Class: LockJar::ClassLoader
- Inherits:
-
Object
- Object
- LockJar::ClassLoader
- Defined in:
- lib/lock_jar/class_loader.rb
Overview
Create a ClassLoader populated by a lockfile
Instance Method Summary collapse
-
#add_path(path) ⇒ Boolean
Add path to the ClassLoader.
-
#initialize(lockfile) ⇒ ClassLoader
constructor
Create new instance, populating ClassLoader with lockfile.
-
#isolate(&blk) ⇒ Object
Execute block.
-
#new_instance(clazz, *args) ⇒ Object
Create new instance of a Java class using the populated ClassLoader.
Constructor Details
#initialize(lockfile) ⇒ ClassLoader
Create new instance, populating ClassLoader with lockfile
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/lock_jar/class_loader.rb', line 31 def initialize( lockfile ) # XXX: ensure Naether has been loaded, this should be handled less # clumsily LockJar::Runtime.instance.resolver(nil) @class_loader = com.tobedevoured.naether.PathClassLoader.new(JRuby.runtime.jruby_class_loader) jars = LockJar.list( lockfile, :local_paths => true ) jars.each do |jar| add_path( jar ) end end |
Instance Method Details
#add_path(path) ⇒ Boolean
Add path to the ClassLoader
54 55 56 |
# File 'lib/lock_jar/class_loader.rb', line 54 def add_path( path ) @class_loader.addPath( path ) end |
#isolate(&blk) ⇒ Object
Execute block
46 47 48 |
# File 'lib/lock_jar/class_loader.rb', line 46 def isolate(&blk) instance_eval(&blk) end |
#new_instance(clazz, *args) ⇒ Object
Create new instance of a Java class using the populated ClassLoader
64 65 66 |
# File 'lib/lock_jar/class_loader.rb', line 64 def new_instance( clazz, *args ) @class_loader.newInstance( clazz, *args ) end |