jruby-bridge lets you create objects within MRI Ruby that have all their execution performed in a JRuby context.
To do this it uses a JRuby DRb service process. Objects passed by reference to method calls are transparently marshalled and executed within the JRuby service, and the results are passed back. Procs are executed in the context they're defined in.
This can be used to add commercial jdbc database support and other JRuby accessible tech to MRI-based projects without having to change much.
Based on, and forked from https://github.com/mkfs/jruby-bridge "See http://entrenchant.blogspot.com/2012/07/drb-jruby-bridge.html for full discussion."
Add this line to your application's Gemfile:
gem 'jruby-bridge'
And then execute:
$ bundle
Or install it yourself as:
$ gem install jruby-bridge
Pat a kitten.
require 'jruby-bridge'
# Make sure JRuby has the right classes loaded
JRubyBridge::Service.remote_require 'kittens', 'puppies'
# Start the JRuby service process
JRubyBridge::Service.with_service do
# Now, every new SomeClass lives remotely
SomeClass.send :include, JRubyBridge::ObjectProxy
# Make a remote object
remote_object = SomeClass.new 'some', 'args'
# executes in the JRuby process
new_object = remote_object.do_stuff
# also in the JRuby process (pass by ref)
new_object.do_more_stuff
# lambdas are executed in this process
new_object.each { |thing| process thing }
end # Stop the JRuby service process# You can also control the service manually
JRubyBridge::Service.start
JRubyBridge::Service.stop- Ahh, some tests?
- Convince the Enterprise to stop using commercial databases
- Lazy-launching of the service process
- Hearbeat signal with auto-shutdown of service process
- Proxy signals to the service
- Fork it
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create new Pull Request