Wednesday, April 22, 2009

Camel Tutorial - OSGI part 1 (UPDATED)

I'm currently working on the part of the camel - OSGI tutorial part 2 but I have found the time to update the first part. This was required because I would like to use the maven PAX plugin instead of spring maven plugin and test it against SMX 1.1.0 and Camel 1.6.0.

The PAX maven plugin offers a lot of advantages regarding to the one of Spring (which is currently becoming a new tool called - bundlor)
- pom.xml file generated only include dependencies, plugin required,
- project can be designed with several modules,
- project can be tested with PAX Exam and launched using PAX runner
- ...

Here is the link to tutorial

Tuesday, April 21, 2009

Distributed OSGi – A Simple Example

Here is a very interesting article explaining what Distributed OSGI will looks like using implementation done by CXF project.

<coderthoughts />: Distributed OSGi – A Simple Example

Monday, April 20, 2009

ServiceMix 4 et son kernel OSGi (Xebia France)

L' excellente revue Xebia parle de ServiceMix et Service Mix Kernel.

Il est toujours intéressant de constater que des acteurs importants dans la vulgarisation des technologies clés dans les développements Java, ESB s'intéressent à ce projet inovateur, construit sur des fondations solides : Apache Felix, Spring DM et PAX et continue à séduire.

Tuesday, April 14, 2009

The power of Apache wicket and Spring OSGI Service top of ServiceMix 4

In a previous post, I have explained how you can transform ServiceMix 4 as a Web Application Server. In this new post, I will show you How you can combine the power of Apache Wicket and Spring OSGI services together on ServiceMix 4 with the help of PAX Web.

This mix can be achieved very easily. Only a few steps are required.

1) Create a maven project where you will design your spring service and expose it as an OSGI service according to the Spring documentation.






2) Create a new maven project that you will use to package your Apache web application. The trick here is to modify your web.xml file like this :

a) add listener and context parameter for the Spring OSGI Context Loader



b) Add Spring Factory to Apache (required to allow injection of dependency in java classes of Wicket)



Please refer to the Apache Wicket Web site for more info about Spring integration

3) create an applicationContext.xml file under WEB-INF folder containing the reference to the OSGI service :

<osgi:reference id="incidentService" interface="org.apache.camel.example.reportincident.service.IncidentService"/>

4) And of course, in your Wicket page, inject dependency using the Wicket annotation :

@SpringBean
private IncidentService incidentService;

5) Now generate the bundles (JAR/WAR) and deploy them top of SMX4. Before to deploy the war containing the web project, verify that the following bundles are deployed on SMX4 :

- OPS4J Pax Web - Web Container (0.6.0)
- OPS4J Pax Web - Jsp Support (0.6.0)
- OPS4J Pax Web Extender - WAR (0.5.1)
- OPS4J Pax Web Extender - Whiteboard (0.5.1)
- OPS4J Pax Url - war:, war-i: (0.4.0)

- spring-osgi-web (1.2.0.rc1)
- Wicket (1.3.5)
- Wicket IoC common code (1.3.5)
- Wicket Spring Integration (1.3.5)
- Wicket Spring Integration through Annotations (1.3.5)
- Wicket Extensions (1.3.5)

- Apache ServiceMix Bundles: jetty-6.1.14 (6.1.14.1)

A tutorial will be published soon with material and step by step.

Remarks :
- PAX-runner can be used as running environment (instead of Servicemix) with Equinox, Felix, ...
- Many thanks to Alin Dreghiciu (PAX project) for its help/support

Tuesday, March 31, 2009

What's new in ServiceMix 4

Rob Biresch has published an interesting post in dzone (SOA zone) about what is new in ServiceMix 4.

For more info, read its post and don't hesitate to vote on dzone

http://soa.dzone.com/news/whats-new-servicemix-4x

Monday, March 30, 2009

Trick to customize war deployment on ServiceMix4 using PAX

Here is another very interesting trick that you can use to customize the war the deployment process on ServiceMix.

customize = in this context, this word means How can I add property or extend existing of a MANIFEST file

e.g. : The WAR to be deployed contains tlb files created under the folder WEB-INF/tags/form and WEB-INF/tags/jms. By default PAX will create a MANIFEST file containing the property Bundle-Classpath with :
  • WEB-INF/classes
  • all jars from WEB-INF/lib directory
but will not take care about your folders

Two possibilities are available to tell to PAX that it must include in the Bundle-Classpath your folders

1) Command + uri

This one consists in to pass the parameters as an uri like this :

install war:file:///d:/temp/activemq-web-console-5.2.0.war?Bundle-Classpath= ., WEB-INF/tags/form, WEB-INF/tags/jms&Webapp-Context= activemqweb

2) Create a file.bnd + command

Another interesting option is to provide as a file the location of the WAR and the properties that you want to add
  • Create a file called xxxx.bnd
  • Add in the file the following lines :
WAR-URL=file:///c/temp/activemq-web-console-5.2.0.war
Bundle-Classpath=., WEB-INF/tags/form, WEB-INF/tags/jms
Webapp-Context=activemqweb
  • use in your favorite OSGI server (ServiceMix) the following command to install the WAR :
install war-i:file:///c:/temp/activemq-web-console-5.2.0.bnd

Friday, March 27, 2009

ServiceMix 4 as a Web Application Server

This week, I have discovered the web possibilities offered by the ServiceMix 4 platform. SMX ("pour les intimes") uses as its core platform the excellent packages of the project PAX which is the umbrella project for all OSGi bundles and tools.

In standard, the following bundles are installed :

[ 9] [Active ] [ ] [ 8] OPS4J Pax Logging - API (1.3.0)
[ 10] [Active ] [ ] [ 8] OPS4J Pax Logging - Service (1.3.0)
[ 11] [Active ] [ ] [ 5] OPS4J Pax Url - wrap: (0.3.3)
[ 12] [Active ] [ ] [ 5] OPS4J Pax Url - mvn: (0.3.3)

They are used to log information of the server and to install or wrap bundles. Nevertheless, PAX project is not limited to the mentioned bundles but proposes also Web support for jetty.

To install or transform ServiceMix as a Web Application Server, you can use the "web" and "web-core" feature (available under ServiceMix 4) or install the following bundles manually :

- OPS4J Pax Web - Web Container (0.5.2)
- OPS4J Pax Web - Jsp Support (0.5.2)
- OPS4J Pax Web Extender - WAR (0.5.0)
- OPS4J Pax Web Extender - Whiteboard (0.5.0)
- OPS4J Pax Url - war:, war-i: (0.3.3)
- Apache ServiceMix Bundles: jetty-6.1.14 (6.1.14.1)

The Web Application Server becomes available at the url http://localhost:8080.

Evidently, no jsp pages, servlets are available. Don't worry, to deploy a WAR, you only have to copy it to the deploy directory of ServiceMix and it will convert be converted as a bundle

By example, you can install a simple Hello World war using the command

install war:file:///d:/temp/sample.war?Webapp-Context=sample

remarks :
- file:/// must be changed according to the location of your war
- The parameter WebApp-Context is added to have a nicer web address

and see the result at the address : http://localhost:8080/sample/index.html

Yes, this looks beautiful but the web port number is 8080, my boss would like to secure the web site, change the session timeout, ....

This is very simple to do, you create a file named (org.ops4j.pax.web.cfg) and copy it in the directory etc of servicemix, in this file you can parametrize by example the following properties (see PAX for more information) :

org.osgi.service.http.port=80
org.ops4j.pax.web.session.timeout=10


You restart Servicemix and now the web site is available at the following address :

http://localhost/sample/index.html