org.mule.providers
Class AbstractConnector

java.lang.Object
  extended byorg.mule.providers.AbstractConnector
All Implemented Interfaces:
Disposable, EventListener, ExceptionListener, Initialisable, UMOConnectable, UMOConnector, WorkListener
Direct Known Subclasses:
AbstractJndiConnector, AbstractMailConnector, AxisConnector, FileConnector, FtpConnector, JbiConnector, JdbcConnector, JmsConnector, ProcessConnector, QuartzConnector, ServletConnector, StreamConnector, TcpConnector, TestConnector, UdpConnector, VMConnector, XFireConnector, XmppConnector

public abstract class AbstractConnector
extends Object
implements UMOConnector, ExceptionListener, UMOConnectable, WorkListener

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. The lifecycle for a connector is -

  1. Create
  2. Initialise
  3. Connect
  4. Connect receivers
  5. Start
  6. Start Receivers
  7. Stop
  8. Stop Receivers
  9. Disconnect
  10. Disconnect Receivers
  11. Dispose
  12. Dispose Receivers


Field Summary
protected  WaitableBoolean connected
           
protected  WaitableBoolean connecting
           
protected  ConnectionStrategy connectionStrategy
           
protected  boolean createMultipleTransactedReceivers
           
static int DEFAULT_NUM_CONCURRENT_TX_RECEIVERS
          Default number of concurrent transactional receivers.
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  GenericKeyedObjectPool dispatchers
          A pool of dispatchers for this connector, keyed by endpoint
protected  AtomicBoolean disposed
          Determines in the connector is alive and well
protected  AtomicBoolean disposing
          Determines in connector has been told to dispose
protected  ExceptionListener exceptionListener
          The exception strategy used by this connector
protected  AtomicBoolean initialised
          True once the endpoint has been initialsed
protected  Log logger
          logger used by this class
protected  String name
          The name that identifies the endpoint
protected  int numberOfConcurrentTransactedReceivers
           
protected  ConcurrentMap receivers
          The collection of listeners on this connector.
protected  TransportServiceDescriptor serviceDescriptor
          Holds the service configuration for this connector
protected  Properties serviceOverrides
          The map of service overrides that can e used to extend the capabilities of the connector
protected  UMOSessionHandler sessionHandler
          The strategy used for reading and writing session information to and fromt he transport
protected  AtomicBoolean started
          Specifies if the endpoint started
protected  WaitableBoolean startOnConnect
          If the connect method was called via the start method, this will be set so that when the connector comes on line it will be started
 
Fields inherited from interface org.mule.umo.provider.UMOConnector
INT_VALUE_NOT_SET
 
Constructor Summary
AbstractConnector()
          Constructs a new AbstractConnector.
 
Method Summary
protected  void checkDisposed()
           
 void connect()
          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.
protected  UMOMessageReceiver createReceiver(UMOComponent component, UMOEndpoint endpoint)
          Create a Message receiver for this connector
protected  void destroyReceiver(UMOMessageReceiver receiver, UMOEndpoint endpoint)
           
 void disconnect()
          Disconnect the from the underlying transport
 void dispatch(UMOImmutableEndpoint endpoint, UMOEvent event)
          Dispatches an event from the endpoint to the external system
 void dispose()
          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.
protected  void disposeDispatchers()
           
protected  void disposeReceivers()
           
protected  void disposeWorkManagers()
           
protected abstract  void doConnect()
          Template method where any connections should be made for the connector
protected abstract  void doDisconnect()
          Template method where any connected resources used by the connector should be disconnected
protected abstract  void doDispose()
          Template method to perform any work when destroying the connectoe
protected abstract  void doInitialise()
           
protected abstract  void doStart()
          Template method to perform any work when starting the connectoe
protected abstract  void doStop()
          Template method to perform any work when stopping the connectoe
 void exceptionThrown(Exception e)
          
 void fireNotification(UMOServerNotification notification)
          Fires a server notification to all registered CustomNotificationListener eventManager.
