Programmatically Start OSGi (Equinox)?

前端 未结 3 1895
野性不改
野性不改 2020-11-28 04:39

I\'d like to be able to easily start an OSGi framework (preferably Equinox) and load up any bundles listed in my pom from a java main.

Is this possible? If so, how?

3条回答
  •  北荒
    北荒 (楼主)
    2020-11-28 04:45

    Edit: Realized you wanted to start from inside java. Shame on me for not reading close enough

    Check out this link. http://www.eclipsezone.com/eclipse/forums/t93976.rhtml

    Essentially

    public static void main(String args[]) throws Exception {
      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();
    }
    

    Edit: Maven

    It seems that https://groups.google.com/group/spring-osgi/web/maven-url-handler?pli=1 contains an OSGi URl Handlers Service that can take URLS of the following format and load bundles from them ( mvn://repo/bundle_path )

提交回复
热议问题