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
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/lock_jar/class_loader.rb', line 29 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
53 54 55 |
# File 'lib/lock_jar/class_loader.rb', line 53 def add_path(path) @class_loader.addPath(path) end |
#isolate(&blk) ⇒ Object
Execute block
45 46 47 |
# File 'lib/lock_jar/class_loader.rb', line 45 def isolate(&blk) instance_eval(&blk) end |
#new_instance(clazz, *args) ⇒ Object
Create new instance of a Java class using the populated ClassLoader
63 64 65 |
# File 'lib/lock_jar/class_loader.rb', line 63 def new_instance(clazz, *args) @class_loader.newInstance(clazz, *args) end |