Class: ClassLoader
Class Method Summary collapse
Methods inherited from AuxLoader
getFacility, is_qualified?, loadFacility
Class Method Details
.loadConnectionClass(subdir, class_name, facility_name = nil) ⇒ Object
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 |
# File 'lib/vcseif/utils/auxloader.rb', line 140 def self.loadConnectionClass(subdir, class_name, facility_name=nil) %{ A generalized means of loading a class. The priority ladder is to first attempt to find and load the class_name from the specific subdir named in any facility_name supplied, In the event that fails, the next attempt to get the class loaded in looks in the '#{ENV['VCS_APP_ROOT']}/lib/vcseif' subdirectory. If that also fails, an attempt is made to load the class via Kernel.const_get in the event that the class is in an already loaded gem. If a facility_name is given, it restricts the location of the class to a specific Ruby file (named by facility_name, which would be the part of the filename without the ".rb" suffix). } ## ## $stdout.write("call of ClassLoader.loadConnectionClass(#{subdir}, #{class_name}, #{facility_name})\n") ## $stdout.flush() ## candidates = [[1, subdir], [2, 'lib/vcseif']] for rung, candidate in candidates do fq_facility_dir = "#{ENV['VCS_APP_ROOT']}/#{candidate}" # fully qualified path to candidate if not File.exists?(fq_facility_dir) or not File.directory?(fq_facility_dir) ## ## $stdout.write(" rung ##{rung} of loadConnectionClass skipped\n") ## next end success = false begin conn_class = loadFacility(candidate, class_name, facility_name) ## ## $stdout.write(" rung ##{rung} of loadConnectionClass succeeded\n") ## $stdout.flush() ## success = true rescue Exception => ex ## ## $stdout.write(" rung ##{rung} of loadConnectionClass failed...\n") ## $stdout.flush() ## raise if ex..include?("defined in more than one file") end return conn_class if success end # # try a Kernel.const_get(class_name) to see # if we can obtain the class from an already loaded relevant *eif gem # begin @@facility_class = Kernel.const_get(class_name) success = true rescue Exception => ex $stderr.write("Caught exception attempting to load #{class_name}: #{ex.}\n") raise end return @@facility_class if success return nil end |