org.mule.transport
Class AbstractMessageReceiver

java.lang.Object
  extended by org.mule.transport.AbstractMessageReceiver
All Implemented Interfaces:
Disposable, Initialisable, Lifecycle, Startable, Stoppable, Connectable, MessageReceiver
Direct Known Subclasses:
AbstractPollingMessageReceiver

public abstract class AbstractMessageReceiver
extends Object
implements MessageReceiver

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  WaitableBoolean connected
           
protected  edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicBoolean connecting
           
protected  ConnectionStrategy connectionStrategy
           
protected  AbstractConnector connector
          the connector associated with this receiver
protected  edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicBoolean disposing
           
protected  InboundEndpoint 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  boolean responseEndpoint
           
protected  Service service
          The Service with which this receiver is associated with
protected  WaitableBoolean stopped
           
 
Fields inherited from interface org.mule.api.lifecycle.Initialisable
PHASE_NAME
 
Fields inherited from interface org.mule.api.lifecycle.Startable
PHASE_NAME
 
Fields inherited from interface org.mule.api.lifecycle.Stoppable
PHASE_NAME
 
Fields inherited from interface org.mule.api.lifecycle.Disposable
PHASE_NAME
 
Constructor Summary
AbstractMessageReceiver(Connector connector, Service service, InboundEndpoint endpoint)
          Creates the Message Receiver
 
Method Summary
 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  void doInitialise()
           
protected abstract  void doStart()
           
protected abstract  void doStop()
           
protected  String getConnectEventId()
           
 String getConnectionDescription()
          Returns a string identifying the underlying resource
 Connector getConnector()
           
 InboundEndpoint getEndpoint()
           
 EndpointURI getEndpointURI()
          The endpointUri that this receiver listens on
 InternalMessageListener getListener()
           
 String getReceiverKey()
           
 Service getService()
           
protected  WorkManager getWorkManager()
           
 void handleException(Exception exception)
           
protected  MuleMessage handleUnacceptedFilter(MuleMessage message)
           
 void initialise()
          Method used to perform any initialisation work.
 boolean isConnected()
          Determines if this object is connected or not
 MuleMessage routeMessage(MuleMessage message)
           
 MuleMessage routeMessage(MuleMessage message, boolean synchronous)
           
 MuleMessage routeMessage(MuleMessage message, boolean synchronous, OutputStream outputStream)
           
 MuleMessage routeMessage(MuleMessage message, OutputStream outputStream)
           
 MuleMessage routeMessage(MuleMessage message, Transaction trans, boolean synchronous)
           
 MuleMessage routeMessage(MuleMessage message, Transaction trans, boolean synchronous, OutputStream outputStream)
           
 void setConnector(Connector connector)
           
 void setEndpoint(InboundEndpoint endpoint)
           
protected  void setExceptionDetails(MuleMessage 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)
           
 void setService(Service service)
           
