Enterprise Integration Zone is brought to you in partnership with:

Ouertani Slim was born in Tunisia in 1981. Now he is a software engineer since 2004 and he is Java 6 and Spring certified with 100% and 94% respectively. He is very interested in Java technology, Scala and open source projects. He believes that programming is one of the hardest jobs and most beautiful in the world. Slim has posted 32 posts at DZone. You can read more from them at their website. View Full User Profile

SCA, Newton and Spring DM

02.04.2009
| 21910 views |
  • submit to reddit

Last week I attended Newton training presented by David Savage and Mike Francis from Paremus. Newton is an open source project aimed to implement the SCA specification using the power of OSGi inside a single JVM and JINI outside it.

 

Goal

Create 2 composite applications:

  • Composite 1: Publish a service outside the current JVM using SCA with Spring DM and Newton
  • Composite 2: Consume service.

Tools

 For this purpose I used:

Project creation

  1. Create a new group project on Netbeans named sca.
  2. New maven projects :
    1. parent pom project that will contain 3 sub-projects :
    2. api : service interface.
    3. impl : service implementation.
    4. client : consuming the service.
  3. Add api dependency to impl and client.
  4. Add resources directories to impl and client projects with empty Spring DM and Newton XML files. 
  5. Project directory will be :

.
|-- api
|   |-- pom.xml
|   `-- src
|       `-- main
|           `-- java
|               `-- com
|                   `-- jtunisie
|                       `-- osgi
|                           `-- sca
|                               `-- IService.java
|-- client
|   |-- pom.xml
|   `-- src
|       `-- main
|           |-- java
|           |   `-- com
|           |       `-- jtunisie
|           |           `-- osgi
|           |               `-- sca
|           |                   `-- client
|           |                       `-- Activator.java
|           `-- resources
|               `-- META-INF
|                   |-- newton
|                   |   `-- client.composite
|                   `-- spring
|                       |-- bundle-context-osgi.xml
|                       `-- bundle-context.xml
|-- impl
|   |-- pom.xml
|   `-- src
|       `-- main
|           |-- java
|           |   `-- com
|           |       `-- jtunisie
|           |           `-- osgi
|           |               `-- sca
|           |                   `-- impl
|           |                       `-- Service.java
|           `-- resources
|               `-- META-INF
|                   |-- newton
|                   |   `-- service.composite
|                   `-- spring
|                       |-- bundle-context-osgi.xml
|                       `-- bundle-context.xml
`-- pom.xml

The IService contains one method signature :

public interface IService extends Serializable  {

String getMessage(String name);
}

The Service implementation is :

public class Service implements IService  {

@Override
public String getMessage(String name) {
return "Hello " + name;
}
}

The client Activator (not an OSGi Activator ):

public class Activator {

IService service;

public void setService(IService service) {
this.service = service;
}

public void init() {
String message = service.getMessage("world!!!!");
System.out.println(message);
}
}

 

Published at DZone with permission of its author, Slim Ouertani.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)

Comments

Wassim ABID replied on Wed, 2009/02/04 - 11:48am

Good work :-)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.