Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
java
java
package demo.service;

public interface TransformService {
	
	public Object transform(Object obj);

}

...

Code Block
xml
xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">

  <!-- regular spring configuration file defining the beans for this
       bundle. The configuration of OSGi definitions is kept in a separate 
       configuration file so that this file can easily be used
       for integration testing outside of an OSGi environment -->
    <bean id="transformService"
	      class="demo.service.TransformServiceImpl">
	</bean>
</beans>

...

Code Block
xml
xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:osgi="http://www.springframework.org/schema/osgi"
  xsi:schemaLocation="
  http://www.springframework.org/schema/beans
  http://www.springframework.org/schema/beans/spring-beans.xsd
  http://www.springframework.org/schema/osgi
  http://www.springframework.org/schema/osgi/spring-osgi.xsd">
       
      <osgi:reference id="myTransform" interface="demo.service.TransformService"/>
  
</beans>

Remarks :
- The id of the bean referenced 'myTransform' used by the camel context has a reference to the OSGI interface 'demo.service.TransformService'
- How could we imagine something more simplest ? We don't have to call a JNDI server with a reference or something like that. Only a reference to the service interface.

Step 6 : Generate the manifest and jar file

Run the command 'mvn package' (= Repeat the step 5).

Unfortunately, the MANIFEST.MF file of the Camel bundle does not contain a link to the package 'demo.Service' that the bean 'myTransform' required in order the instantiate the class. This link is not added by the bnd tool during the generation step. So we have to edit the file contained in the jar file 'demo.camel-bundle-0.1.jar' in order to add the following line at the end of the MANIFEST.MF file.

...

Save the MANIFEST.MF file (and the jar containing it)

...

Deploy the bundles

We will show you now that we can easily deploy our bundles in two OSGI servers running a different OSGI kernel :

  • Felix for ServiceMix Kernel
  • Equinox for Spring Dynamic Module

SerciceMix Kernel

If this is not yet done, download ServiceMix Kernel 1.0.0 server and install it. Launch the server by executing the command in the folder 'bin' :

Code Block

c:\apache-servicemix-kernel-1.0.0\bin>servicemix

If this is the first time that servicemix is started, then you will see that a new folder is created 'data'.

In order to allow our bundles to work with Camel, execute the following commands to download and install the 'Camel and Spring bundles' :

____ _ __ __ _
/ __| ___ _ ____ _() ___ __| \/ ()_ __
___ \ / _ \ '__\ \ / / |/ __/ _ \ |\/| | \ \/ /
__) | __/ | \ V /| | (| __/ | | | |> <

___/ __

_

_/

_

____

_

 

_

//_\

ServiceMix (1.0.0)

Type 'help' for more information.
-----------------------------------------------------------------------------------------------------------------------
servicemix> osgi install -s mvn:org.springframework/spring-tx/2.5.5
servicemix> osgi install -s mvn:org.apache.camel/camel-core/1.5.0
servicemix> osgi install -s mvn:org.apache.camel/camel-spring/1.5.0
servicemix> osgi install -s mvn:org.apache.camel/camel-osgi/1.5.0

#Resources

  • Attachments
    patterns.*part-one.zip