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:- Maven 2 build tool.
- Netbeans 6.5 IDE.
- Spring DM 1.2.0 M2
- Newton 1.3.2
- Maven Felix plugin to generate bundles.
Project creation
- Create a new group project on Netbeans named sca.
- New maven projects :
- parent pom project that will contain 3 sub-projects :
- api : service interface.
- impl : service implementation.
- client : consuming the service.
- Add api dependency to impl and client.
- Add resources directories to impl and client projects with empty Spring DM and Newton XML files.
- 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);
}
}
(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