protected  String getConnectEventId()
          The resource id used when firing ConnectEvents from this connector
 String getConnectionDescription()
          Returns a string identifying the underlying resource
 ConnectionStrategy getConnectionStrategy()
          Getter for property 'connectionStrategy'.
 UMOTransformer getDefaultInboundTransformer()
          Getter for property 'defaultInboundTransformer'.
 UMOTransformer getDefaultOutboundTransformer()
          Getter for property 'defaultOutboundTransformer'.
 UMOTransformer getDefaultResponseTransformer()
          Getter for property 'defaultResponseTransformer'.
 UMOMessageDispatcherFactory getDispatcherFactory()
          The dispatcher factory is used to create a message dispatcher of the current request
 ThreadingProfile getDispatcherThreadingProfile()
          Getter for property 'dispatcherThreadingProfile'.
protected  UMOWorkManager getDispatcherWorkManager()
          Returns a work manager for message dispatchers.
 ExceptionListener getExceptionListener()
           
 int getMaxDispatchersActive()
          Returns the maximum number of dispatchers that can be concurrently active per endpoint.
 UMOMessageAdapter getMessageAdapter(Object message)
          Gets a UMOMessageAdapter for the endpoint for the given message (data)
 String getName()
          
 int getNumberOfConcurrentTransactedReceivers()
          Returns the number of concurrent receivers that will be launched when isCreateMultipleTransactedReceivers() returns true.
 OutputStream getOutputStream(UMOImmutableEndpoint endpoint, UMOMessage message)
          Will get the output stream for this type of transport.
 UMOMessageReceiver getReceiver(UMOComponent component, UMOEndpoint endpoint)
           
protected  Object getReceiverKey(UMOComponent component, UMOEndpoint endpoint)
          The method determines the key used to store the receiver against.
 Map getReceivers()
          Getter for property 'receivers'.
 UMOMessageReceiver[] getReceivers(String wildcardExpression)
           
 ThreadingProfile getReceiverThreadingProfile()
          Getter for property 'receiverThreadingProfile'.
protected  UMOWorkManager getReceiverWorkManager(String receiverName)
          Returns a work manager for message receivers.
 ReplyToHandler getReplyToHandler()
          Getter for property 'replyToHandler'.
 ScheduledExecutorService getScheduler()
          Returns a Scheduler service for execution of periodic tasks.
protected  TransportServiceDescriptor getServiceDescriptor()
          Get the TransportServiceDescriptor for this connector.
 Map getServiceOverrides()
          A map of fully qualified class names that should override those in the connectors' service descriptor This map will be null if there are no overrides
 UMOSessionHandler getSessionHandler()
          Getter for property 'sessionHandler'.
 UMOStreamMessageAdapter getStreamMessageAdapter(InputStream in, OutputStream out)
          Gets a UMOStreamMessageAdapter from the connector for the given message.
 List getSupportedProtocols()
          Returns an unmodifiable list of the protocols supported by this connector
 void handleException(Exception exception)
          
protected  void handleWorkException(WorkEvent event, String type)
           
protected  void initFromServiceDescriptor()
          Initialises this connector from its TransportServiceDescriptor This will be called before the doInitialise() method is called.
 void initialise()
          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.
 void initialiseFromUrl(UMOEndpointURI endpointUri)
          When this connector is created via the TransportFactory the endpoint used to determine the connector type is passed to this method so that any properties set on the endpoint that can be used to initialise the connector are made available.
 boolean isConnected()
          Determines if this object is connected or not
 boolean isCreateMultipleTransactedReceivers()
          For better throughput when using TransactedMessageReceivers this will enable a number of concurrent receivers, based on the value returned by getNumberOfConcurrentTransactedReceivers().
 boolean isDisposed()
          
 boolean isDisposing()
          
 boolean isEnableMessageEvents()
          Whether to fire message notifications for every message that is sent or received from this connector
 boolean isRemoteSyncEnabled()
          
 boolean isStarted()
          
 UMOMessageReceiver lookupReceiver(String key)
           
 UMOMessage receive(UMOEndpointURI endpointUri, long timeout)
          Make a specific request to the underlying transport
 UMOMessage receive(UMOImmutableEndpoint endpoint, long timeout)
          Make a specific request to the underlying transport
 UMOMessageReceiver registerListener(UMOComponent component, UMOEndpoint endpoint)
          This creates a UMOMessageReceiver associated with this endpoint and registers it with the connector.
 void registerSupportedProtocol(String protocol)
          Registers other protocols 'understood' by this connector.
