org.ow2.petals.component.framework.listener
Class AbstractJBIListener

java.lang.Object
  extended by org.ow2.petals.component.framework.listener.AbstractListener
      extended by org.ow2.petals.component.framework.listener.AbstractJBIListener

public abstract class AbstractJBIListener
extends AbstractListener

This class is used when a JBI message is received on the Component from the JBI environment.
Service Engine case :
The goal of this class is to process a service with the JBI message information.
For instance, a ServiceUnit has been deployed on the component, defining a provides section.
This section defines an Endpoint "myService/jbiMyServiceEndpoint" and some property extensions.
A "myService/jbiMyServiceEndpoint" has been activated on the JBI environment.

When a JBI consumer sends in the JBI environment a message to the "myService/jbiMyServiceEndpoint" endpoint, this component received the message, and calls the onJBIMessage(exchange) method.
Then, the method has to process the message according to optional property extensions (extensions of the provides that has activated the endpoint). Binding Component case :
The goal of this class is to call an external service, related to this JBI message. The address associated with the requested endpoint is handled by the Extensions object of the provides that has activated the endpoint.
For instance, a ServiceUnit has been deployed on the component, defining a provides section.
This section defines a relation between the external address "http://www.enterprise.com/webservices/myService" (an address attribute of the provides extensions), and an Endpoint "myService/jbiMyServiceEndpoint".
A "myService/jbiMyServiceEndpoint" has been activated on the JBI environment.

When a JBI consumer sends in the JBI environment a message to the "myService/jbiMyServiceEndpoint" endpoint, this component received the message, and calls the onJBIMessage(exchange) method.
Then, the method has to send the message to "http://www.enterprise.com/webservices/myService".

Author:
ofabre - EBM Websourcing

Field Summary
 
Fields inherited from class org.ow2.petals.component.framework.listener.AbstractListener
component, factory, messageInterceptorProcessor
 
Constructor Summary
AbstractJBIListener()
           
 
Method Summary
 boolean onAsyncJBIMessage(org.ow2.petals.component.framework.api.message.Exchange asyncExchange, AsyncContext asyncContext)
          This method is invoked by the CDK when an asynchronous response is received for the component.
 boolean onExpiredAsyncJBIMessage(org.ow2.petals.component.framework.api.message.Exchange originalExchange, AsyncContext asyncContext)
          This method is invoked by the CDK when an asynchronous context has expires.
abstract  boolean onJBIMessage(org.ow2.petals.component.framework.api.message.Exchange exchange)
           This method is used to process a JBI message received on the Component from the JBI environment.
 
Methods inherited from class org.ow2.petals.component.framework.listener.AbstractListener
createConsumeExchange, createConsumeExchange, createExchange, getComponent, getComponentContext, getConsumes, getCurrentTransaction, getExtensions, getInstallRoot, getLogger, getMessageInterceptorProcessor, getProvides, init, init, retrievePattern, send, sendAsync, sendSync, sendSync, setConsumes, setCurrentTransaction, setExtensions, setProvides
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractJBIListener

public AbstractJBIListener()
Method Detail

onAsyncJBIMessage

public boolean onAsyncJBIMessage(org.ow2.petals.component.framework.api.message.Exchange asyncExchange,
                                 AsyncContext asyncContext)
This method is invoked by the CDK when an asynchronous response is received for the component. Its bound AsyncContext is set as parameter.

This method MUST be overridden if asynchronous invocation are processed by the component.

Parameters:
exchange -
asyncContext -

onExpiredAsyncJBIMessage

public boolean onExpiredAsyncJBIMessage(org.ow2.petals.component.framework.api.message.Exchange originalExchange,
                                        AsyncContext asyncContext)
This method is invoked by the CDK when an asynchronous context has expires. Its bound AsyncContext is set as parameter.

This method MUST be overridden if asynchronous invocation are processed by the component.

Parameters:
exchange -
asyncContext -

onJBIMessage

public abstract boolean onJBIMessage(org.ow2.petals.component.framework.api.message.Exchange exchange)

This method is used to process a JBI message received on the Component from the JBI environment.

This method can't throws Exceptions. You must managed Exception yourself by using Exchange methods :
- setFault(Exception) : create a Fault with the given Exception and set it in the MessageExchange
- setError(Exception) : set Error part of the MessageExchange and set MessageExchange status to error. Exceptions handled by MessageExchanges must be in the container classpath.

If the methods return true, according to the pattern use cases, message can be terminated and sent back by the CDK :
- InOnly : DONE status is automatically set at the end of the message exchange process.
- RobustInOnly : DONE status is automatically set if no Fault found in exchange at the end of the message exchange process.
- InOut : DONE status is never set (forbidden).
- InOptOut : DONE status is automatically set if no Fault or Out message found in exchange at the end of the message exchange process.

Parameters:
exchange - the message exchange to process, wrapped to add some utility methods. Not null
Returns:
true if the message must be terminated and sent back automatically by the CDK. The interceptors are activated.
false if you you want yourself terminate the process and not use the MessageExchangeProcessor
Throws:
java.lang.RuntimeException - RuntimeException will be handle by the MessageExchange as Error part. So handled RuntimeExceptions must be in the classpath of your Petals node(s)


Copyright © 2005-2011 Petals Link (EBM Websourcing). All Rights Reserved.