...
- Maven 2.0.9 to setup the Camel project and for dependencies for artifacts,
- Eclipse Ganymede 3.4.x,
- Spring Dynamic Modules for OSGI 1.2.0-m2
- Service Mix Kernel 1.01.0,
- Spring DM Server 1.0.1
- Pax maven construct
Note: The sample project can be downloaded, see the resources section.
...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
<?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"> <!-- definitions using elements of the osgi namespace can be included in this file. There is no requirement to keep these definitions in a separate file if you do not want to. The rationale for keeping these definitions separate is to facilitate integration testing of the bundle outside of an OSGi container --> <osgi:service ref="transformService"> <osgi:interfaces> <value>demo.service.TransformService</value> </osgi:interfaces> </osgi:service> </beans> |
The xml tag osgi:service will help to register our OSGI service top of the OSGI server and will publish the interfaces as available for another bundles who would like to use them
Remark: for more information about Spring Dynamic Modules and configuration, I recommend to read its documentation
Tip | ||
---|---|---|
| ||
Two XML files have been created to work with Spring beans and Spring OSGI beans separately (as proposed by spring - section D.1 Generated Project Features at-a-glance) but you can also merge the content in one file. |
...
This command can be launched from Eclipse (if you have integrated maven within Eclipse (eclipse maven plugin)) or a Unix/Dos prompt in the folder where your pom.xml file is located:
Code Block |
---|
mvn packageorg.ops4j:maven-pax-plugin:compile |
If this command does not report any error, then a 'MANIFEST.MF' file containing the following information is created in the folder 'META-INF' and
a demo.service-bundle-0.1.0.jar
jar is created in the target
folder:
...