[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [equinox-dev] Starting equinox framework in program

Tom,
    Thanks for your reply. I sorry that I did not express my question clearly. 
    I was finding a way to start an Equinox framework through Java application. It looks like: I have a set of bundles in a folder which construct an application. In a normal way when I want to start the framework, I just need to click the launcher or type a command line in the console. What I need is to write a program, this program may NOT be a bundle, and start the Equinox framework and install all the bundles in the folder but no need to click or type something. I have search on google and found that EclipseStarter can do this in Java application, and I have try it. Code likes: 

    public static void main(String[] args) {
         BundleContext context = null;
         // start up OSGI framework.
        context = EclipseStarter.startup(new String[] { "-console" }, null);
        context.installBundle("file:////path/to/bundle.jar");
      }
       
    For my application is an ECLIIPSE PLUG-IN, when I use the same code snipe to start another Equinox framework, I got the error message that told me "framework is running". I think the reason is that Eclipse platform has already use EclipseStarter to start itself, and when you try to use EclipseStarter to start another Equinox framework, you get such error. EclipseStarter is a static utility class.
   I wonder whether there is a way to fix the problem using EclipseStarter or there is another way to start Equinox framework as I need and got BundleContext like the method  EclipseStarter.startup().



2008/9/3 Thomas Watson <tjwatson@xxxxxxxxxx>

I need to better understand your requirements:

Are you simply trying to get a valid BundleContext? If so you get access to your bundle's BundleContext when you bundle is activated. The BundleContext is passed to you in your BundleActivator.start(BundleContext) method.

>From your description it does not sound like you want to actually start another instance of the Equinox when your bundle is already running in an instance of the Framework. Instead you simply need to get access to your bundle's BundleContext so you can interact with the Framework.

HTH.

Tom