@Documented
@Inherited
@Target(value=TYPE)
@Retention(value=CLASS)
public @interface SonicConnect
client attribute(default false) indicates whether a REST client of server will be created.
REST clients hosted in Sonic are used to consume external REST services. An other option to JAXR-RS 2.0 annotations, is to generated REST clients for Sonic hosting from WADL contracts. REST clients only annotate an interface, the annotation processor generates all the artifacts needed for itinerary use. REST clients present a friendly interface to itinerary developers, annotated methods and parameters appear as as operations and parameters in itinerary mapping.
REST services have implementation logic of course. Hosted in Sonic have at their disposal all the standard capabilities provided by CXF(consumption from the outside via REST, data binding, 3rd jars, etc etc). In addition, REST services may be injected with Sonic service lifecycle and context access for hybrid capabilities including itinerary integration and exposure etc.
Finally, REST services and client can be used together on the Sonic bus distributed across ESB containers(or, setups that map to separate JVMs, separate docker containers, separate physical hosts, Sonic routing nodes etc).
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import com.aurea.sonic.esb.connect.annotation.SonicConnect;
@SonicConnect(baseUrl = "http://0.0.0.0:8080/Hello")
@Path("hello")
@Produces(MediaType.APPLICATION_XML)
public class HelloService {
@GET
public Response sayHello() {
final StringBuilder xml = new StringBuilder("<response>");
final String hello = "<message>Hello everyone!</message>";
xml.append(hello);
xml.append("</response>");
return Response.ok(xml.toString()).build();
}
@GET
@Path("{name}")
public Response saySpecialHello(@PathParam("name") final String name) {
final StringBuilder xml = new StringBuilder("<response>");
final String hello = "<message>Special hello to " + name + "!</message>";
xml.append(hello);
xml.append("</response>");
return Response.ok(xml.toString()).build();
}
}
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.core.Response;
import com.aurea.sonic.esb.connect.annotation.SonicConnect;
@SonicConnect(baseUrl = "http://0.0.0.0:8080/Hello", client = true)
@Path("hello")
public interface HelloClient {
@GET
Response sayHello();
@GET
@Path("{name}")
Response saySpecialHello(@PathParam("name") String name);
}
| Modifier and Type | Required Element and Description |
|---|---|
java.lang.String |
baseUrl
baseUrl is required
Should have 'http(s)' scheme, server address, port and path (e.g: http://0.0.0.0:8080/rest) |
| Modifier and Type | Optional Element and Description |
|---|---|
boolean |
client
set to true for clients.
|
java.lang.String |
name
display name (default: simple class name)
|
java.lang.String |
springConfigFilePath
Path to Spring template configuration used to generate spring.xml
|
java.lang.String |
tags
comma delimited tags (e.g: REST,JAXRS).
|
public abstract java.lang.String baseUrl
public abstract java.lang.String name
public abstract java.lang.String tags