SCA, Newton and Spring DM

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);
}
}

 

Article Type: 
How-to
0
Average: 4.3 (3 votes)

(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.