Class: Jnlp::Otrunk
Overview
Jnlp::Otrunk is a subclass of Jnlp::Jnlp that adds SAIL-Otrunk specific methods for execution.of the jnlp locally without using Java Web Start.
It assumes a default main-class of:
net.sf.sail.emf.launch.EMFLauncher2
and by default uses the argument in the original jnlp. Both of these values can be overridden.
Example:
j = Jnlp::Otrunk.new('http://rails.dev.concord.org/sds/2/offering/144/jnlp/540/view?sailotrunk.otmlurl=http://continuum.concord.org/otrunk/examples/BasicExamples/document-edit.otml&sailotrunk.hidetree=false', 'cache'); nil
Instance Method Summary collapse
-
#run_local(argument = @argument, main_class = 'net.sf.sail.emf.launch.EMFLauncher2') ⇒ Object
This will start the jnlp locally in Java without using Java Web Start.
-
#stop_local ⇒ Object
This will stop the locally run OTrunk process.
Instance Method Details
#run_local(argument = @argument, main_class = 'net.sf.sail.emf.launch.EMFLauncher2') ⇒ Object
This will start the jnlp locally in Java without using Java Web Start
This method works in MRI by forking and using exec to start a separate javavm process.
JRuby Note:
In JRuby the jars are required which makes them available to JRuby – but to make this work you will need to also included them on the CLASSPATH.
The convienence method Jnlp#write_local_classpath_shell_script can be used to create a shell script to set the classpath.
If you are using the JRuby interactive console you will need to exclude any reference to a separate jruby included in the jnlp.
Example in JRuby jirb:
j = Jnlp::Otrunk.new('http://rails.dev.concord.org/sds/2/offering/144/jnlp/540/view?sailotrunk.otmlurl=http://continuum.concord.org/otrunk/examples/BasicExamples/document-edit.otml&sailotrunk.hidetree=false', 'cache'); nil
j.write_local_classpath_shell_script('document-edit_classpath.sh', :remove_jruby => true)
Now exit jirb and execute this in the shell:
source document-edit_classpath.sh
Now restart jirb:
j = Jnlp::Otrunk.new('http://rails.dev.concord.org/sds/2/offering/144/jnlp/540/view?sailotrunk.otmlurl=http://continuum.concord.org/otrunk/examples/BasicExamples/document-edit.otml&sailotrunk.hidetree=false', 'cache'); nil
j.run_local
You can optionally pass in jnlp and main-class arguments If these paramaters are not present Otrunk#run_local will use:
net.sf.sail.emf.launch.EMFLauncher2
as the default main class and the default argument in the original jnlp.
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 |
# File 'lib/jnlp/otrunk.rb', line 142 def run_local(argument=@argument, main_class='net.sf.sail.emf.launch.EMFLauncher2') if RUBY_PLATFORM =~ /java/ java.lang.Thread.currentThread.setContextClassLoader(JRuby.runtime.jruby_class_loader) require_resources configUrl = URL.new(JavaIO::File.new("dummy.txt").toURL, argument) # configUrl = URL.new("document-edit.config") unless @bundleManager @bundleManager = SailCoreBundle::BundleManager.new @serviceContext = @bundleManager.getServiceContext @bundleManager.setContextURL(configUrl) # # Add the <code>bundles</code> configured in this bundles xml file. The format of the file # is XMLEncoder # @bundleManager.addBundles(configUrl.openStream) # # Have all the bundles register their services, and then do any linking # to other registered services # @bundleManager.initializeBundles # # Start the session manager # @manager = @serviceContext.getService(SailCoreService::SessionManager.java_class) end @manager.start(@serviceContext) else command = "java -classpath #{local_classpath} #{main_class} '#{argument}'" $pid = fork { exec command } end end |
#stop_local ⇒ Object
This will stop the locally run OTrunk process. This only works in MRI at this point.
179 180 181 182 183 184 185 186 |
# File 'lib/jnlp/otrunk.rb', line 179 def stop_local if RUBY_PLATFORM =~ /java/ @manager.stop(@serviceContext) else Process.kill 15, $pid Process.wait($pid) end end |