Extending the DSB

compared with
Key
This line was removed.
This word was removed. This word was added.
This line was added.

Changes (6)

View Page History
# There is no 3

To illustrate this feature, we provide a sample to expose a simple Hello TestService service as Web service.

h2. Create your interface
{code:language=java|title=TestService interface}package org.petalslink.dsb.ws.api;

import javax.jws.WebMethod;
import javax.jws.WebService;

@WebService
public interface TestService {

@WebMethod
void test();

}{code}
In this sample, we start from a JAXWS annotated Java interface. This is the only thing to check in this step.

h2. Create your service

Creating your service means implement the interface we just defined in the previous step. Now we have to create a Fractal component which implement the JAXWS annotated TestService interface.
{code:language=java|title=Fractal Component}package org.petalslink.dsb.kernel.ws;

import org.objectweb.fractal.fraclet.annotation.annotations.FractalComponent;
import org.objectweb.fractal.fraclet.annotation.annotations.Interface;
import org.objectweb.fractal.fraclet.annotation.annotations.LifeCycle;
import org.objectweb.fractal.fraclet.annotation.annotations.Monolog;
import org.objectweb.fractal.fraclet.annotation.annotations.Provides;
import org.objectweb.fractal.fraclet.annotation.annotations.type.LifeCycleType;
import org.objectweb.util.monolog.api.Logger;
import org.ow2.petals.util.LoggingUtil;
import org.petalslink.dsb.ws.api.TestService;

@FractalComponent
@Provides(interfaces = { @Interface(name = "service", signature = TestService.class) })
public class TestServiceImpl implements TestService {

@Monolog(name = "logger")
private Logger logger;

private LoggingUtil log;

@LifeCycle(on = LifeCycleType.START)
protected void start() {
this.log = new LoggingUtil(this.logger);
this.log.debug("Starting...");
}

@LifeCycle(on = LifeCycleType.STOP)
protected void stop() {
this.log.debug("Stopping...");
}

/**
* {@inheritDoc}
*/
public void test() {
System.out.println("This is a test!");
}

}{code}
* As a Fractal component, you MUST check that you put all the Fractal annotations (@FractalComponent, @Provides, @LifeCycle)
* This component MUST implements the TestService interface


h2. Add service to the architecture