org.mule.providers
Class AbstractConnector

java.lang.Object
  extended byorg.mule.providers.AbstractConnector
All Implemented Interfaces:
Disposable, java.beans.ExceptionListener, Initialisable, Startable, Stoppable, UMOConnector
Direct Known Subclasses:
AbstractServiceEnabledConnector, MailConnector

public abstract class AbstractConnector
extends java.lang.Object
implements UMOConnector, java.beans.ExceptionListener

AbstractConnector provides base functionality for all connectors provided with Mule. Connectors are the mechanism used to connect to external systems and protocols in order to send and receive data.

The AbstractConnector provides getter and setter methods for endpoint name, transport name and protocol. It also provides methods to stop and start connecotors and sets up a dispatcher threadpool which allows deriving connectors the possibility to dispatch work to separate threads. This functionality is controlled with the doThreading property on the threadingProfiles for dispachers and receivers.

Version:
$Revision: 1.3 $
Author:
Ross Mason

Field Summary
static int DEFAULT_RETRY_COUNT
           
static long DEFAULT_RETRY_FREQUENCY
           
protected  UMOTransformer defaultInboundTransformer
          The service descriptor can define a default inbound transformer to be used on an endpoint if no other is set
protected  UMOTransformer defaultOutboundTransformer
          The service descriptor can define a default outbound transformer to be used on an endpoint if no other is set
protected  UMOTransformer defaultResponseTransformer
          For some connectors such as http, a response transformer is required or where a replyTo needs a trnasformer
protected  UMOMessageDispatcherFactory dispatcherFactory
          Factory used to create dispatchers for this connector
protected  LRUMap dispatchers
          A pool of dispatchers for this connector, the pool is keyed on endpointUri
protected  SynchronizedBoolean disposed
          Determines in the endpoint is alive and well
protected  UMOExceptionStrategy exceptionStrategy
          The exception strategy used by this endpoint
protected  SynchronizedBoolean initialised
          True once the endpoint has been initialsed
protected  Log logger
          logger used by this class
protected  java.lang.String name
          The name that identifies the endpoint
protected  ConcurrentHashMap receivers
          The collection of listeners on this connector.
protected  SynchronizedBoolean started
          Specifies if the endpoint started
 
Constructor Summary
AbstractConnector()
           
 
Method Summary
protected  UMOMessageDispatcher createDispatcher()
           
abstract  UMOMessageReceiver createReceiver(UMOComponent component, UMOEndpoint endpoint)
           
 void destroyReceiver(UMOMessageReceiver receiver, UMOEndpoint endpoint)
           
 void dispose()
           
protected  void disposeConnector()
          Template method to perform any work when destroying the connectoe
 void doInitialise()
           
 void exceptionThrown(java.lang.Exception e)
           
 UMOTransformer getDefaultInboundTransformer()
           
 UMOTransformer getDefaultOutboundTransformer()
           
 UMOTransformer getDefaultResponseTransformer()
           
 UMOMessageDispatcher getDispatcher(java.lang.String endpoint)
          The connector can pool dispatchers based on their endpointUri or can ingnore the endpointUri altogether and use a ThreadLocal or always create new.
 UMOMessageDispatcherFactory getDispatcherFactory()
          The dispatcher factory is used to create a message dispatcher of the current request
 ThreadingProfile getDispatcherThreadingProfile()
           
 UMOExceptionStrategy getExceptionStrategy()
           
 java.lang.String getName()
           
abstract  java.lang.String getProtocol()
           
protected  java.lang.Object getReceiverKey(UMOComponent component, UMOEndpoint endpoint)
           
 ThreadingProfile getReceiverThreadingProfile()
           
 ReplyToHandler getReplyToHandler()
           
 int getRetryCount()
           
 long getRetryFrequency()
           
 void handleException(java.lang.Object message, java.lang.Throwable exception)
           
 void initialise()
           
 boolean isDisposed()
           
 boolean isDisposeDispatcherOnCompletion()
           
 boolean isStarted()
           
 UMOMessageReceiver registerListener(UMOComponent component, UMOEndpoint endpoint)
          This creates a UMOMessageReceiver associated with this endpoint and registers it with the endpoint
 void setDefaultInboundTransformer(UMOTransformer defaultInboundTransformer)
           
 void setDefaultOutboundTransformer(UMOTransformer defaultOutboundTransformer)
           
 void setDefaultResponseTransformer(UMOTransformer defaultResponseTransformer)
           
 void setDispatcherFactory(UMOMessageDispatcherFactory dispatcerFactory)
          The dispatcher factory is used to create a message dispatcher of the current request
 void setDispatcherThreadingProfile(ThreadingProfile dispatcherThreadingProfile)
           
 void setDisposeDispatcherOnCompletion(boolean disposeDispatcherOnCompletion)
           
 void setExceptionStrategy(UMOExceptionStrategy strategy)
           
 void setName(java.lang.String newName)
           
 void setReceiverThreadingProfile(ThreadingProfile receiverThreadingProfile)
           
 void setRetryCount(int retryCount)
           
 void setRetryFrequency(long retryFrequency)
           
 void start()
           
