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

Inherits:
Object
  • Object
show all
Defined in:
lib/openhab/rspec/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.



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

def initialize(bundle)
  @bundle = bundle
end

Instance Method Details

#get_class_loaderObject

rubocop:disable Naming/AccessorMethodName



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

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

#get_resource(path) ⇒ Object



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

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

#get_resources(path) ⇒ Object



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

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

#load_class(name) ⇒ Object



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

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