Developing and Deploying an OSGI Bundle on to the ADEP Experience Server

The Open Services Gateway Initiative (OSGi), also known as the Dynamic Module System for Java, defines architecture for modular application development. ADEP Experience Server is developed on the OSGi container implementation Apache Felix, which allows you to break your application into multiple modules and thus more easily manage cross-dependencies between them.

In this blog entry I am going to show how easy it is to develop your custom OSGI bundle and deploy it in the ADEP’s Felix OSGI container. So you can easily develop your backend services as bundles and have them exposed to your front end applications.

Hello OSGI Bundle

First let’s develop a simple OSGI bundle; in this post we will utilize the Eclipse IDE to develop our bundle.  If you already not have Eclipse IDE installed get it installed from http://www.eclipse.org/downloads/ , I have Eclipse 3.7(INDIGO) installed which will be used to develop our bundle. Let’s get started!

  • From  Eclipse IDE Click File->New->Project
  • From the New Project wizard select Plug-in Project and click Next

 

  • Type the Project name in the Project name field
  • For Target Platform Select an OSGI framework and from the drop down standard Click Next 

 

  • View the bundle content details which will become the entries in the bundle’s MANIFEST.MF Leave everything as displayed click Next               
  •  Let’s use a template for our OSGI bundle.  Make sure Create a plug-in using one of the templates is checked.
  • As you can see there are many readily available templates which will get you on your way of developing much more complicated bundles.  But for the purpose of this post we are going to keep it simple, Select Hello OSGI Bundle template from the Available Templates and click Next.
  • We can customize the start and stop messages.  Every OSGI bundles consists of an Activator class which implements the BundleActivator interface, in the Activator class the start and stop operations are invoked by the OSGI framework when a bundle starts and stops.  Here we are just printing messages to standard output when the bundle starts and stops.  But you might as well register a class you developed as a service or consume a service you might be interested in by modifying the generated Activator class.
  • You may edit the start and stop messages as below, click Finish.

Now all the code needed for our simple HelloADEP OSGI bundle is auto generated.  You can open the Activator.java and the MANIFEST.MF to take a look at the generated code or to customize it.

We have all the code needed for our HelloADEP OSGI bundle, let’s build and export it as a jar so it can be deployed in the ADEP’s Felix OSGI container.

  • Right Click on the HelloADEP project from the Project Explorer and Click Export
  • In the Export wizard expand Plug-in Development and select Deployable plug-ins and fragments then click Next.
  • Make sure our HelloADEP bundle is selected from the Available plug-ins and Fragments list. For Destination enter a directory location where the HelloADEP bundle will be saved as a jar.  Click Finish

Upon Clicking Finish above, the build scripts were executed by Eclipse to build and package the HelloADEP bundle jar.  If you browse the directory chosen on the above step you will see a plugins folder created and inside the HelloADEP.jar is copied.  The generated jar file would have the version and date appended to the jar name.

Deploying the HelloADEP OSGI bundle to ADEP Experience Server

Now that we have developed our HelloADEP OSGI bundle, Lets deploy it to the ADEP’s Felix container.

 

  •  Using the Browse button on the upload/install Bundles dialog locate the HellowADEP.jar that was developed.  Click Install or Update.
  • Click the Reload button to refresh the page, locate the HelloADEP bundle and click the start/play button.   Now the status for the HelloADEP bundle will be changed from Installed to Active.

Now that we have deployed and started our HelloADEP OSGI bundle to the Experience Server, let’s see if our bundle start message is printed to standard output.  Open the Experience Server’s logs folder (crx-quickstart\logs) and locate the stdout.log, at the end of the log file you will see “Hello ADEP World!!”

There it is, in less than ten minutes we were able to develop and deploy an OSGI bundle on to the ADEP Experience Server.

 

 

VN:F [1.9.22_1171]
Was this helpful? Please rate the content.
Rating: 0.0/10 (0 votes cast)

About Suren@adobe

Suren is a Computer Scientist who works on Adobe Digital Enterprise Platform(ADEP).
This entry was posted in ADEP, Experience Services and tagged . Bookmark the permalink.

2 Responses to Developing and Deploying an OSGI Bundle on to the ADEP Experience Server

  1. Pingback: Developing and Deploying an OSGI Bundle on to the ADEP Experience Server « Enterprise Platform Techies

  2. Christa Kovac says:

    Why not use CRXDE Lite, instead of Eclipse, to create the OSGI bundle?
    http://dev.day.com/content/docs/en/crx/20/developing/development_tools/developing_with_crxde_lite.html#Managing a Bundle