Friday, June 26, 2009

Don't Use System.out.println! but Log4j

Here is the bible when you want/need to configure Log4J. Thanks to Vipan Singla

Don't Use System.out.println!

Wednesday, June 24, 2009

OSGi Blueprint Services

In this very nice presentation of Guillaume Nodet, you will discovered what is magic behind OSGi Blueprint Services. This implementation who will be part of the next OSGI specification 4.2 will help the Java developer/architect to better design their solutions. The blueprint services are largely inspired from Spring Dynamic Module project but now it becomes a standard like EJB, ... in the past.


Tuesday, May 5, 2009

Apache Camel / OSGI / Wicket (real example - tutorial part2)

I have finalized a first draft of the second part of my tutorial about Camel 2.0 / ServiceMix-Karaf / CXF / OSGI / Apache Wicket

The purpose of the second part was to explain how to design a simple project where different concepts like :
  • persistence (Hibernate/spring),
  • routing (Apache Camel 2.0),
  • mapping between CSV file and objects (using camel-bindy),
  • webservices (Apache CXF - OSGI),
  • osgi stuffs,
  • packaging and deployment on Apache Karaf/ServiceMix OSGI server (features, PAX url),
  • web application integration (Apache Wicket, PAX Web)
have been addressed.

The tutorial has been designed in 4 parts :

  • Part 2a : real example, architecture, project setup, database creation
  • Part 2b : transform projects in bundles
  • Part 2c : add infrastructure and routing
  • Part 2d : web and deployment

and is available here : http://cwiki.apache.org/CAMEL/tutorial-osgi-camel-part2.html

Don't hesitate to provide me your remarks/comments to improve it.

Trick to pass an uri declared in a property file to a Camel route

Defining Camel uris in a file is not so easy. Until now, the only possibility was to create a camel endpoint where the uri was declared in the XML file.

Here is a trick who will simplify your life to declare/define the uri in a property file. Spring injection is used to replaced the variable declared in your XML file with the value discovered in the property file.

By example, to work with the following uri : file://d:/temp/data/?move=d:/temp/done/${file.name}

Remark : as you can see, the uri contains a variable to a Camel variable and in consequence is not a Spring bean. So we have to inform Spring that the variable to be searched in the XML file use another syntax delimiter (#{} instead of ${}).

Here is what you have to do

Step 1 : Create org.springframework.beans.factory.config.PropertyPlaceholderConfigurer bean

Define a PropertyPlaceHolder (using another prefix/suffix delimiter) to avoid conflict between your camel variable and Spring property



(1)
(2)
(2)


(1) : Define a different prefix instead of ${ which is the value by default and used as variable
(2) : Define the value of the suffix. In this case, this is the same as the default value

Step 2 : Create org.apache.camel.example.reportincident.routing.properties

Create the following file : org.apache.camel.example.reportincident.routing.properties and put it in your classpath. If you plan to deploy your camel route under Apache ServiceMix Kernel --> Apache Karaf, add this file in the META-INF/spring directory by example
Add the following property :

uriFile=file://d:/temp/data/?move=d:/temp/done/${file.name}

Step 3 : Create an endpoint in your Camel Spring DSL file

Create a camel endpoint for the uri that you would like to use



(1)

(1) As you can see, we use as a Spring variable reference the syntax #{} so spring will retrieve the value from the variable declared in the file

Step 4 : Adapt your route

Define the uri of your route like this :




Cool isn't !!

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.