org.mule.transport
Class AbstractConnector

java.lang.Object
  extended by org.mule.transport.AbstractConnector
All Implemented Interfaces:
ExceptionListener, EventListener, javax.resource.spi.work.WorkListener, MuleContextAware, Disposable, Initialisable, Lifecycle, Startable, Stoppable, NamedObject, Connectable, Connector
Direct Known Subclasses:
AbstractJndiConnector, AbstractMailConnector, AxisConnector, CxfConnector, FileConnector, FtpConnector, JdbcConnector, JettyHttpConnector, JmsConnector, ProcessConnector, QuartzConnector, ServletConnector, StdioConnector, TcpConnector, UdpConnector, VMConnector, XmppConnector

public abstract class AbstractConnector
extends Object
implements Connector, ExceptionListener, Connectable, javax.resource.spi.work.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  edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicBoolean connected
           
protected  boolean createMultipleTransactedReceivers
           
static int DEFAULT_NUM_CONCURRENT_TX_RECEIVERS
          Default number of concurrent transactional receivers.
protected  MessageDispatcherFactory dispatcherFactory
          Factory used to create dispatchers for this connector
protected  GenericKeyedObjectPool dispatchers
          A pool of dispatchers for this connector, keyed by endpoint
protected  edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicBoolean disposed
           
protected  ExceptionListener exceptionListener
          The exception strategy used by this connector
protected  edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicBoolean initialised
           
protected  Log logger
          logger used by this class
protected  MuleContext muleContext
           
protected  String name
          The name that identifies the endpoint
protected  int numberOfConcurrentTransactedReceivers
           
protected  edu.emory.mathcs.backport.java.util.concurrent.ConcurrentMap receivers
          The collection of listeners on this connector.
protected  MessageRequesterFactory requesterFactory
          Factory used to create requesters for this connector
protected  GenericKeyedObjectPool requesters
          A pool of requesters for this connector, keyed by endpoint
protected  TransportServiceDescriptor serviceDescriptor
          Holds the service configuration for this connector
protected  Properties serviceOverrides
          The map of service overrides that can be used to extend the capabilities of the connector
protected  SessionHandler sessionHandler
          The strategy used for reading and writing session information to and fromt he transport
protected  edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicBoolean started
           
protected  boolean startOnConnect
          Indicates whether the connector should start upon connecting.
 
Fields inherited from interface org.mule.api.transport.Connector
INT_VALUE_NOT_SET
 
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
AbstractConnector()
           
 
Method Summary
protected  void checkDisposed()
           
 void connect()
          Make the connection to the underlying transport.
protected  MessageReceiver createReceiver(Service service, InboundEndpoint endpoint)
          Create a Message receiver for this connector
 void destroyReceiver(MessageReceiver receiver, ImmutableEndpoint endpoint)
           
 void disconnect()
          Disconnect the from the underlying transport
 void dispatch(OutboundEndpoint endpoint, MuleEvent event)
          Dispatches an event from the endpoint to the external system
 void dispose()
          A lifecycle method where implementor should free up any resources.
protected  void disposeDispatchers()
           
protected  void disposeReceivers()
           
protected  void disposeRequesters()
           
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(ServerNotification notification)
          Fires a server notification to all registered listeners
protected  String getConnectEventId()
          The resource id used when firing ConnectEvents from this connector
 String getConnectionDescription()
          Returns a string identifying the underlying resource
 List getDefaultInboundTransformers()
           
 List getDefaultOutboundTransformers()
           
 List getDefaultResponseTransformers()
           
 MessageDispatcherFactory getDispatcherFactory()
          The dispatcher factory is used to create a message dispatcher of the current request
 ThreadingProfile getDispatcherThreadingProfile()
          Getter for property 'dispatcherThreadingProfile'.
protected  WorkManager 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.
 int getMaxRequestersActive()
          Returns the maximum number of requesters that can be concurrently active per endpoint.
 MessageAdapter getMessageAdapter(Object message)
          Gets a MessageAdapter for the endpoint for the given message (data)
 MuleContext getMuleContext()
           
 String getName()
          Gets the name of the object
 int getNumberOfConcurrentTransactedReceivers()
          Returns the number of concurrent receivers that will be launched when isCreateMultipleTransactedReceivers() returns true.
 OutputStream getOutputStream(OutboundEndpoint endpoint, MuleMessage message)
          Will get the output stream for this type of transport.
 MessageReceiver getReceiver(Service service, InboundEndpoint endpoint)
           
