JBoss.orgCommunity Documentation

Chapter 2. Resource Adaptor Type

2.1. Activities
2.2. Events
2.3. Activity Context Interface Factory
2.4. Resource Adaptor Interface
2.5. Restrictions
2.6. Sbb Code Examples
2.6.1. Synchronous Operations
2.6.2. Asynchronous Operations

The Resource Adaptor Type is the interface which defines the contract between the RA implementations, the SLEE container, and the Applications running in it.

The name of the RA Type is HttpClientResourceAdaptorType, its vendor is org.mobicents and its version is 1.0.

The single activity object for HTTP Client Resource Adaptor is the net.java.client.slee.resource.http.HttpClientActivity interface. Through the activity an SBB can send multiple HTTP requests, and receive the related responses asynchronously. Due to the nature of SLEE activities, this RA activity acts like a queue of requests, allowing the processing of their responses - the events- in a serialized way

An activity starts on demand by an SBB, through the RA SBB Interface, and it ends when the response is received, or when the SBB invokes its endActivity() method.

The HttpClientActivity interface is defined as follows:



        
package net.java.client.slee.resource.http;
import org.apache.commons.httpclient.HttpMethod;
public interface HttpClientActivity {
    public String getSessionId();
    public void endActivity();
    public boolean getEndOnReceivingResponse();
    public void executeMethod(HttpMethod httpMethod);
}
     

There is a single event fired by HTTP Client Resource Adaptor, which represents a response to a request, received in a specific HttpClientActivity instance.


Important

Spaces where introduced in Name, Vendor and Event Class column values, to correctly render the table. Please remove them when using copy/paste.

The response event class provides the result of sending an HTTP request, which can be response or exception, due to error.

The Resource Adaptor's Activity Context Interface Factory is of type net.java.client.slee.resource.http.HttpClientActivityContextInterfaceFactory, it allows the SBB to retrieve the ActivityContextInterface related with an existing Resource Adaptor activity object. The interface is defined as follows:



        
package net.java.client.slee.resource.http;
import javax.slee.ActivityContextInterface;
import javax.slee.FactoryException;
import javax.slee.UnrecognizedActivityException;
public interface HttpClientActivityContextInterfaceFactory {
    
    public ActivityContextInterface getActivityContextInterface(
            HttpClientActivity acivity) throws NullPointerException,
            UnrecognizedActivityException, FactoryException;    
}
     

The HTTP Client Resource Adaptor interface, of type net.java.client.slee.resource.http.HttpClientResourceAdaptorSbbInterface, which an SBB uses to create new HttpClientActivity instances or send synchronous requests, its interface is defined as follows:



        
package net.java.client.slee.resource.http;
import java.io.IOException;
import javax.slee.resource.StartActivityException;
import net.java.client.slee.resource.http.event.Response;
import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.HttpMethod;
import org.apache.commons.httpclient.HttpState;
import org.apache.commons.httpclient.params.HttpClientParams;
public interface HttpClientResourceAdaptorSbbInterface {
    public HttpClientActivity createHttpClientActivity() throws StartActivityException;
    public HttpClientActivity createHttpClientActivity(
            boolean endOnReceivingResponse) throws StartActivityException;
            
    public HttpMethod createHttpMethod(HttpMethodName methodName, String uri);
    public Response executeMethod(HttpMethod method) throws HttpException, IOException;
    public HttpClientParams getParams();
    public HttpState getState();
    public void setParams(HttpClientParams params);
    public void setState(HttpState state);
}
    

The HTTP Client Resource Adaptor Type does not defines any restriction on the usage of its interfaces.

The following code examples shows how to use the Resource Adaptor Type for common functionalities