-
Notifications
You must be signed in to change notification settings - Fork 1
Defining Endpoint Contracts
sahan edited this page Jan 14, 2013
·
21 revisions
######The intended use of an endpoint contract is to identify a set of remote services and provide information for successful communication.
You start off by defining and exact copy (mirror) of the endpoint, with all its public methods (services), on a single interface. This interface is then annotated to provide information (metadata) on how to reach the endpoint services and communicate with them using data structures & a common format which both ends understand.
Almost all usage of the ZombieLink API revolves around this set of annotations for populating endpoint metadata.
####1. Identifying Endpoints
- The
@Endpointannotation is used to mark interfaces which specify contracts for remote endpoints. - It takes a mandatory host parameter which specifies the target endpoint host-name for all service invocations.
@Endpoint("www.google.com")
public interface CurrencyConverterEndpoint {}- It can be optionally configured to use a different scheme and port, along with a root-path.
@Endpoint(scheme = "https", value = "www.google.com", port = "443", path = "/ig/calculator")
public interface CurrencyConverterEndpoint {}####2. Defining Services
- Each endpoint service can be identified using the
@Requestannotation.
@Request
public String timestamp();By default each service is executed as an HTTP GET request on the endpoint root-path with no request parameters.
- To populate request parameters, define them as arguments to the service method and annotate them with
@Param.
@Request
public String convert(@Param(name = "q") String conversionString);