Welcome to Part #2 of the SOA Light – Usage of services in your application.
In the 2nd part I want to introduce a sample project, which reflects the architecture described in part one. All the projects are prepared to be compiled with Maven 2.x .
The project itself consists of the following Maven modules:
- sampleApplication: This is the application that uses the services.
- service-base: This module contains the service interface and a class which describes a DTO (Data Transfer Object).
- service-client: This module contains a so called façade class. This façade implements the interface from the base module. This façade also contains a property of type SampleService.So this class, the façade, is actually the bridge between the sample application and the service itself. This façade will be injected into the sampleApplication.
- service-server: This module offers the service itself. The service has implemented the interface from service-base. This is the place where the actual work is done. This can be communication with database or whatever comes to your mind.
A simple way to use the application and the service is to deploy them to a Jetty server. The service and the application contain a jetty plug in which can be started via
“mvn jetty:run -Djetty.port=9002.
See the attachment for the example implementations: