Sun POJO Service Engine User's Guide

Providing a JBI Service

With just two annotations, @Provider and @Operation, you can enable a Java class as JBI service. Below is an example of a simple POJO service provider.


package org.glassfish.openesb.pojo.sample;
import org.glassfish.openesb.pojose.api.annotation.Operation; 
import org.glassfish.openesb.pojose.api.annotation.Provider; 
@Provider 
public class Echo {
     @Operation (outMessageType="EchoOperationResponse", 
                 outMessageTypeNS="http://sample.pojo.openesb.glassfish.org/Echo/")
     public String receive(String input) {
            return input;
     } 
}

The properties for @Operation annotation are not mandatory, but may be needed if the JBI component interacting with the POJO SE expects the JBI message type QName on the JBI wrapper message element. Defaults are assumed for most of the information needed by JBI runtime. Some of the defaults are endpoint names and interface and service QNames. If not specified through @POJO annotation, the endpoint name defaults to the unqualified class name. The service and interface QName namespaces default to the HTTP URI made up of the package name in reverse with the endpoint name appended. For the above example, this would be http://tst.pojo.glassfishesb.org/Echo/. The local service name defaults to the endpoint name with “Service" appended. The local interface name defaults to the endpoint name with "Interface" appended. For the above example it will be "EchoService" and "EchoInterface" respectively.

Operation Parameter Types

The POJO SE supports the following input parameter types and return types for methods annotated with @Operation:

When the return type is void, the JBI message exchange pattern is assumed to be InOnly. The POJO SE supports InOnly and InOut JBI message exchange patterns. For parameter and return types of String, Node, and Source, the POJO SE automates JBI WSDL 1.1 message unwrapping and wrapping.

Context

The POJO SE injects an instance of the class org.glassfish.openesb.pojose.api.res.Context when a field is annotated with @Resource (org.glassfish.openesb.pojose.api.annotation.Resource). The Context class includes the methods needed to retrieve an instance of the current MessageExchange object and a method to create a new MessageExchange objects for invoking JBI services.