Originally, according to my plan, I should continue to write some interesting articles related to Glassfish OSGi-JavaEE(eg. Part5, Part 6…), however, recently, I have seen some requirements related to enterprise application bundle from glassfish community, that is to say, some users wish to make JavaEE ear to live in OSGi world.
So, from now, I will start to write some interesting stories about Glassfish OSGi-Integration.
Before integrating Apache Aries Application into Glassfish, we need to do some preparation.
1 Apache Aries Application Bundles
Basically, there are two ways to obtain the Apache Aries bundles,
1) downloading the current release of Aries Application from , current release is 1.0.0.
Because we *only* need Aries Application bundles to build our .eba application, most of other Apache Aries bundles are not required. Noting that Aries Application bundles depend on blueprint related bundles and other dependencies, so, we also need to obtain these dependencies.
1) building Aries Application bundles from aries trunk based on 
Noting: currently, building aries in JDK 7 will be failed, so, you’d better use JDK 6.
2 Glassfish v4 Distro
Also having two ways to obtain a v4 distro ,
2) building a v4 SNAPSHOT according to
1 Putting Aries Application bundles including dependencies into Glassfish
Based on such a fact that Aries related bundles are from third-party vendors and we must make these bundles available while starting glassfish, so, I put these bundles into glassfish/modules/autostart directory. In order to differentiate from glassfish OSGi-JavaEE bundles, I create a directory called “aries”under autostart directory and create three sub-directories(application, blueprint,dependencies) under aries directory.
1) putting Aries Application bundles into application directory
2) putting Aries Blueprint bundles into blueprint directory
3) putting dependent bundles into dependencies directoryThe result should look like the following,
2 modifying config/osgi.properties file
In order to make aries related bundles available while starting glassfish, apart from 1, we also need to modify config/osgi.properties liking the following,
1) glassfish.osgi.auto.installThe property is used to configure a list of locations from where bundles will be installed. Modifying the properties liking the following and adding the locations of our aries bundles,
2) defining an aries.bundles property
You’d better define an aries.bundles property to differentiate autostart.bundles.
This property is used to configure a list of bundles to be started by felix autoprocessor. However, activation of the bundles still depend on bundle's start level and activation policy. Noting, the means of “depend on bundle's start level”is that “glassfish.osgi.auto.start.level.x”and “glassfish.osgi.start.level.final”control whether starting the bundles. For example,
Assuming having a bundle called “A”,If setting glassfish.osgi.auto.start.level.2 = A, and glassfish.osgi.start.level.final=2(or >2), then, after starting glassfish domain, the A bundle’s status will be active. However, if setting glassfish.osgi.start.level.final=1, the A bundle’s status will be installed.
Coming back the our integration, and modifying the properties liking the following,
modifying the properties liking the following in order to make these aries bundles to be active after starting glassfish domain,
3 starting glassfish domain
So far, let us to start glassfish domain to see whether aries related bundles have been in active status.
Here, we have seen that Aries related bundles are all in active status.
After integrating Aries Application bundles into Glassfish, it is time for us to do a test for deploying a simple .eba application.
1 wrapping a .eba application using org.apache.aries: eba-maven-plugin
In order to save space, I ignore how to create the .eba application using maven. However, you can download the source of the .eba application from the attachment(gfearbundletest.zip).
2 deploying the .eba application into glassfish
Currently, only having a way to deploy the .eba application into glassfish.And putting the .eba application(gfearbundletest.application-1.0.0.eba) into glassfish/domains/domain1/autodeploy/bundles directory. How to use deploy command to deploy the .eba application should be future’s consideration.
3 seeing resultStill using “asadmin osgi lb”to see whether the bundles wrapped in the .eba application has been in active status.
OK, deployment has been successful!Finally, I must seriously say that because of performance factor(eg. org.apache.felix.bundlerepository), the integration should not be put into Glassfish v4 , however, this also tells us integrating with other frameworks based on OSGi is very feasible. Maybe, in the future, while in some way, org.apache.felix.bundlerepository is brought back into Glassfish, I will re-consider or discuss with Sahoo how to make integration better.