protected  void registerSupportedProtocolWithoutPrefix(String protocol)
          Registers other protocols 'understood' by this connector.
 UMOMessage send(UMOImmutableEndpoint endpoint, UMOEvent event)
          Sends an event from the endpoint to the external system
 void setConnectionStrategy(ConnectionStrategy connectionStrategy)
          Setter for property 'connectionStrategy'.
 void setCreateMultipleTransactedReceivers(boolean createMultipleTransactedReceivers)
           
 void setDefaultInboundTransformer(UMOTransformer defaultInboundTransformer)
          Setter for property 'defaultInboundTransformer'.
 void setDefaultOutboundTransformer(UMOTransformer defaultOutboundTransformer)
          Setter for property 'defaultOutboundTransformer'.
 void setDefaultResponseTransformer(UMOTransformer defaultResponseTransformer)
          Setter for property 'defaultResponseTransformer'.
 void setDispatcherFactory(UMOMessageDispatcherFactory dispatcherFactory)
          The dispatcher factory is used to create a message dispatcher of the current request
 void setDispatcherThreadingProfile(ThreadingProfile dispatcherThreadingProfile)
          Setter for property 'dispatcherThreadingProfile'.
 void setEnableMessageEvents(boolean enableMessageEvents)
          Whether to fire message notifications for every message that is sent or received from this connector
 void setExceptionListener(ExceptionListener listener)
           
 void setMaxDispatchersActive(int maxActive)
          Configures the maximum number of dispatchers that can be concurrently active per endpoint
 void setName(String newName)
          
 void setNumberOfConcurrentTransactedReceivers(int count)
           
 void setReceiverThreadingProfile(ThreadingProfile receiverThreadingProfile)
          Setter for property 'receiverThreadingProfile'.
 void setServiceOverrides(Map serviceOverrides)
          Set the Service overrides on this connector.
 void setSessionHandler(UMOSessionHandler sessionHandler)
          Setter for property 'sessionHandler'.
 void setSupportedProtocols(List supportedProtocols)
          Sets A list of protocols that the connector can accept
 void startConnector()
          
 void stopConnector()
          
 boolean supportsProtocol(String protocol)
           
 String toString()
           
 void unregisterListener(UMOComponent component, UMOEndpoint endpoint)
          
 void unregisterSupportedProtocol(String protocol)
           
 void workAccepted(WorkEvent event)
          
 void workCompleted(WorkEvent event)
          
 void workRejected(WorkEvent event)
          
 void workStarted(WorkEvent event)
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.mule.umo.provider.UMOConnector
getProtocol
 

Field Detail

DEFAULT_NUM_CONCURRENT_TX_RECEIVERS

public static final int DEFAULT_NUM_CONCURRENT_TX_RECEIVERS
Default number of concurrent transactional receivers.

See Also:
Constant Field Values

logger

protected final Log logger
logger used by this class


started

protected final AtomicBoolean started
Specifies if the endpoint started


initialised

protected final AtomicBoolean initialised
True once the endpoint has been initialsed


name

protected volatile String name
The name that identifies the endpoint


exceptionListener

protected volatile ExceptionListener exceptionListener
The exception strategy used by this connector


disposed

protected final AtomicBoolean disposed
Determines in the connector is alive and well


disposing

protected final AtomicBoolean disposing
Determines in connector has been told to dispose


dispatcherFactory

protected volatile UMOMessageDispatcherFactory dispatcherFactory
Factory used to create dispatchers for this connector


