From a code point of view, Equinox are an implementation of the OSGi Core Framework specification, a set of bundles that IM Plement various optional OSGi services and other infrastructure for running osgi-based systems.
Above is the description of Equinox official website, Equinox is an OSGI implementation, specifically do not repeat, the following see Equinox how to play, directly on the code.
According to the Convention, a Hello World
chestnut. First Hello World
, a bundle of output is typed,
PackageMe.kisimple.just4fun.osgi;ImportOrg.osgi.framework.BundleActivator;ImportOrg.osgi.framework.BundleContext; Public class ibundleactivator implements bundleactivator { @Override Public void Start(Bundlecontext Bundlecontext)throwsException {System.out.println ("Hello,world."); }@Override Public void Stop(Bundlecontext Bundlecontext)throwsException {System.out.println ("Goodbye,world."); }}
MANIFEST.MF
So write,
manifest-version : 1.0 bundle-manifestversion : 2 bundle-name : helloworld Bundle-symbolicname : me.kisimple.just4fun.osgi.helloworld bundle-version : 1.0.0 Bundle-activator : me.kisimple.just4fun.osgi.ibundleactivator bundle-vendor : kisimple Bundle-localization : systembundle Import-package : org.osgi.framework
And then pack,
> jar cvfm me.kisimple.just4fun_1.0.0.jar MANIFEST.MF me\kisimple\just4fun\osgi\IBundleActivator.class
Next need to go to the official website download Equinox SDK, I next is equinox-sdk-lunasr2.zip. Then refer to the official website of the Quick Start document, we create a new container
directory, the directory has the following files,
E:\projects> Tree container/fE:\projects\container│org. Eclipse. Equinox. Common_3. 6.. V20130402-1505.jar│org. Eclipse. OSGi_3. Ten. 2. V20150203-1939.jar│org. Eclipse. Update. Configurator_3. 3.. V20140518-1928.Jar│├─configuration│config. INI│└─plugins Me. Kisimple. Just4fun_1. 0. 0. JarOrg. Apache. Felix. Gogo. Command_0. Ten. 0. V201209301215. JarOrg. Apache. Felix. Gogo. Runtime_0. Ten. 0. V201209301036. JarOrg. Apache. Felix. Gogo. Shell_0. Ten. 0. V201212101605. JarOrg. Eclipse. Equinox. Console_1. 1. 0. V20140131-1639.Jar
In addition to me.kisimple.just4fun_1.0.0.jar
org.eclipse.update.configurator_3.3.300.v20140518-1928.jar
that, the other jar packages are available from the downloaded SDK, which is the bundle of outputs from the me.kisimple.just4fun_1.0.0.jar
above, and the Hello World
org.eclipse.update.configurator_3.3.300.v20140518-1928.jar
installation directory from Eclipse (which version of >_< has forgotten to install). plugins
directory (itself, Eclipse also uses Equinox, so there are configuration/config.ini
files and plugins
directories).
configuration/config.ini
As follows
osgi.bundles=org.eclipse.equinox.common@2:start, org.eclipse.update.configurator@3:start
Alright, the next thing you can do is start Equinox,
E:\Projects\container>java -jar org.eclipse.osgi_3.10.2.v20150203-1939.jar -consoleosgi> _
You can then start our bundle on the command line. First use ss
the command to see the bundle,
osgi> SS"The Framework is launched."ID State Bundle0ACTIVE org. Eclipse. OSGi_3. Ten. 2. V20150203-19391ACTIVE org. Eclipse. Equinox. Common_3. 6.. V20130402-15052ACTIVE org. Eclipse. Update. Configurator_3. 3.. V20140518-19283Resolved Me. Kisimple. Just4fun. OSGi. HelloWorld_1. 0. 04ACTIVE org. Apache. Felix. Gogo. Command_0. Ten. 0. V2012093012155ACTIVE org. Apache. Felix. Gogo. Runtime_0. Ten. 0. V2012093010366ACTIVE org. Apache. Felix. Gogo. Shell_0. Ten. 0. V2012121016057ACTIVE org. Eclipse. Equinox. Console_1. 1. 0. V20140131-1639
Start our bundle,
osgi> start 3Hello,World.
At this point ss
, we can see the state of our bundle is changed by the command. ACTIVE
3 ACTIVE me.kisimple.just4fun.osgi.HelloWorld_1.0.0
Stop our bundle,
stop3Goodbye,World.
The state of the bundle will be back again RESOLVED
.
Resources
- http://eclipse.org/equinox/documents/quickstart-framework.php
- Http://www.javaworld.com/article/2077837/java-se/hello–osgi–part-1–bundles-for-beginners.html
- Http://developer.51cto.com/art/200909/152209.htm
Preliminary study on Osgi#1:equinox