protected  Object getReceiverKey(Service service, InboundEndpoint endpoint)
          The method determines the key used to store the receiver against.
 Map getReceivers()
          Getter for property 'receivers'.
 MessageReceiver[] getReceivers(String wildcardExpression)
           
 ThreadingProfile getReceiverThreadingProfile()
          Getter for property 'receiverThreadingProfile'.
protected  WorkManager getReceiverWorkManager(String receiverName)
          Returns a work manager for message receivers.
 ReplyToHandler getReplyToHandler()
          Getter for property 'replyToHandler'.
 MessageRequesterFactory getRequesterFactory()
          The requester factory is used to create a message requester of the current request
 ThreadingProfile getRequesterThreadingProfile()
          Getter for property 'requesterThreadingProfile'.
protected  WorkManager getRequesterWorkManager()
          Returns a work manager for message requesters.
 RetryPolicyTemplate getRetryPolicyTemplate()
           
 edu.emory.mathcs.backport.java.util.concurrent.ScheduledExecutorService getScheduler()
          Returns a Scheduler service for periodic tasks, currently limited to internal use.
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
 SessionHandler getSessionHandler()
          Getter for property 'sessionHandler'.
 List getSupportedProtocols()
          Returns an unmodifiable list of the protocols supported by this connector
 void handleException(Exception exception)
           
 void handleException(Exception exception, Connectable failed)
           