dispatchers

protected final GenericKeyedObjectPool dispatchers
A pool of dispatchers for this connector, keyed by endpoint


receivers

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


createMultipleTransactedReceivers

protected volatile boolean createMultipleTransactedReceivers
See Also:
{@link #isCreateMultipleTransactedReceivers()}

numberOfConcurrentTransactedReceivers

protected volatile int numberOfConcurrentTransactedReceivers
See Also:
{@link #getNumberOfConcurrentTransactedReceivers()}

defaultInboundTransformer

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


defaultOutboundTransformer

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


defaultResponseTransformer

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


connectionStrategy

protected volatile ConnectionStrategy connectionStrategy

connected

protected final WaitableBoolean connected

connecting

protected final WaitableBoolean connecting

startOnConnect

protected final WaitableBoolean startOnConnect
If the connect method was called via the start method, this will be set so that when the connector comes on line it will be started


serviceDescriptor

protected volatile TransportServiceDescriptor serviceDescriptor
Holds the service configuration for this connector


serviceOverrides

protected volatile Properties serviceOverrides
The map of service overrides that can e used to extend the capabilities of the connector


sessionHandler

protected volatile UMOSessionHandler sessionHandler
The strategy used for reading and writing session information to and fromt he transport

Constructor Detail

AbstractConnector

public AbstractConnector()
Constructs a new AbstractConnector.

Method Detail

getName

public String getName()

Specified by:
getName in interface UMOConnector
Returns:
the name associated with the connector

setName

public void setName(String newName)

Specified by:
setName in interface UMOConnector
Parameters:
newName - the name to associate with the connector

initialise

public final 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

startConnector

public final void startConnector()
                          throws UMOException

Specified by:
startConnector in interface UMOConnector
Throws:
UMOException

isStarted

public boolean isStarted()

Specified by:
isStarted in interface UMOConnector
Returns:
true if the endpoint is started

stopConnector

public final void stopConnector()
                         throws UMOException

Specified by:
stopConnector in interface UMOConnector
Throws:
UMOException

dispose

public final void dispose()
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

disposeWorkManagers

protected void disposeWorkManagers()

disposeReceivers

protected void disposeReceivers()

disposeDispatchers

protected void disposeDispatchers()

isDisposed

public boolean isDisposed()

Specified by:
isDisposed in interface UMOConnector
Returns:
false if the connector is alive and well or true if the connector is being destroyed

handleException

public void handleException(Exception exception)

Specified by:
handleException in interface UMOConnector
Parameters:
exception - the exception that was caught

exceptionThrown

public void exceptionThrown(Exception e)

Specified by:
exceptionThrown in interface ExceptionListener

getExceptionListener

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

setExceptionListener

public void setExceptionListener(ExceptionListener listener)
Specified by:
setExceptionListener in interface UMOConnector
Parameters:
listener - the ExceptionStrategy to use with this endpoint
See Also:
ExceptionListener

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 dispatcherFactory)
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:
dispatcherFactory - The dispatcherFactory to set.

getMaxDispatchersActive

public int getMaxDispatchersActive()
Returns the maximum number of dispatchers that can be concurrently active per endpoint.

Returns:
max. number of active dispatchers

setMaxDispatchersActive

public void setMaxDispatchersActive(int maxActive)
Configures the maximum number of dispatchers that can be concurrently active per endpoint

Parameters:
maxActive - max. number of active dispatchers

checkDisposed

protected void checkDisposed()
                      throws DisposeException
Throws:
DisposeException

registerListener

public UMOMessageReceiver registerListener(UMOComponent component,
                                           UMOEndpoint endpoint)
                                    throws Exception
This creates a UMOMessageReceiver associated with this endpoint and registers it with the connector.

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

getReceiverKey

protected Object getReceiverKey(UMOComponent component,
                                UMOEndpoint endpoint)
The method determines the key used to store the receiver against.

Parameters:
component - the component for which the endpoint is being registered
endpoint - the endpoint being registered for the component
Returns:
the key to store the newly created receiver against

unregisterListener

public final void unregisterListener(UMOComponent component,
                                     UMOEndpoint endpoint)
                              throws Exception

Specified by:
unregisterListener in interface UMOConnector
Parameters:
component - the listening component
endpoint - the associated endpointDescriptor with the listener
Throws:
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()
Getter for property 'dispatcherThreadingProfile'.

Returns:
Value for property 'dispatcherThreadingProfile'.

setDispatcherThreadingProfile

public void setDispatcherThreadingProfile(ThreadingProfile dispatcherThreadingProfile)
Setter for property 'dispatcherThreadingProfile'.

Parameters:
dispatcherThreadingProfile - Value to set for property 'dispatcherThreadingProfile'.

getReceiverThreadingProfile

public ThreadingProfile getReceiverThreadingProfile()
Getter for property 'receiverThreadingProfile'.

Returns:
Value for property 'receiverThreadingProfile'.

setReceiverThreadingProfile

public void setReceiverThreadingProfile(ThreadingProfile receiverThreadingProfile)
Setter for property 'receiverThreadingProfile'.

Parameters:
receiverThreadingProfile - Value to set for property 'receiverThreadingProfile'.

destroyReceiver

protected void destroyReceiver(UMOMessageReceiver receiver,
                               UMOEndpoint endpoint)
                        throws Exception
Throws:
Exception

doInitialise

protected abstract void doInitialise()
                              throws InitialisationException
Throws:
InitialisationException

doDispose

protected abstract void doDispose()
Template method to perform any work when destroying the connectoe


doStart

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

Throws:
UMOException - if the method fails

doStop

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

Throws:
UMOException - if the method fails

getDefaultInboundTransformer

public UMOTransformer getDefaultInboundTransformer()
Getter for property 'defaultInboundTransformer'.

Returns:
Value for property 'defaultInboundTransformer'.

setDefaultInboundTransformer

public void setDefaultInboundTransformer(UMOTransformer defaultInboundTransformer)
Setter for property 'defaultInboundTransformer'.

Parameters:
defaultInboundTransformer - Value to set for property 'defaultInboundTransformer'.

getDefaultResponseTransformer

public UMOTransformer getDefaultResponseTransformer()
Getter for property 'defaultResponseTransformer'.

Returns:
Value for property 'defaultResponseTransformer'.

getDefaultOutboundTransformer

public UMOTransformer getDefaultOutboundTransformer()
Getter for property 'defaultOutboundTransformer'.

Returns:
Value for property 'defaultOutboundTransformer'.

setDefaultOutboundTransformer

public void setDefaultOutboundTransformer(UMOTransformer defaultOutboundTransformer)
Setter for property 'defaultOutboundTransformer'.

Parameters:
defaultOutboundTransformer - Value to set for property 'defaultOutboundTransformer'.

setDefaultResponseTransformer

public void setDefaultResponseTransformer(UMOTransformer defaultResponseTransformer)
Setter for property 'defaultResponseTransformer'.

Parameters:
defaultResponseTransformer - Value to set for property 'defaultResponseTransformer'.

getReplyToHandler

public ReplyToHandler getReplyToHandler()
Getter for property 'replyToHandler'.

Returns:
Value for property 'replyToHandler'.

fireNotification

public void fireNotification(UMOServerNotification notification)
Fires a server notification to all registered CustomNotificationListener eventManager.

Parameters:
notification - the notification to fire. This must be of type CustomNotification otherwise an exception will be thrown.
Throws:
UnsupportedOperationException - if the notification fired is not a CustomNotification

getConnectionStrategy

public ConnectionStrategy getConnectionStrategy()
Getter for property 'connectionStrategy'.

Returns:
Value for property 'connectionStrategy'.

setConnectionStrategy

public void setConnectionStrategy(ConnectionStrategy connectionStrategy)
Setter for property 'connectionStrategy'.

Parameters:
connectionStrategy - Value to set for property 'connectionStrategy'.

isDisposing

public boolean isDisposing()

Specified by:
isDisposing in interface UMOConnector
Returns:
false if the connector is alive and well or true if the connector has been told to dispose

isRemoteSyncEnabled

public boolean isRemoteSyncEnabled()

Specified by:
isRemoteSyncEnabled in interface UMOConnector

getReceiver

public UMOMessageReceiver getReceiver(UMOComponent component,
                                      UMOEndpoint endpoint)

getReceivers

public Map getReceivers()
Getter for property 'receivers'.

Returns:
Value for property 'receivers'.

lookupReceiver

public UMOMessageReceiver lookupReceiver(String key)

getReceivers

public UMOMessageReceiver[] getReceivers(String wildcardExpression)

connect

public void connect()
             throws Exception
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
Disconnect the from the underlying transport

Specified by:
disconnect in interface UMOConnectable
Throws:
Exception

getConnectionDescription

public String getConnectionDescription()
Returns a string identifying the underlying resource

Specified by:
getConnectionDescription in interface UMOConnectable
Returns:

isConnected

public final boolean isConnected()
Determines if this object is connected or not

Specified by:
isConnected in interface UMOConnectable
Returns:

doConnect

protected abstract void doConnect()
                           throws Exception
Template method where any connections should be made for the connector

Throws:
Exception

doDisconnect

protected abstract void doDisconnect()
                              throws Exception
Template method where any connected resources used by the connector should be disconnected

Throws:
Exception

getConnectEventId

protected String getConnectEventId()
The resource id used when firing ConnectEvents from this connector

Returns:
the resource id used when firing ConnectEvents from this connector

isCreateMultipleTransactedReceivers

public boolean isCreateMultipleTransactedReceivers()
For better throughput when using TransactedMessageReceivers this will enable a number of concurrent receivers, based on the value returned by getNumberOfConcurrentTransactedReceivers(). This property is used by transports that support transactions, specifically receivers that extend the TransactedPollingMessageReceiver.

Returns:
true if multiple receivers will be enabled for this connection

setCreateMultipleTransactedReceivers

public void setCreateMultipleTransactedReceivers(boolean createMultipleTransactedReceivers)
Parameters:
createMultipleTransactedReceivers - if true, multiple receivers will be created for this connection
See Also:
{@link #isCreateMultipleTransactedReceivers()}

getNumberOfConcurrentTransactedReceivers

public int getNumberOfConcurrentTransactedReceivers()
Returns the number of concurrent receivers that will be launched when isCreateMultipleTransactedReceivers() returns true.

See Also:
DEFAULT_NUM_CONCURRENT_TX_RECEIVERS

setNumberOfConcurrentTransactedReceivers

public void setNumberOfConcurrentTransactedReceivers(int count)
Parameters:
count - the number of concurrent transacted receivers to start
See Also:
{@link #getNumberOfConcurrentTransactedReceivers()}

isEnableMessageEvents

public boolean isEnableMessageEvents()
Whether to fire message notifications for every message that is sent or received from this connector


setEnableMessageEvents

public void setEnableMessageEvents(boolean enableMessageEvents)
Whether to fire message notifications for every message that is sent or received from this connector

Parameters:
enableMessageEvents -

registerSupportedProtocol

public void registerSupportedProtocol(String protocol)
Registers other protocols 'understood' by this connector. These must contain scheme meta info. Any protocol registered must begin with the protocol of this connector, i.e. If the connector is axis the protocol for jms over axis will be axis:jms. Here, 'axis' is the scheme meta info and 'jms' is the protocol. If the protocol argument does not start with the connector's protocol, it will be appended.

Parameters:
protocol - the supported protocol to register

registerSupportedProtocolWithoutPrefix

protected void registerSupportedProtocolWithoutPrefix(String protocol)
Registers other protocols 'understood' by this connector. These must contain scheme meta info. Unlike the registerSupportedProtocol(String) method, this allows you to register protocols that are not prefixed with the connector protocol. This is useful where you use a Service Finder to discover which Transport implementation to use. For example the 'wsdl' transport is a generic 'finder' transport that will use Axis, Xfire or Glue to create the WSDL client. These transport protocols would be wsdl-axis, wsdl-xfire and wsdl-glue, but they can all support 'wsdl' protocol too.

Parameters:
protocol - the supported protocol to register

unregisterSupportedProtocol

public void unregisterSupportedProtocol(String protocol)

supportsProtocol

public boolean supportsProtocol(String protocol)
Specified by:
supportsProtocol in interface UMOConnector
Parameters:
protocol - protocol name
Returns:
true if the protocol is supported by this connector.

getSupportedProtocols

public List getSupportedProtocols()
Returns an unmodifiable list of the protocols supported by this connector

Returns:
an unmodifiable list of the protocols supported by this connector

setSupportedProtocols

public void setSupportedProtocols(List supportedProtocols)
Sets A list of protocols that the connector can accept

Parameters:
supportedProtocols -

getReceiverWorkManager

protected UMOWorkManager getReceiverWorkManager(String receiverName)
                                         throws UMOException
Returns a work manager for message receivers.

Throws:
UMOException

getDispatcherWorkManager

protected UMOWorkManager getDispatcherWorkManager()
                                           throws UMOException
Returns a work manager for message dispatchers.

Throws:
UMOException - in case of error

getScheduler

public ScheduledExecutorService getScheduler()
Returns a Scheduler service for execution of periodic tasks.

Specified by:
getScheduler in interface UMOConnector
Returns:
scheduler

getSessionHandler

public UMOSessionHandler getSessionHandler()
Getter for property 'sessionHandler'.

Returns:
Value for property 'sessionHandler'.

setSessionHandler

public void setSessionHandler(UMOSessionHandler sessionHandler)
Setter for property 'sessionHandler'.

Parameters:
sessionHandler - Value to set for property 'sessionHandler'.

workAccepted

public void workAccepted(WorkEvent event)

Specified by:
workAccepted in interface WorkListener

workRejected

public void workRejected(WorkEvent event)

Specified by:
workRejected in interface WorkListener

workStarted

public void workStarted(WorkEvent event)

Specified by:
workStarted in interface WorkListener

workCompleted

public void workCompleted(WorkEvent event)

Specified by:
workCompleted in interface WorkListener

handleWorkException

protected void handleWorkException(WorkEvent event,
                                   String type)

dispatch

public void dispatch(UMOImmutableEndpoint endpoint,
                     UMOEvent event)
              throws DispatchException
Dispatches an event from the endpoint to the external system

Specified by:
dispatch in interface UMOConnector
Parameters:
event - The event to dispatch
endpoint - endpoint to dispatch from
Throws:
DispatchException - if the event fails to be dispatched

receive

public UMOMessage receive(UMOEndpointURI endpointUri,
                          long timeout)
                   throws Exception
Make a specific request to the underlying transport

Specified by:
receive in interface UMOConnector
Parameters:
endpointUri - the endpoint URI to use when connecting to the resource
timeout - the maximum time the operation should block before returning. The call should return immediately if there is data available. If no data becomes available before the timeout elapses, null will be returned
Returns:
the result of the request wrapped in a UMOMessage object. Null will be returned if no data was avaialable
Throws:
Exception - if the call to the underlying protocal cuases an exception

receive

public UMOMessage receive(UMOImmutableEndpoint endpoint,
                          long timeout)
                   throws Exception
Make a specific request to the underlying transport

Specified by:
receive in interface UMOConnector
Parameters:
endpoint - the endpoint to use when connecting to the resource
timeout - the maximum time the operation should block before returning. The call should return immediately if there is data available. If no data becomes available before the timeout elapses, null will be returned
Returns:
the result of the request wrapped in a UMOMessage object. Null will be returned if no data was avaialable
Throws:
Exception - if the call to the underlying protocal cuases an exception

send

public UMOMessage send(UMOImmutableEndpoint endpoint,
                       UMOEvent event)
                throws DispatchException
Sends an event from the endpoint to the external system

Specified by:
send in interface UMOConnector
Parameters:
event - The event to send
endpoint - endpoint to send from
Returns:
event the response form the external system wrapped in a UMOEvent
Throws:
DispatchException - if the event fails to be dispatched

initialiseFromUrl

public void initialiseFromUrl(UMOEndpointURI endpointUri)
                       throws InitialisationException
When this connector is created via the TransportFactory the endpoint used to determine the connector type is passed to this method so that any properties set on the endpoint that can be used to initialise the connector are made available.

Parameters:
endpointUri - the UMOEndpointURI use to create this connector
Throws:
InitialisationException - If there are any problems with the configuration set on the Endpoint or if another exception is thrown it is wrapped in an InitialisationException.

initFromServiceDescriptor

protected void initFromServiceDescriptor()
                                  throws InitialisationException
Initialises this connector from its TransportServiceDescriptor This will be called before the doInitialise() method is called.

Throws:
InitialisationException - InitialisationException If there are any problems with the configuration or if another exception is thrown it is wrapped in an InitialisationException.

getServiceDescriptor

protected TransportServiceDescriptor getServiceDescriptor()
Get the TransportServiceDescriptor for this connector. This will be null if the connector was created by the developer. To create a connector the proper way the developer should use the TransportFactory and pass in an endpoint.

Returns:
the TransportServiceDescriptor for this connector

createReceiver

protected UMOMessageReceiver createReceiver(UMOComponent component,
                                            UMOEndpoint endpoint)
                                     throws Exception
Create a Message receiver for this connector

Parameters:
component - the component that will receive events from this receiver, the listener
endpoint - the endpoint that defies this inbound communication
Returns:
an instance of the message receiver defined in this connectors' TransportServiceDescriptor initialised using the component and endpoint.
Throws:
Exception - if there is a problem creating the receiver. This exception really depends on the underlying transport, thus any exception could be thrown

getMessageAdapter

public UMOMessageAdapter getMessageAdapter(Object message)
                                    throws MessagingException
Gets a UMOMessageAdapter for the endpoint for the given message (data)

Specified by:
getMessageAdapter in interface UMOConnector
Parameters:
message - the data with which to initialise the UMOMessageAdapter
Returns:
the UMOMessageAdapter for the endpoint
Throws:
MessagingException - if the message parameter is not supported
See Also:
UMOMessageAdapter

getStreamMessageAdapter

public UMOStreamMessageAdapter getStreamMessageAdapter(InputStream in,
                                                       OutputStream out)
                                                throws MessagingException
Gets a UMOStreamMessageAdapter from the connector for the given message. This Adapter will correctly handle data streaming for this type of connector

Specified by:
getStreamMessageAdapter in interface UMOConnector
Parameters:
in - the input stream to read the data from
out - the outputStream to write data to. This can be null.
Returns:
the UMOStreamMessageAdapter for the endpoint
Throws:
MessagingException - if the message parameter is not supported
See Also:
UMOStreamMessageAdapter

getServiceOverrides

public Map getServiceOverrides()
A map of fully qualified class names that should override those in the connectors' service descriptor This map will be null if there are no overrides

Returns:
a map of override values or null

setServiceOverrides

public void setServiceOverrides(Map serviceOverrides)
Set the Service overrides on this connector.

Parameters:
serviceOverrides - the override values to use

getOutputStream

public OutputStream getOutputStream(UMOImmutableEndpoint endpoint,
                                    UMOMessage message)
                             throws UMOException
Will get the output stream for this type of transport. Typically this will be called only when Streaming is being used on an outbound endpoint. If Streaming is not supported by this transport an UnsupportedOperationException is thrown. Note that the stream MUST release resources on close. For help doing so, see CallbackOutputStream.

Specified by:
getOutputStream in interface UMOConnector
Parameters:
endpoint - the endpoint that releates to this Dispatcher
message - the current message being processed
Returns:
the output stream to use for this request
Throws:
UMOException - in case of any error

toString

public String toString()


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