| Launching a product from within Java [message #544004] |
Thu, 01 July 2010 06:21  |
Chris Messages: 3 Registered: July 2010 |
Junior Member |
|
|
Hello there,
I'm looking to find out if possible whether there is a way to launch an Equinox OSGI prodct from within Java.
Currently we launch via JNLP or via an Eclipse.exe however we have a new requirement to now launch from within an already running java application.
Within our JNLP we have many plugin's and a product under the resources. Then of course we have the start options for some of the plugins as well as instance areas and other properties.
String[] equinoxArgs = { "-console", "1234", "-noExit" };
BundleContext context = EclipseStarter.startup(equinoxArgs, null);
Bundle bundle = context.installBundle("http://www.eclipsezone.com/files/jsig/bundles/HelloWorld.jar");
bundle.start();
Is what I've found so far with a little google action, but are my plugin's bundles? Is there any more documentation on where I set the properties for products and other properties?
It's worth mentioning that all the plugins will be local on disk somewhere.
Thanks for any help or pointers!!
Chris
[Updated on: Thu, 01 July 2010 06:40] Report message to a moderator
|
|
|
| Re: Launching a product from within Java [message #546000 is a reply to message #544004] |
Fri, 09 July 2010 16:29   |
ib Messages: 2 Registered: July 2010 |
Junior Member |
|
|
Hi Chris,
If it's an OSGi product, you can launch your product inside a regular POJO. Here is an example:
public class MyTestClass
{
public void myMethod(Object interestingObj)
{
String[] arguments = {"-consolelog", "-noExit", "-product", "myeclipse.product", "-name", "My Product", "-install", "\\MyProductDir", "-configuration", "\\MyProductDir\\configuration"};
Main.main(arguments);
}
}
Hope this helps.
|
|
|
| Re: Launching a product from within Java [message #714730 is a reply to message #546000] |
Thu, 11 August 2011 07:53  |
Chris Messages: 3 Registered: July 2010 |
Junior Member |
|
|
import org.eclipse.core.runtime.adaptor.EclipseStarter;
public class LaunchOsgi
{
public static void main(String args[]) throws Exception
{
if(args.length == 0)
{
System.err.println("Usage: configuration-directory");
System.exit(1);
}
try
{
Map<String, String> initProps = new HashMap<String, String> ();
initProps.put("osgi.configuration.area", args[0]);
EclipseStarter.setInitialProperties(initProps);
EclipseStarter.debug = true;
EclipseStarter.startup(new String[]{}, null);
EclipseStarter.run(new String[]{});
}
catch(Throwable t)
{
t.printStackTrace();
}
finally
{
EclipseStarter.shutdown();
}
}
}
I know this is an old thread but it might help someone else with a similar question.
Here is the solution we used in the end, you only need to specify the configuration path.
|
|
|
Powered by
FUDForum. Page generated in 0.01575 seconds