org.mule.providers
Class AbstractMessageReceiver

java.lang.Object
  extended byorg.mule.providers.AbstractMessageReceiver
All Implemented Interfaces:
Disposable, Lifecycle, Startable, Stoppable, UMOConnectable, UMOMessageReceiver
Direct Known Subclasses:
AbstractPollingMessageReceiver, AxisMessageReceiver, JbiMessageReceiver, JettyHttpMessageReceiver, JmsMessageReceiver, ProcessMessageReceiver, QuartzMessageReceiver, RmiCallbackMessageReceiver, ServletMessageReceiver, TcpMessageReceiver, TransactedSingleResourceJmsMessageReceiver, UdpMessageReceiver, XFireMessageReceiver, XmppMessageReceiver

public abstract class AbstractMessageReceiver
extends Object
implements UMOMessageReceiver

AbstractMessageReceiver provides common methods for all Message Receivers provided with Mule. A message receiver enables an endpoint to receive a message from an external system.


Field Summary
protected  UMOComponent component
          The Component with which this receiver is associated with
protected  WaitableBoolean connected
           
protected  AtomicBoolean connecting
           
protected  ConnectionStrategy connectionStrategy
           
protected  AbstractConnector connector
          the connector associated with this receiver
protected  AtomicBoolean disposing
           
protected  UMOEndpoint endpoint
          The endpoint descriptor which is associated with this receiver
protected  Log logger
          logger used by this class
protected  String receiverKey
          Stores the key to this receiver, as used by the Connector to store the receiver.
protected  WaitableBoolean stopped
           
 
Constructor Summary
AbstractMessageReceiver(UMOConnector connector, UMOComponent component, UMOEndpoint endpoint)
          Creates the Message Receiver
 
Method Summary
protected  UMOMessage applyResponseTransformer(UMOMessage returnMessage)
           
 void connect()
          Make the connection to the underlying transport.
 void disconnect()
          Disconnect the from the underlying transport
 void dispose()
          A lifecycle method where implementor should free up any resources.
protected abstract  void doConnect()
           
protected abstract  void doDisconnect()
           
protected abstract  void doDispose()
           
protected abstract  void doStart()
           
protected abstract  void doStop()
           
 UMOComponent getComponent()
           
protected  String getConnectEventId()
           
 String getConnectionDescription()
          Returns a string identifying the underlying resource
 UMOConnector getConnector()
           
 UMOEndpoint getEndpoint()
           
 UMOEndpointURI getEndpointURI()
          The endpointUri that this receiver listens on
 InternalMessageListener getListener()
           
 String getReceiverKey()
           
protected  UMOWorkManager getWorkManager()
           
 void handleException(Exception exception)
           
protected  UMOMessage handleUnacceptedFilter(UMOMessage message)
           
 boolean isConnected()
          Determines if this object is connected or not
 UMOMessage routeMessage(UMOMessage message)
           
 UMOMessage routeMessage(UMOMessage message, boolean synchronous)
           
 UMOMessage routeMessage(UMOMessage message, boolean synchronous, OutputStream outputStream)
           
 UMOMessage routeMessage(UMOMessage message, OutputStream outputStream)
           
 UMOMessage routeMessage(UMOMessage message, UMOTransaction trans, boolean synchronous)
           
 UMOMessage routeMessage(UMOMessage message, UMOTransaction trans, boolean synchronous, OutputStream outputStream)
           
 void setComponent(UMOComponent component)
           
 void setConnector(UMOConnector connector)
           
 void setEndpoint(UMOEndpoint endpoint)
           
protected  void setExceptionDetails(UMOMessage message, Throwable exception)
          This method is used to set any additional aand possibly transport specific information on the return message where it has an exception payload.
 void setListener(InternalMessageListener listener)
           
 void setReceiverKey(String receiverKey)
           
protected  void setWorkManager(UMOWorkManager workManager)
           
 void start()
           
 void stop()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

logger

protected final Log logger
logger used by this class


component

protected UMOComponent component
The Component with which this receiver is associated with


endpoint

protected UMOEndpoint endpoint
The endpoint descriptor which is associated with this receiver


connector

protected AbstractConnector connector
the connector associated with this receiver


disposing

protected final AtomicBoolean disposing

connected

protected final WaitableBoolean connected

stopped

protected final WaitableBoolean stopped

connecting

protected final AtomicBoolean connecting

receiverKey

protected String receiverKey
Stores the key to this receiver, as used by the Connector to store the receiver.


connectionStrategy

protected ConnectionStrategy connectionStrategy
Constructor Detail

AbstractMessageReceiver

public AbstractMessageReceiver(UMOConnector connector,
                               UMOComponent component,
                               UMOEndpoint endpoint)
                        throws InitialisationException
Creates the Message Receiver

Parameters:
connector - the endpoint that created this listener
component - the component to associate with the receiver. When data is received the component dispatchEvent or sendEvent is used to dispatch the data to the relivant UMO.
endpoint - the provider contains the endpointUri on which the receiver will listen on. The endpointUri can be anything and is specific to the receiver implementation i.e. an email address, a directory, a jms destination or port address.
See Also:
UMOComponent, UMOEndpoint
Method Detail

getEndpoint

public UMOEndpoint getEndpoint()
Specified by:
getEndpoint in interface UMOMessageReceiver
Returns:
the receivers endpoint

