Jump to: navigation, search

Using FrameworkAdmin from Java programs

Revision as of 16:38, 16 February 2007 by Yamasaki.ikuo.lab.ntt.co.jp (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Overview

Since version 1.1.0, FrameworkAdmin API and its implementation enables not only a bundle but also a Java program, which is not OSGi based application, to do the followings in a framework independent way.

  • Set configurations required to launch a framework, such as
    • Java VM location,
    • Java VM arguments,
    • executable launcher location, if used
    • beginning start level and initial bundle start level of a framework,
    • Bundles to be installed and started with their start levels,
    • framework configuration location,
    • framework persistent date location,
  • Launch a framework with the specified configurations.
  • get the expected state of a framework when it runs.

Provider of FrameworkAdmin

To realize it, the provider should do

  1. implement a subclass of FrameworkAdminFactory whose createFrameworkAdmin() returns a FrameworkAdmin object which doesn’t use BundleContext at all.
  2. declare the fully qualified class name of it in public.
    • for instance, the name of the class in org.eclipse.equinox.frameworkadmin.equinox bundle is declared as org.eclipse.equinox.frameworkadmin.equinox.internal.EquinoxFrameworkAdminFactoryImpl.

Client Java program of FrameworkAdmin

On the other hand, a client Java program should do

  1. set classpath properly in order to load required classes.
    • Taking org.eclipse.equinox.frameworkadmin.equinox version 1.1.0 as an example, set org.eclipse.osgi_*.jar, org.eclipse.equinox.frameworkadmin_*.jar and org.eclipse.equinox.frameworkadmin.equinox_*.jar to its classpath.
  2. in the code, call static method FrameworkAdminFactory.getInstance(className) with the fully qualified class name of its FrameworkAdminFactory subclass org.eclipse.equinox.frameworkadmin.equinox.internal.EquinoxFrameworkAdminFactoryImpl in order to get a FrameworkAdmin object for Equinox.

After instantiate a FrameworkAdmin object for the target framework implementation, do as same as a bundle which gets an FrameworkAdmin object from the service registry on running framework does for configuring and launching a framework.

Example code

Example code of a client Java program is included in org.eclipse.equinox.frameworkadmin.examples plug-in. In order to run it, set properties file called "setting.properties" properly to your environment in advance (you don’t need to set properties related with either Knopflerfish or Felix, in this case) and just run Main class as a Java application from PDE (IDE).

References

  1. [Equinox_FrameworkAdmin FrameworkAdmin]