|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.mule.providers.AbstractConnector
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.
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 -
| Field Summary | |
protected WaitableBoolean |
connected
|
protected WaitableBoolean |
connecting
|
protected boolean |
createDispatcherPerRequest
Determines whether dispatchers should be disposed straight away of after every request or cached |
protected boolean |
createMultipleTransactedReceivers
For better throughput when using TransactedMessageReceivers. |
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 ConcurrentMap |
dispatchers
A pool of dispa tchers for this connector, the pool is keyed on endpointUri |
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 ConcurrentMap |
receivers
The collection of listeners on this connector. |
protected boolean |
serverSide
The flag determines if the connector is being used on the server side or client. |
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()
|
|
| Method Summary | |
protected void |
checkDisposed()
|
void |
connect()
Make the connection to the underlying transport. |
protected UMOMessageDispatcher |
createDispatcher(UMOImmutableEndpoint endpoint)
|
abstract UMOMessageReceiver |
createReceiver(UMOComponent component,
UMOEndpoint endpoint)
|
void |
destroyReceiver(UMOMessageReceiver receiver,
UMOEndpoint endpoint)
|
void |
disconnect()
Disconnect the from the underlying transport |
void |
dispose()
A lifecycle method where implementor should free up any resources. |
protected void |
disposeDispatchers()
|
protected void |
disposeReceivers()
|
void |
doConnect()
Template method where any connections should be made for the connector |
void |
doDisconnect()
Template method where any connected resources used by the connector should be disconnected |
protected void |
doDispose()
Template method to perform any work when destroying the connectoe |
void |
doInitialise()
|
protected void |
doStart()
Template method to perform any work when starting the connectoe |
protected 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()
|
UMOTransformer |
getDefaultInboundTransformer()
|
UMOTransformer |
getDefaultOutboundTransformer()
|
UMOTransformer |
getDefaultResponseTransformer()
|
UMOMessageDispatcher |
getDispatcher(UMOImmutableEndpoint endpoint)
The connector can pool dispatchers based on their endpointUri or can ingnore the endpointUri altogether and use a ThreadLocal or always create new. |
UMOMessageDispatcher |
getDispatcher(UMOImmutableEndpoint endpoint,
boolean createDispatcherIfNotExists)
|
UMOMessageDispatcherFactory |
getDispatcherFactory()
The dispatcher factory is used to create a message dispatcher of the current request |
Map |
getDispatchers()
Deprecated. this method will go away soon. |
ThreadingProfile |
getDispatcherThreadingProfile()
|
ExceptionListener |
getExceptionListener()
|
String |
getName()
|
abstract String |
getProtocol()
|
AbstractMessageReceiver |
getReceiver(String key)
Deprecated. Use lookupReceiver instead |
AbstractMessageReceiver |
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()
|
AbstractMessageReceiver[] |
getReceivers(String wildcardExpression)
|
ThreadingProfile |
getReceiverThreadingProfile()
|
ReplyToHandler |
getReplyToHandler()
|
UMOSessionHandler |
getSessionHandler()
|
List |
getSupportedProtocols()
Returns an unmodifiable list of the protocols supported by this connector |
void |
handleException(Exception exception)
|
protected void |
handleWorkException(WorkEvent event,
String type)
|
void |
initialise()
Method used to perform any initialisation work. |
boolean |
isConnected()
Determines if this object is connected or not |
boolean |
isCreateDispatcherPerRequest()
controls whether dispatchers or cached or created per request Note that if an exception occurs in the Dispatcher it is automatically disposed of and a new one is created for the next request. |
boolean |
isCreateMultipleTransactedReceivers()
For better throughput when using TransactedMessageReceivers. |
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 |
isServerSide()
The flag determines if the connector is being used on the server side or client. |
boolean |
isStarted()
|
boolean |
isUseSingleDispatcherThreadPool()
Should a single dispatcher thread pool be created for all distachers It is recommended that if you have a lot of dispatcher being created per connector that this should be set to true i.e. |
boolean |
isUseSingleReceiverThreadPool()
Should a single receiver thread pool be created for all receivers It is recommended that if you have a lot of receivers being registered per connector that this should be set to true |
UMOMessageDispatcher |
lookupDispatcher(String key)
|
UMOMessageReceiver |
lookupReceiver(String key)
|
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 |
registerSupportedProtocolWithotPrefix(String protocol)
Registers other protocols 'understood' by this connector. |
void |
setConnectionStrategy(ConnectionStrategy connectionStrategy)
|
void |
setCreateDispatcherPerRequest(boolean createDispatcherPerRequest)
controls whether dispatchers or cached or created per request Note that if an exception occurs in the Dispatcher it is automatically disposed of and a new one is created for the next request. |
void |
setCreateMultipleTransactedReceivers(boolean createMultipleTransactedReceivers)
For better throughput when using TransactedMessageReceivers. |
void |
setDefaultInboundTransformer(UMOTransformer defaultInboundTransformer)
|
void |
setDefaultOutboundTransformer(UMOTransformer defaultOutboundTransformer)
|
void |
setDefaultResponseTransformer(UMOTransformer defaultResponseTransformer)
|
void |
setDispatcherFactory(UMOMessageDispatcherFactory dispatcherFactory)
The dispatcher factory is used to create a message dispatcher of the current request |
void |
setDispatcherThreadingProfile(ThreadingProfile 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 |
setName(String newName)
|
void |
setReceiverThreadingProfile(ThreadingProfile receiverThreadingProfile)
|
void |
setServerSide(boolean serverSide)
The flag determines if the connector is being used on the server side or client. |
void |
setSessionHandler(UMOSessionHandler sessionHandler)
|
void |
setSupportedProtocols(List supportedProtocols)
Sets A list of protocols that the connector can accept |
void |
setUseSingleDispatcherThreadPool(boolean useSingleDispatcherThreadPool)
Should a single dispatcher thread pool be created for all distachers It is recommended that if you have a lot of dispatcher being created per connector that this should be set to true i.e. |
void |
setUseSingleReceiverThreadPool(boolean useSingleReceiverThreadPool)
Should a single dispatcher thread pool be created for all recivers It is recommended that if you have a lot of receivers being registered per connector that this should be set to true |
void |
startConnector()
|
void |
stopConnector()
|
boolean |
supportsProtocol(String protocol)
|
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, toString, wait, wait, wait |
| Methods inherited from interface org.mule.umo.provider.UMOConnector |
getMessageAdapter, getStreamMessageAdapter |
| Field Detail |
protected transient Log logger
protected AtomicBoolean started
protected AtomicBoolean initialised
protected String name
protected ExceptionListener exceptionListener
protected AtomicBoolean disposed
protected AtomicBoolean disposing
protected UMOMessageDispatcherFactory dispatcherFactory
protected ConcurrentMap dispatchers
protected ConcurrentMap receivers
protected boolean createDispatcherPerRequest
protected boolean createMultipleTransactedReceivers
protected UMOTransformer defaultInboundTransformer
protected UMOTransformer defaultOutboundTransformer
protected UMOTransformer defaultResponseTransformer
protected WaitableBoolean connected
protected WaitableBoolean connecting
protected WaitableBoolean startOnConnect
protected boolean serverSide
protected UMOSessionHandler sessionHandler
| Constructor Detail |
public AbstractConnector()
| Method Detail |
public String getName()
getName in interface UMOConnectorpublic void setName(String newName)
setName in interface UMOConnectornewName - the name to associate with the endpoint
public final void initialise()
throws InitialisationException
InitialisableInitialisationException 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.
initialise in interface InitialisableInitialisationException - if a fatal error occurs causing the Mule
instance to shutdownpublic abstract String getProtocol()
getProtocol in interface UMOConnector
public final void startConnector()
throws UMOException
startConnector in interface UMOConnectorUMOExceptionpublic boolean isStarted()
isStarted in interface UMOConnector
public final void stopConnector()
throws UMOException
stopConnector in interface UMOConnectorUMOExceptionpublic final void dispose()
Disposable
dispose in interface Disposableprotected void disposeReceivers()
protected void disposeDispatchers()
public boolean isDisposed()
isDisposed in interface UMOConnectorpublic void handleException(Exception exception)
handleException in interface UMOConnectorexception - the exception that was caughtpublic void exceptionThrown(Exception e)
exceptionThrown in interface ExceptionListenerpublic ExceptionListener getExceptionListener()
getExceptionListener in interface UMOConnectorExceptionListenerpublic void setExceptionListener(ExceptionListener listener)
setExceptionListener in interface UMOConnectorlistener - the ExceptionStrategy to use with this endpointExceptionListenerpublic UMOMessageDispatcherFactory getDispatcherFactory()
UMOConnector
getDispatcherFactory in interface UMOConnectorpublic void setDispatcherFactory(UMOMessageDispatcherFactory dispatcherFactory)
UMOConnector
setDispatcherFactory in interface UMOConnectordispatcherFactory - The dispatcherFactory to set.
public UMOMessageDispatcher getDispatcher(UMOImmutableEndpoint endpoint)
throws UMOException
UMOConnector
getDispatcher in interface UMOConnectorendpoint - the endpoint that can be used to key cached dispatchers
UMOException - if creation of a component fails
public UMOMessageDispatcher getDispatcher(UMOImmutableEndpoint endpoint,
boolean createDispatcherIfNotExists)
throws UMOException
UMOExceptionpublic UMOMessageDispatcher lookupDispatcher(String key)
protected void checkDisposed()
throws DisposeException
DisposeException
protected UMOMessageDispatcher createDispatcher(UMOImmutableEndpoint endpoint)
throws UMOException
UMOException
public UMOMessageReceiver registerListener(UMOComponent component,
UMOEndpoint endpoint)
throws Exception
UMOConnectorUMOMessageReceiver associated with this endpoint
and registers it with the connector
registerListener in interface UMOConnectorcomponent - the listening componentendpoint - the endpoint contains the listener endpointUri on which to
listen on.
Exception - if the UMOMessageReceiver cannot be created or the Receiver
cannot be registered
protected Object getReceiverKey(UMOComponent component,
UMOEndpoint endpoint)
component - the component for which the endpoint is being registeredendpoint - the endpoint being registered for the component
public final void unregisterListener(UMOComponent component,
UMOEndpoint endpoint)
throws Exception
unregisterListener in interface UMOConnectorcomponent - the listening componentendpoint - the associated endpointDescriptor with the listener
Exception - if the listener cannot be unregistered. If a listener is not
associated with the given endpoint this will not throw an
exceptionpublic ThreadingProfile getDispatcherThreadingProfile()
public void setDispatcherThreadingProfile(ThreadingProfile dispatcherThreadingProfile)
public ThreadingProfile getReceiverThreadingProfile()
public void setReceiverThreadingProfile(ThreadingProfile receiverThreadingProfile)
public abstract UMOMessageReceiver createReceiver(UMOComponent component,
UMOEndpoint endpoint)
throws Exception
Exception
public void destroyReceiver(UMOMessageReceiver receiver,
UMOEndpoint endpoint)
throws Exception
Exception
protected void doStart()
throws UMOException
UMOException - if the method fails
protected void doStop()
throws UMOException
UMOException - if the method failsprotected void doDispose()
public void doInitialise()
throws InitialisationException
InitialisationExceptionpublic UMOTransformer getDefaultInboundTransformer()
public void setDefaultInboundTransformer(UMOTransformer defaultInboundTransformer)
public UMOTransformer getDefaultResponseTransformer()
public UMOTransformer getDefaultOutboundTransformer()
public void setDefaultOutboundTransformer(UMOTransformer defaultOutboundTransformer)
public void setDefaultResponseTransformer(UMOTransformer defaultResponseTransformer)
public ReplyToHandler getReplyToHandler()
public Map getDispatchers()
public void fireNotification(UMOServerNotification notification)
CustomNotificationListener
eventManager.
notification - the notification to fire. This must be of type
CustomNotification
otherwise an exception will be thrown.
UnsupportedOperationException - if the notification fired is not a
CustomNotificationpublic ConnectionStrategy getConnectionStrategy()
public void setConnectionStrategy(ConnectionStrategy connectionStrategy)
public boolean isDisposing()
isDisposing in interface UMOConnectorpublic boolean isRemoteSyncEnabled()
isRemoteSyncEnabled in interface UMOConnector
public AbstractMessageReceiver getReceiver(UMOComponent component,
UMOEndpoint endpoint)
public Map getReceivers()
public UMOMessageReceiver lookupReceiver(String key)
public AbstractMessageReceiver getReceiver(String key)
public AbstractMessageReceiver[] getReceivers(String wildcardExpression)
public void connect()
throws Exception
UMOConnectable
connect in interface UMOConnectableException
public void disconnect()
throws Exception
UMOConnectable
disconnect in interface UMOConnectableExceptionpublic String getConnectionDescription()
UMOConnectable
getConnectionDescription in interface UMOConnectablepublic final boolean isConnected()
UMOConnectable
isConnected in interface UMOConnectable
public void doConnect()
throws Exception
Exception
public void doDisconnect()
throws Exception
Exceptionprotected String getConnectEventId()
public void setCreateDispatcherPerRequest(boolean createDispatcherPerRequest)
createDispatcherPerRequest - whether a new dispatcher is created for
every request or notpublic boolean isCreateDispatcherPerRequest()
public boolean isCreateMultipleTransactedReceivers()
public void setCreateMultipleTransactedReceivers(boolean createMultipleTransactedReceivers)
createMultipleTransactedReceivers - true if multiple receiver threads
will be created for receivers on this connectionpublic boolean isEnableMessageEvents()
public void setEnableMessageEvents(boolean enableMessageEvents)
enableMessageEvents - public void registerSupportedProtocol(String protocol)
protocol - the supported protocol to registerprotected void registerSupportedProtocolWithotPrefix(String protocol)
registerSupportedProtolcol 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.
protocol - the supported protocol to registerpublic void unregisterSupportedProtocol(String protocol)
public boolean supportsProtocol(String protocol)
supportsProtocol in interface UMOConnectorpublic List getSupportedProtocols()
public void setSupportedProtocols(List supportedProtocols)
supportedProtocols - public boolean isUseSingleReceiverThreadPool()
public void setUseSingleReceiverThreadPool(boolean useSingleReceiverThreadPool)
useSingleReceiverThreadPool - true is a single thread pool is being used
for all receivers on this connectorpublic boolean isUseSingleDispatcherThreadPool()
public void setUseSingleDispatcherThreadPool(boolean useSingleDispatcherThreadPool)
useSingleDispatcherThreadPool - true is a single thread pool is being
used for all dispatchers on this connectorpublic boolean isServerSide()
public void setServerSide(boolean serverSide)
serverSide - true if running on the server sidepublic UMOSessionHandler getSessionHandler()
public void setSessionHandler(UMOSessionHandler sessionHandler)
public void workAccepted(WorkEvent event)
public void workRejected(WorkEvent event)
public void workStarted(WorkEvent event)
public void workCompleted(WorkEvent event)
protected void handleWorkException(WorkEvent event,
String type)
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||