protected  void startConnector()
          Template method to perform any work when starting the connectoe
 void stop()
           
protected  void stopConnector()
          Template method to perform any work when stopping the connectoe
 void unregisterListener(UMOComponent component, UMOEndpoint endpoint)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.mule.umo.provider.UMOConnector
getMessageAdapter
 

Field Detail

logger

protected transient Log logger
logger used by this class


DEFAULT_RETRY_FREQUENCY

public static final long DEFAULT_RETRY_FREQUENCY
See Also:
Constant Field Values

DEFAULT_RETRY_COUNT

public static final int DEFAULT_RETRY_COUNT
See Also:
Constant Field Values

started

protected SynchronizedBoolean started
Specifies if the endpoint started


initialised

protected SynchronizedBoolean initialised
True once the endpoint has been initialsed


name

protected java.lang.String name
The name that identifies the endpoint


exceptionStrategy

protected UMOExceptionStrategy exceptionStrategy
The exception strategy used by this endpoint


disposed

protected SynchronizedBoolean disposed
Determines in the endpoint is alive and well


dispatcherFactory

protected UMOMessageDispatcherFactory dispatcherFactory
Factory used to create dispatchers for this connector


dispatchers

protected LRUMap dispatchers
A pool of dispatchers for this connector, the pool is keyed on endpointUri


receivers

protected ConcurrentHashMap receivers
The collection of listeners on this connector. Keyed by entrypoint


defaultInboundTransformer

protected UMOTransformer defaultInboundTransformer
The service descriptor can define a default inbound transformer to be used on an endpoint if no other is set


defaultOutboundTransformer

protected UMOTransformer defaultOutboundTransformer
The service descriptor can define a default outbound transformer to be used on an endpoint if no other is set


defaultResponseTransformer

protected UMOTransformer defaultResponseTransformer
For some connectors such as http, a response transformer is required or where a replyTo needs a trnasformer

Constructor Detail

AbstractConnector

public AbstractConnector()
Method Detail

getName

public java.lang.String getName()
Specified by:
getName in interface UMOConnector
Returns:
the name associated with the endpoint

setName

public void setName(java.lang.String newName)
Specified by:
setName in interface UMOConnector
Parameters:
newName - the name to associate with the endpoint

initialise

public final void initialise()
                      throws InitialisationException
Specified by:
initialise in interface Initialisable
Throws:
InitialisationException

getProtocol

public abstract java.lang.String getProtocol()
Specified by:
getProtocol in interface UMOConnector
Returns:
the protocol name for the endpoint

getRetryFrequency

public long getRetryFrequency()

setRetryFrequency

public void setRetryFrequency(long retryFrequency)

getRetryCount

public int getRetryCount()

setRetryCount

public void setRetryCount(int retryCount)

start

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

isStarted

public boolean isStarted()
Specified by:
isStarted in interface UMOConnector
Returns:
true if the endpoint is started

stop

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

dispose

public final void dispose()
                   throws UMOException
Specified by:
dispose in interface Disposable
Throws:
UMOException

isDisposed

public boolean isDisposed()
Specified by:
isDisposed in interface UMOConnector
Returns:
true if the endpoint is alive and well or false if the endpoint is being destroyed

handleException

public void handleException(java.lang.Object message,
                            java.lang.Throwable exception)
Specified by:
handleException in interface UMOConnector
Parameters:
message - the object that was being processed when the exception occurred
exception - the exception that was caught

exceptionThrown

public void exceptionThrown(java.lang.Exception e)
Specified by:
exceptionThrown in interface java.beans.ExceptionListener

getExceptionStrategy

public UMOExceptionStrategy getExceptionStrategy()
Specified by:
getExceptionStrategy in interface UMOConnector
Returns:
the ExceptionStrategy for this endpoint
See Also:
UMOExceptionStrategy

setExceptionStrategy

public void setExceptionStrategy(UMOExceptionStrategy strategy)
Specified by:
setExceptionStrategy in interface UMOConnector
Parameters:
strategy - the ExceptionStrategy to use with this endpoint
See Also:
UMOExceptionStrategy

getDispatcherFactory

public UMOMessageDispatcherFactory getDispatcherFactory()
Description copied from interface: UMOConnector
The dispatcher factory is used to create a message dispatcher of the current request