protected  void handleWorkException(javax.resource.spi.work.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.
 void initialiseFromUrl(EndpointURI 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.
protected  void initWorkManagers()
           
 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()
           
protected  boolean isEnableMessageEvents()
           
 boolean isResponseEnabled()
           
 boolean isStarted()
           
 boolean isSyncEnabled(String protocol)
          Used to define is this connectors endpoints' should be synchronous by default rather than using Mule's instance wide default.
 boolean isValidateConnections()
          Whether to test a connection on each take from pool.
 MessageReceiver lookupReceiver(String key)
           
 MessageReceiver registerListener(Service service, InboundEndpoint endpoint)
          This creates a MessageReceiver 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.
 MuleMessage request(InboundEndpoint endpoint, long timeout)
          Make a specific request to the underlying transport
 MuleMessage request(String uri, long timeout)
          Make a specific request to the underlying transport
 MuleMessage send(OutboundEndpoint endpoint, MuleEvent event)
          Sends an event from the endpoint to the external system
 void setConnected(boolean flag)
           
 void setCreateMultipleTransactedReceivers(boolean createMultipleTransactedReceivers)
           
 void setDispatcherFactory(MessageDispatcherFactory dispatcherFactory)
          The dispatcher factory is used to create a message dispatcher of the current request
 void setDispatcherThreadingProfile(ThreadingProfile dispatcherThreadingProfile)
          Setter for property 'dispatcherThreadingProfile'.
 void setDynamicNotification(boolean dynamic)
           
 void setExceptionListener(ExceptionListener listener)
           
 void setMaxDispatchersActive(int maxActive)
          Configures the maximum number of dispatchers that can be concurrently active per endpoint
 void setMaxRequestersActive(int maxActive)
          Configures the maximum number of requesters that can be concurrently active per endpoint
 void setMuleContext(MuleContext context)
           
 void setName(String newName)
          Sets the name of the object
 void setNumberOfConcurrentTransactedReceivers(int count)
           
 void setReceiverThreadingProfile(ThreadingProfile receiverThreadingProfile)
          Setter for property 'receiverThreadingProfile'.
 void setRequesterFactory(MessageRequesterFactory requesterFactory)
          The requester factory is used to create a message requester of the current request
 void setRequesterThreadingProfile(ThreadingProfile requesterThreadingProfile)
          Setter for property 'requesterThreadingProfile'.
 void setRetryPolicyTemplate(RetryPolicyTemplate retryPolicyTemplate)
           
 void setServiceOverrides(Map serviceOverrides)
          Set the Service overrides on this connector.
 void setSessionHandler(SessionHandler sessionHandler)
          Setter for property 'sessionHandler'.
 void setSupportedProtocols(List supportedProtocols)
          Sets A list of protocols that the connector can accept
protected  void setupDispatchReturn(OutboundEndpoint endpoint, MessageDispatcher dispatcher, MuleMessage result)
          This method will return the dispatcher to the pool or, if the payload is an inputstream, replace the payload with a new DelegatingInputStream which returns the dispatcher to the pool when the stream is closed.
protected  void setupRequestReturn(InboundEndpoint endpoint, MessageRequester requester, MuleMessage result)
          This method will return the requester to the pool or, if the payload is an inputstream, replace the payload with a new DelegatingInputStream which returns the requester to the pool when the stream is closed.
 void setValidateConnections(boolean validateConnections)
          Whether to test a connection on each take.
 void start()
           
 void stop()
           
 boolean supportsProtocol(String protocol)
           
 String toString()
           
 void unregisterListener(Service service, InboundEndpoint endpoint)
           
 void unregisterSupportedProtocol(String protocol)
           
protected  void updateCachedNotificationHandler()
           
 RetryContext validateConnection(RetryContext retryContext)
          Override this method to test whether the connector is able to connect to its resource(s).
 void workAccepted(javax.resource.spi.work.WorkEvent event)
           
 void workCompleted(javax.resource.spi.work.WorkEvent event)
           
 void workRejected(javax.resource.spi.work.WorkEvent event)
           
 void workStarted(javax.resource.spi.work.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.api.transport.Connector
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


name

protected volatile String name
The name that identifies the endpoint


exceptionListener

protected volatile ExceptionListener exceptionListener
The exception strategy used by this connector


dispatcherFactory

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


requesterFactory

protected volatile MessageRequesterFactory requesterFactory
Factory used to create requesters for this connector


dispatchers

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


requesters

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


receivers

protected final edu.emory.mathcs.backport.java.util.concurrent.ConcurrentMap receivers
The collection of listeners on this connector. Keyed by entrypoint


createMultipleTransactedReceivers

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

numberOfConcurrentTransactedReceivers

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

serviceDescriptor

protected volatile TransportServiceDescriptor serviceDescriptor
Holds the service configuration for this connector


serviceOverrides

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


sessionHandler

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


muleContext

protected MuleContext muleContext

initialised

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

connected

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

started

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

disposed

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

startOnConnect

protected boolean startOnConnect
Indicates whether the connector should start upon connecting. This is necessary to support asynchronous retry policies, otherwise the start() method would block until connection is successful.

Constructor Detail

AbstractConnector

public AbstractConnector()
Method Detail

getName

public String getName()
Description copied from interface: NamedObject
Gets the name of the object

Specified by:
getName in interface NamedObject
Returns:
the name of the object

setName

public void setName(String newName)
Description copied from interface: NamedObject
Sets the name of the object

Specified by:
setName in interface NamedObject
Parameters:
newName - the name of the object

initialise

public final void initialise()
                      throws InitialisationException
Description copied from interface: Initialisable
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

start

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

isStarted

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

stop

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

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

initWorkManagers

protected void initWorkManagers()
                         throws MuleException
Throws:
MuleException

disposeWorkManagers

protected void disposeWorkManagers()

disposeReceivers

protected void disposeReceivers()

disposeDispatchers

protected void disposeDispatchers()

disposeRequesters

protected void disposeRequesters()

isDisposed

public boolean isDisposed()
Specified by:
isDisposed in interface Connector
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 Connector
Parameters:
exception - the exception that was caught

handleException

public void handleException(Exception exception,
                            Connectable failed)

exceptionThrown

public void exceptionThrown(Exception e)
Specified by:
exceptionThrown in interface ExceptionListener

getExceptionListener

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

setExceptionListener

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

getDispatcherFactory

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

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

setDispatcherFactory

public void setDispatcherFactory(MessageDispatcherFactory dispatcherFactory)
Description copied from interface: Connector
The dispatcher factory is used to create a message dispatcher of the current request

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

getRequesterFactory

public MessageRequesterFactory getRequesterFactory()
Description copied from interface: Connector
The requester factory is used to create a message requester of the current request

Specified by:
getRequesterFactory in interface Connector
Returns:
Returns the requesterFactory.

setRequesterFactory

public void setRequesterFactory(MessageRequesterFactory requesterFactory)
Description copied from interface: Connector
The requester factory is used to create a message requester of the current request

Specified by:
setRequesterFactory in interface Connector
Parameters:
requesterFactory - The requesterFactory 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

getMaxRequestersActive

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

Returns:
max. number of active requesters

setMaxRequestersActive

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

Parameters:
maxActive - max. number of active requesters

checkDisposed

protected void checkDisposed()
                      throws DisposeException
Throws:
DisposeException

registerListener

public MessageReceiver registerListener(Service service,
                                        InboundEndpoint endpoint)
                                 throws Exception
Description copied from interface: Connector
This creates a MessageReceiver associated with this endpoint and registers it with the connector

Specified by:
registerListener in interface Connector
Parameters:
service - the listening service
endpoint - the endpoint contains the listener endpointUri on which to listen on.
Throws:
Exception - if the MessageReceiver cannot be created or the Receiver cannot be registered

getReceiverKey

protected Object getReceiverKey(Service service,
                                InboundEndpoint endpoint)
The method determines the key used to store the receiver against.

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

unregisterListener

public final void unregisterListener(Service service,
                                     InboundEndpoint endpoint)
                              throws Exception
Specified by:
unregisterListener in interface Connector
Parameters:
service - the listening service
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'.

getRequesterThreadingProfile

public ThreadingProfile getRequesterThreadingProfile()
Getter for property 'requesterThreadingProfile'.

Returns:
Value for property 'requesterThreadingProfile'.

setRequesterThreadingProfile

public void setRequesterThreadingProfile(ThreadingProfile requesterThreadingProfile)
Setter for property 'requesterThreadingProfile'.

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

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

public void destroyReceiver(MessageReceiver receiver,
                            ImmutableEndpoint 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 MuleException
Template method to perform any work when starting the connectoe

Throws:
MuleException - if the method fails

doStop

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

Throws:
MuleException - if the method fails

getDefaultInboundTransformers

public List getDefaultInboundTransformers()

getDefaultResponseTransformers

public List getDefaultResponseTransformers()

getDefaultOutboundTransformers

public List getDefaultOutboundTransformers()

getReplyToHandler

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

Returns:
Value for property 'replyToHandler'.

fireNotification

public void fireNotification(ServerNotification notification)
Fires a server notification to all registered listeners

Parameters:
notification - the notification to fire.

isResponseEnabled

public boolean isResponseEnabled()
Specified by:
isResponseEnabled in interface Connector

isSyncEnabled

public boolean isSyncEnabled(String protocol)
Description copied from interface: Connector
Used to define is this connectors endpoints' should be synchronous by default rather than using Mule's instance wide default. The endpoint is passed through to this method so that transports like Axis/CXF can determine if synchronous should be default depending on the endpoint transport e.g. http/vm/jms etc.

Specified by:
isSyncEnabled in interface Connector
Returns:
See Also:
ImmutableEndpoint.isSynchronous()

getReceiver

public MessageReceiver getReceiver(Service service,
                                   InboundEndpoint endpoint)

getReceivers

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

Returns:
Value for property 'receivers'.

lookupReceiver

public MessageReceiver lookupReceiver(String key)

getReceivers

public MessageReceiver[] getReceivers(String wildcardExpression)

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

validateConnection

public RetryContext validateConnection(RetryContext retryContext)
Override this method to test whether the connector is able to connect to its resource(s). This will allow a retry policy to go into effect in the case of failure.

Specified by:
validateConnection in interface Connectable
Returns:
retry context with a success flag or failure details
See Also:
RetryContext.isOk(), RetryContext.getLastFailure()

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:

isConnected

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

Specified by:
isConnected in interface Connectable
Specified by:
isConnected in interface Connector

setConnected

public final void setConnected(boolean flag)

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:
#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:
#getNumberOfConcurrentTransactedReceivers()}

setDynamicNotification

public void setDynamicNotification(boolean dynamic)

updateCachedNotificationHandler

protected void updateCachedNotificationHandler()

isEnableMessageEvents

protected boolean isEnableMessageEvents()

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 Connector
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 WorkManager getReceiverWorkManager(String receiverName)
                                      throws MuleException
Returns a work manager for message receivers.

Throws:
MuleException

getDispatcherWorkManager

protected WorkManager getDispatcherWorkManager()
                                        throws MuleException
Returns a work manager for message dispatchers.

Throws:
MuleException - in case of error

getRequesterWorkManager

protected WorkManager getRequesterWorkManager()
                                       throws MuleException
Returns a work manager for message requesters.

Throws:
MuleException - in case of error

getScheduler

public edu.emory.mathcs.backport.java.util.concurrent.ScheduledExecutorService getScheduler()
Returns a Scheduler service for periodic tasks, currently limited to internal use. Note: getScheduler() currently conflicts with the same method in the Quartz transport


getSessionHandler

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

Returns:
Value for property 'sessionHandler'.

setSessionHandler

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

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

workAccepted

public void workAccepted(javax.resource.spi.work.WorkEvent event)
Specified by:
workAccepted in interface javax.resource.spi.work.WorkListener

workRejected

public void workRejected(javax.resource.spi.work.WorkEvent event)
Specified by:
workRejected in interface javax.resource.spi.work.WorkListener

workStarted

public void workStarted(javax.resource.spi.work.WorkEvent event)
Specified by:
workStarted in interface javax.resource.spi.work.WorkListener

workCompleted

public void workCompleted(javax.resource.spi.work.WorkEvent event)
Specified by:
workCompleted in interface javax.resource.spi.work.WorkListener

handleWorkException

protected void handleWorkException(javax.resource.spi.work.WorkEvent event,
                                   String type)

dispatch

public void dispatch(OutboundEndpoint endpoint,
                     MuleEvent event)
              throws DispatchException
Description copied from interface: Connector
Dispatches an event from the endpoint to the external system

Specified by:
dispatch in interface Connector
event - The event to dispatch
Throws:
DispatchException - if the event fails to be dispatched

setupDispatchReturn

protected void setupDispatchReturn(OutboundEndpoint endpoint,
                                   MessageDispatcher dispatcher,
                                   MuleMessage result)
This method will return the dispatcher to the pool or, if the payload is an inputstream, replace the payload with a new DelegatingInputStream which returns the dispatcher to the pool when the stream is closed.

Parameters:
endpoint -
dispatcher -
result -

request

public MuleMessage request(String uri,
                           long timeout)
                    throws Exception
Description copied from interface: Connector
Make a specific request to the underlying transport

Specified by:
request in interface Connector
Parameters:
uri - 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 MuleMessage object. Null will be returned if no data was avaialable
Throws:
Exception - if the call to the underlying protocal cuases an exception

request

public MuleMessage request(InboundEndpoint endpoint,
                           long timeout)
                    throws Exception
Description copied from interface: Connector
Make a specific request to the underlying transport

Specified by:
request in interface Connector
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 MuleMessage object. Null will be returned if no data was avaialable
Throws:
Exception - if the call to the underlying protocal cuases an exception

setupRequestReturn

protected void setupRequestReturn(InboundEndpoint endpoint,
                                  MessageRequester requester,
                                  MuleMessage result)
This method will return the requester to the pool or, if the payload is an inputstream, replace the payload with a new DelegatingInputStream which returns the requester to the pool when the stream is closed.

Parameters:
endpoint -
requester -
result -

send

public MuleMessage send(OutboundEndpoint endpoint,
                        MuleEvent event)
                 throws DispatchException
Description copied from interface: Connector
Sends an event from the endpoint to the external system

Specified by:
send in interface Connector
event - The event to send
Returns:
event the response form the external system wrapped in a MuleEvent
Throws:
DispatchException - if the event fails to be dispatched

initialiseFromUrl

public void initialiseFromUrl(EndpointURI 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 EndpointURI 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 MessageReceiver createReceiver(Service service,
                                         InboundEndpoint endpoint)
                                  throws Exception
Create a Message receiver for this connector

Parameters:
service - the service 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 service 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 MessageAdapter getMessageAdapter(Object message)
                                 throws MessagingException
Gets a MessageAdapter for the endpoint for the given message (data)

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

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(OutboundEndpoint endpoint,
                                    MuleMessage message)
                             throws MuleException
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 Connector
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:
MuleException - in case of any error

getMuleContext

public MuleContext getMuleContext()
Specified by:
getMuleContext in interface Connector

setMuleContext

public void setMuleContext(MuleContext context)
Specified by:
setMuleContext in interface MuleContextAware

toString

public String toString()
Overrides:
toString in class Object

getRetryPolicyTemplate

public RetryPolicyTemplate getRetryPolicyTemplate()
Specified by:
getRetryPolicyTemplate in interface Connector

setRetryPolicyTemplate

public void setRetryPolicyTemplate(RetryPolicyTemplate retryPolicyTemplate)

isValidateConnections

public boolean isValidateConnections()
Whether to test a connection on each take from pool.


setValidateConnections

public void setValidateConnections(boolean validateConnections)
Whether to test a connection on each take. A result is higher availability at the expense of a potential slight performance hit (when a test connection is made) or be very lightweight in other cases (like sending a hearbeat ping to the server).

Disable to obtain slight performance gain or if you are absolutely sure of the server availability.

It is up to the transport implementatin to support such validation, thus it should be considered a hint only.

The default value is true



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