Creating a new DSB Distribution

Adding Core Services

If you want to add your own services, the best way to follow is to create your own 'kernel' which is extending the DSB kernel. Since we are using the Fractal component model in Petals ESB/DSB, you must also use it for your service.

To illustrate this chapter, let's add a simple and powerful service : The HelloWorld Service!

The source code for this illustration is available under the DSB samples folder in SVN at https://svn.petalslink.com/svnroot/trunk/research/commons/dsb/samples

We assume that you are Maven-aware so we do not explain all the commands here... 

Create a new kernel

Create a new project :

and choose groupId:org.petalslink.dsb.sample.custom, artifactId:custom-kernel, version:1.0-SNAPSHOT

Use the dsb-kernel as dependency in your new project POM:

Create the interface

Let's create a new project for the API definition of your service:

and choose groupId:org.petalslink.dsb.sample.custom, artifactId:custom-api, version:1.0-SNAPSHOT

Let's create a simple interface for our Hello service, HelloService.java:

Implement your service

Let's go back to our kernel and add the API as dependency:

Now, let's implement the Hello service, create the HelloServiceImpl in the org.petalslink.dsb.sample.custom.kernel package :

Is it enough? No... Since we use a component framework, we need to add component related configuration and dependencies in our kernel project. Let's add the required Fractal annotations and methods in the service implementation, the updated implementation looks like :

Is it enough? Almost... Let's say to Maven he has to do some extra steps at compilation time:

And add the spoon.cfg.xml at the root level of the custom-kernel project with this content :

Create your custom distribution project

We do not have any other way to create a distribution other that cloning some existing distribution and to customize its configuration files. To be faster, clone the default distribution files from the dsb-distribution project located at http://svn.petalslink.org/svnroot/trunk/research/commons/dsb/distributions/dsb-distribution/ into a new custom-distrib folder.
Next we need to add our previous modules to the distribution dependencies :

Add your service to the distribution

Now that we have our service API, implementation and distribution, let's add this service to the software component model. To be simple, let's add it in the top level component described in custom-distrib/src/main/resources/Petals.fractal :

This will instantiate our component when the DSB starts

Packaging your distribution

Just compile the all

And go to the dsb-distrib/target folder. You should find your new custom distribution in the custom-distrib-1.0-SNAPSHOT folder.

Launching

Go to dsb-distrib/target/custom-distrib-1.0-SNAPSHOT/custom-distrib-1.0-SNAPSHOT/bin and launch startup.sh

Next steps...

Ok... But how to access to the HelloService? You should have a look to the Expose Core Service as Web services section. Please note that this service has no added value. In order to to some more useful things, you should consider using some other services provided by DSB kernel components and bind them to your component, but this is another story which is out of scope...

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.