Specified by:
getDispatcherFactory in interface UMOConnector
Returns:
Returns the dispatcherFactory.

setDispatcherFactory

public void setDispatcherFactory(UMOMessageDispatcherFactory dispatcerFactory)
Description copied from interface: UMOConnector
The dispatcher factory is used to create a message dispatcher of the current request

Specified by:
setDispatcherFactory in interface UMOConnector
Parameters:
dispatcerFactory - The dispatcherFactory to set.

getDispatcher

public UMOMessageDispatcher getDispatcher(java.lang.String endpoint)
                                   throws UMOException
Description copied from interface: UMOConnector
The connector can pool dispatchers based on their endpointUri or can ingnore the endpointUri altogether and use a ThreadLocal or always create new.

Specified by:
getDispatcher in interface UMOConnector
Parameters:
endpoint - the endpointUri that can be used to key cached dispatchers
Returns:
the component associated with the endpointUri If there is no component for the current thread one will be created
Throws:
UMOException - if creation of a component fails

createDispatcher

protected UMOMessageDispatcher createDispatcher()
                                         throws UMOException
Throws:
UMOException

registerListener

public UMOMessageReceiver registerListener(UMOComponent component,
                                           UMOEndpoint endpoint)
                                    throws java.lang.Exception
Description copied from interface: UMOConnector
This creates a UMOMessageReceiver associated with this endpoint and registers it with the endpoint

Specified by:
registerListener in interface UMOConnector
Parameters:
component - the listening component
endpoint - the endpoint contains the listener endpointUri on which to listen on.
Throws:
java.lang.Exception - if the UMOMessageReceiver cannot be created or the Receiver cannot be registered

getReceiverKey

protected java.lang.Object getReceiverKey(UMOComponent component,
                                          UMOEndpoint endpoint)

unregisterListener

public final void unregisterListener(UMOComponent component,
                                     UMOEndpoint endpoint)
                              throws java.lang.Exception
Specified by:
unregisterListener in interface UMOConnector
Parameters:
component - the listening component
endpoint - the associated endpointDescriptor with the listener
Throws:
java.lang.Exception - if the listener cannot be unregistered. If a listener is not associated with the given endpoint this will not throw an exception

getDispatcherThreadingProfile

public ThreadingProfile getDispatcherThreadingProfile()

setDispatcherThreadingProfile

public void setDispatcherThreadingProfile(ThreadingProfile dispatcherThreadingProfile)

getReceiverThreadingProfile

public ThreadingProfile getReceiverThreadingProfile()

setReceiverThreadingProfile

public void setReceiverThreadingProfile(ThreadingProfile receiverThreadingProfile)

createReceiver

public abstract UMOMessageReceiver createReceiver(UMOComponent component,
                                                  UMOEndpoint endpoint)
                                           throws java.lang.Exception
Throws:
java.lang.Exception

destroyReceiver

public void destroyReceiver(UMOMessageReceiver receiver,
                            UMOEndpoint endpoint)
                     throws java.lang.Exception
Throws:
java.lang.Exception

startConnector

protected void startConnector()
                       throws UMOException
Template method to perform any work when starting the connectoe

Throws:
UMOException - if the method fails

stopConnector

protected void stopConnector()
                      throws UMOException
Template method to perform any work when stopping the connectoe

Throws:
UMOException - if the method fails

isDisposeDispatcherOnCompletion

public boolean isDisposeDispatcherOnCompletion()

setDisposeDispatcherOnCompletion

public void setDisposeDispatcherOnCompletion(boolean disposeDispatcherOnCompletion)

disposeConnector

protected void disposeConnector()
                         throws UMOException
Template method to perform any work when destroying the connectoe

Throws:
UMOException - if the method fails

doInitialise

public void doInitialise()
                  throws InitialisationException
Throws:
InitialisationException

getDefaultInboundTransformer

public UMOTransformer getDefaultInboundTransformer()

setDefaultInboundTransformer

public void setDefaultInboundTransformer(UMOTransformer defaultInboundTransformer)

getDefaultResponseTransformer

public UMOTransformer getDefaultResponseTransformer()

getDefaultOutboundTransformer

public UMOTransformer getDefaultOutboundTransformer()

setDefaultOutboundTransformer

public void setDefaultOutboundTransformer(UMOTransformer defaultOutboundTransformer)

setDefaultResponseTransformer

public void setDefaultResponseTransformer(UMOTransformer defaultResponseTransformer)

getReplyToHandler

public ReplyToHandler getReplyToHandler()


Copyright © 2003-2005 SymphonySoft Limited. All Rights Reserved.