Class: RSpec::OpenHAB::JRuby::OSGiBundleClassLoader

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec/openhab/jruby.rb

Overview

Basically org.jruby.embed.osgi.OSGiIsolatedScriptingContainer$BundleGetResources, but implemented in Ruby so that it doesn’t have a hard dependency on org.osgi.bundle.Bundle – which we may need to load!

Instance Method Summary collapse

Constructor Details

#initialize(bundle) ⇒ OSGiBundleClassLoader

Returns a new instance of OSGiBundleClassLoader.



12
13
14
# File 'lib/rspec/openhab/jruby.rb', line 12

def initialize(bundle)
  @bundle = bundle
end

Instance Method Details

#get_class_loaderObject

rubocop:disable Naming/AccessorMethodName



28
29
30
# File 'lib/rspec/openhab/jruby.rb', line 28

def get_class_loader # rubocop:disable Naming/AccessorMethodName
  @bundle&.adapt(org.osgi.framework.wiring.BundleWiring.java_class)&.class_loader
end

#get_resource(path) ⇒ Object



16
17
18
# File 'lib/rspec/openhab/jruby.rb', line 16

def get_resource(path)
  @bundle.get_resource(path)
end

#get_resources(path) ⇒ Object



20
21
22
# File 'lib/rspec/openhab/jruby.rb', line 20

def get_resources(path)
  @bundle.get_resources(path)
end

#load_class(name) ⇒ Object



24
25
26
# File 'lib/rspec/openhab/jruby.rb', line 24

def load_class(name)
  @bundle.load_class(name)
end