handleException

public void handleException(Exception exception)

setExceptionDetails

protected void setExceptionDetails(UMOMessage message,
                                   Throwable exception)
This method is used to set any additional aand possibly transport specific information on the return message where it has an exception payload.

Parameters:
message -
exception -

getConnector

public UMOConnector getConnector()
Specified by:
getConnector in interface UMOMessageReceiver

setConnector

public void setConnector(UMOConnector connector)
Specified by:
setConnector in interface UMOMessageReceiver

getComponent

public UMOComponent getComponent()
Specified by:
getComponent in interface UMOMessageReceiver
Returns:
the component associated with the receiver

routeMessage

public final UMOMessage routeMessage(UMOMessage message)
                              throws UMOException
Specified by:
routeMessage in interface UMOMessageReceiver
Throws:
UMOException

routeMessage

public final UMOMessage routeMessage(UMOMessage message,
                                     boolean synchronous)
                              throws UMOException
Specified by:
routeMessage in interface UMOMessageReceiver
Throws:
UMOException

routeMessage

public final UMOMessage routeMessage(UMOMessage message,
                                     UMOTransaction trans,
                                     boolean synchronous)
                              throws UMOException
Specified by:
routeMessage in interface UMOMessageReceiver
Throws:
UMOException

routeMessage

public final UMOMessage routeMessage(UMOMessage message,
                                     OutputStream outputStream)
                              throws UMOException
Specified by:
routeMessage in interface UMOMessageReceiver
Throws:
UMOException

routeMessage

public final UMOMessage routeMessage(UMOMessage message,
                                     boolean synchronous,
                                     OutputStream outputStream)
                              throws UMOException
Specified by:
routeMessage in interface UMOMessageReceiver
Throws:
UMOException

routeMessage

public final UMOMessage routeMessage(UMOMessage message,
                                     UMOTransaction trans,
                                     boolean synchronous,
                                     OutputStream outputStream)
                              throws UMOException
Specified by:
routeMessage in interface UMOMessageReceiver
Throws:
UMOException

handleUnacceptedFilter

protected UMOMessage handleUnacceptedFilter(UMOMessage message)

setEndpoint

public void setEndpoint(UMOEndpoint endpoint)
Specified by:
setEndpoint in interface UMOMessageReceiver
Parameters:
endpoint - the endpoint to listen on
See Also:
UMOEndpoint

setComponent

public void setComponent(UMOComponent component)
Specified by:
setComponent in interface UMOMessageReceiver
Parameters:
component - the component to associate with the receiver. When data is received the component dispatchEvent or sendEvent is used to dispatch the data to the relivant UMO.

dispose

public final void dispose()
Description copied from interface: Disposable
A lifecycle method where implementor should free up any resources. If an exception is thrown it should just be logged and processing should continue. This method should not throw Runtime exceptions.

Specified by:
dispose in interface Disposable

getEndpointURI

public UMOEndpointURI getEndpointURI()
Description copied from interface: UMOMessageReceiver
The endpointUri that this receiver listens on

Specified by:
getEndpointURI in interface UMOMessageReceiver
Returns:

getWorkManager

protected UMOWorkManager getWorkManager()

setWorkManager

protected void setWorkManager(UMOWorkManager workManager)

connect

public void connect()
             throws Exception
Description copied from interface: UMOConnectable
Make the connection to the underlying transport. The fact that this object is connected or not should have no influence on the lifecycle, especially the start / stop state if applicable.

Specified by:
connect in interface UMOConnectable
Throws:
Exception

disconnect

public void disconnect()
                throws Exception
Description copied from interface: UMOConnectable
Disconnect the from the underlying transport

Specified by:
disconnect in interface UMOConnectable
Throws:
Exception

getConnectionDescription

public String getConnectionDescription()
Description copied from interface: UMOConnectable
Returns a string identifying the underlying resource

Specified by:
getConnectionDescription in interface UMOConnectable
Returns:

start

public final void start()
                 throws UMOException
Specified by:
start in interface Startable
Throws:
UMOException

stop

public final void stop()
Specified by:
stop in interface Stoppable

isConnected

public final boolean isConnected()
Description copied from interface: UMOConnectable
Determines if this object is connected or not

Specified by:
isConnected in interface UMOConnectable
Returns:

getListener

public InternalMessageListener getListener()

setListener

public void setListener(InternalMessageListener listener)

getConnectEventId

protected String getConnectEventId()

applyResponseTransformer

protected UMOMessage applyResponseTransformer(UMOMessage returnMessage)
                                       throws TransformerException
Throws:
TransformerException

setReceiverKey

public void setReceiverKey(String receiverKey)
Specified by:
setReceiverKey in interface UMOMessageReceiver

getReceiverKey

public String getReceiverKey()
Specified by:
getReceiverKey in interface UMOMessageReceiver

toString

public String toString()

doStart

protected abstract void doStart()
                         throws UMOException
Throws:
UMOException

doStop

protected abstract void doStop()
                        throws UMOException
Throws:
UMOException

doConnect

protected abstract void doConnect()
                           throws Exception
Throws:
Exception

doDisconnect

protected abstract void doDisconnect()
                              throws Exception
Throws:
Exception

doDispose

protected abstract void doDispose()


Copyright © 2003-2008 MuleSource, Inc.. All Rights Reserved.