protected  void setWorkManager(WorkManager 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


service

protected Service service
The Service with which this receiver is associated with


endpoint

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


connector

protected AbstractConnector connector
the connector associated with this receiver


disposing

protected final edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicBoolean disposing

connected

protected final WaitableBoolean connected

stopped

protected final WaitableBoolean stopped

connecting

protected final edu.emory.mathcs.backport.java.util.concurrent.atomic.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

responseEndpoint

protected boolean responseEndpoint
Constructor Detail

AbstractMessageReceiver

public AbstractMessageReceiver(Connector connector,
                               Service service,
                               InboundEndpoint endpoint)
                        throws CreateException
Creates the Message Receiver

Parameters:
connector - the endpoint that created this listener
service - the service to associate with the receiver. When data is received the service 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.
Throws:
CreateException
See Also:
Service, InboundEndpoint
Method Detail

initialise

public void initialise()
                throws InitialisationException
Method used to perform any initialisation work. If a fatal error occurs during initialisation an InitialisationException should be thrown, causing the Mule instance to shutdown. If the error is recoverable, say by retrying to connect, a RecoverableException should be thrown. There is no guarantee that by throwing a Recoverable exception that the Mule instance will not shut down.

Specified by:
initialise in interface Initialisable
Throws:
InitialisationException - if a fatal error occurs causing the Mule instance to shutdown
RecoverableException - if an error occurs that can be recovered from

getEndpoint

public InboundEndpoint getEndpoint()
Specified by:
getEndpoint in interface MessageReceiver
Returns:
the receivers endpoint

handleException

public void handleException(Exception exception)

setExceptionDetails

protected void setExceptionDetails(MuleMessage 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 Connector getConnector()
Specified by:
getConnector in interface MessageReceiver

setConnector

public void setConnector(Connector connector)
Specified by:
setConnector in interface MessageReceiver

getService

public Service getService()
Specified by:
getService in interface MessageReceiver
Returns:
the service associated with the receiver

routeMessage

public final MuleMessage routeMessage(MuleMessage message)
                               throws MuleException
Specified by:
routeMessage in interface MessageReceiver
Throws:
MuleException

routeMessage

public final MuleMessage routeMessage(MuleMessage message,
                                      boolean synchronous)
                               throws MuleException
Specified by:
routeMessage in interface MessageReceiver
Throws:
MuleException

routeMessage

public final MuleMessage routeMessage(MuleMessage message,
                                      Transaction trans,
                                      boolean synchronous)
                               throws MuleException
Specified by:
routeMessage in interface MessageReceiver
Throws:
MuleException

routeMessage

public final MuleMessage routeMessage(MuleMessage message,
                                      OutputStream outputStream)
                               throws MuleException
Specified by:
routeMessage in interface MessageReceiver
Throws:
MuleException

routeMessage

public final MuleMessage routeMessage(MuleMessage message,
                                      boolean synchronous,
                                      OutputStream outputStream)
                               throws MuleException
Specified by:
routeMessage in interface MessageReceiver
Throws:
MuleException

routeMessage

public final MuleMessage routeMessage(MuleMessage message,
                                      Transaction trans,
                                      boolean synchronous,
                                      OutputStream outputStream)
                               throws MuleException
Specified by:
routeMessage in interface MessageReceiver
Throws:
MuleException

handleUnacceptedFilter

protected MuleMessage handleUnacceptedFilter(MuleMessage message)

setEndpoint

public void setEndpoint(InboundEndpoint endpoint)
Specified by:
setEndpoint in interface MessageReceiver
Parameters:
endpoint - the endpoint to listen on
See Also:
ImmutableEndpoint

setService

public void setService(Service service)
Specified by:
setService in interface MessageReceiver
Parameters:
service - the service to associate with the receiver. When data is received the service 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 EndpointURI getEndpointURI()
Description copied from interface: MessageReceiver
The endpointUri that this receiver listens on

Specified by:
getEndpointURI in interface MessageReceiver
Returns:

getWorkManager

protected WorkManager getWorkManager()

setWorkManager

protected void setWorkManager(WorkManager workManager)

connect

public void connect()
             throws Exception
Description copied from interface: Connectable
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 Connectable
Throws:
Exception

disconnect

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

Specified by:
disconnect in interface Connectable
Throws:
Exception

getConnectionDescription

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

Specified by:
getConnectionDescription in interface Connectable
Returns:

start

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

stop

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

isConnected

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

Specified by:
isConnected in interface Connectable
Returns:

getListener

public InternalMessageListener getListener()

setListener

public void setListener(InternalMessageListener listener)

getConnectEventId

protected String getConnectEventId()

setReceiverKey

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

getReceiverKey

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

toString

public String toString()
Overrides:
toString in class Object

doInitialise

protected void doInitialise()
                     throws InitialisationException
Throws:
InitialisationException

doStart

protected abstract void doStart()
                         throws MuleException
Throws:
MuleException

doStop

protected abstract void doStop()
                        throws MuleException
Throws:
MuleException

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.