Index Changes

Difference between version and version     

Back to Fuji Service API, or Fuji Service API Info


At line 1 added 1 line.
[{Image src='fuji-logo8.gif' link='https://fuji.dev.java.net/' alt='Fuji Home' align='left'}]
At line 3 added 10 lines.
\\
__
[1. Overview | http://wiki.open-esb.java.net/Wiki.jsp?page=FujiServiceAPI#section-FujiServiceAPI-Overview] \\ \\
[2. Consuming Services | FujiServiceAPI.ConsumingServices] \\ \\
[3. Providing Services | FujiServiceAPI.ProvidingServices] \\ \\
[4. Message Processing | FujiServiceAPI.MessageProcessing] \\ \\
[5. API Details | FujiServiceAPI.APIDetails] \\ \\
[6. Deployment Choices | FujiServiceAPI.DeploymentChoices] \\ \\
[7. Examples | FujiServiceAPI.Examples] \\ \\
__
At line 3 changed 1 line.
[{TableOfContents}]
\\ \\
At line 16 added 1 line.
At line 15 removed 1 line.
!! Consuming Services
At line 17 removed 107 lines.
Consuming a service using the Service API consists of the following:
* Obtaining a ServiceConsumer reference by querying the OSGi service registry directly or using annotation-based injection
* Creating a message and populating it with content (properties, payload, etc.)
* Invoking the service with the message and digesting the response (if applicable)
[{Image src='service-api-consumer.jpg' width='50%' align='left'}]
!
A ServiceConsumer instance is identified via two properties: service name and endpoint name. These can be specified as annotation properties or as properties associated with a query in the OSGi service registry. The Fuji runtime automatically registers a ServiceConsumer instance in the registry for each service endpoint activated on the NMR.
\\ \\
Invoking a service via the ServiceConsumer interface takes two forms:
* ''send'' : represents a one-way invocation of a service; results in an InOnly message exchange over the NMR.
* ''call'' : represents a request-response invocation of a service; results in an InOut message exchange over the NMR.
Both calls are synchronous. The ''send'' method waits for a DONE/ERROR before returning. The ''call'' method waits for a response message/fault before returning.
\\ \\
''NOTE: We can consider an asynchronous mechanism which would require a callback handler in the client''
\\ \\
!! Providing Services
Providing a service using the Service API can take one of two forms:
!''Java Interface''
* Implement the ServiceProvider interface
* Register an instance of the ServiceProvider implementation in the OSGi service registry
* Process messages received via the invoke() method and optionally return a response
!''Annotation''
* Annotate with a service provider annotation
* Each public method in the class becomes an invokable service operation
* Process messages received via public methods and optionally return a response
[{Image src='service-api-provider.jpg' width='50%' align='left'}]
!
The following properties are required for instances of a service provider:
* Service name : defaults to class name, can be specified using:
** annotation property
** implementation of getServiceName()
* Endpoint name : defaults to hashCode of object instance, can be specified using:
** annotation property
** implementation of getEndpointName()
* Operation names : defaults to method name, can be specified using:
** annotation
** implementation of getOperationNames()
All invocations are synchronous, whether the provider implements ServiceProvider or uses annotations.
!
\\ \\
!! Message Processing
\\ \\
!! API Details
! Annotations
__@Consumer__ \\
Used for field-level injection of ServiceConsumer references.
* service : service name
* endpoint : endpoint name
\\
__@Provider__ \\
Specified at the class level to extract a ServiceProvider instance from a class.
* name ''(optional)'' : service name
* endpoint ''(optional)'' : endpoint name
\\
__@Operation__ \\
Specified at the method level. Allows a class to change metadata associated with a service operation.
* name : operation name - serves as an override in place of the method name
\\
__@MessageFactory__ \\
Used for field-level injection of ServiceMessageFactory references. Can only be used in classes with @Consumer or @Provider annotations.
\\ \\
! Java Interfaces
{{{
public interface ServiceProvider {
ServiceMessage invoke(ServiceMessage message) throws Exception;
void setMessageFactory(ServiceMessageFactory factory);
}
}}}
\\
{{{
public interface ServiceConsumer {
public ServiceMessage call(String operation, ServiceMessage request) throws Exception;
public void send(String operation, ServiceMessage request) throws Exception;
public ServiceMessageFactory getServiceMessageFactory();
}
}}}
\\
{{{
public interface ServiceMessage<T> extends NormalizedMessage {
public void setPayload(T payload) throws Exception;
public T getPayload() throws Exception;
}
}}}
\\
{{{
public interface ServiceMessageFactory {
<T> ServiceMessage<T> createMessage(T payload);
}
}}}
\\ \\
!! Deployment Choices

JSPWiki v2.4.100
[RSS]
« Home Index Changes Prefs
This page (revision-30) was last changed on 17-Feb-09 17:08 PM, -0800 by MarkWhite