org.mule.transport
Class KeyedPoolMessageDispatcherFactoryAdapter

java.lang.Object
  extended by org.mule.transport.KeyedPoolMessageDispatcherFactoryAdapter
All Implemented Interfaces:
KeyedPoolableObjectFactory, MessageDispatcherFactory

public class KeyedPoolMessageDispatcherFactoryAdapter
extends Object
implements MessageDispatcherFactory, KeyedPoolableObjectFactory

KeyedPoolMessageDispatcherFactoryAdapter adapts a MessageDispatcherFactory with methods from commons-pool KeyedPoolableObjectFactory. It is only required for dispatcher factories that do not inherit from AbstractMessageDispatcherFactory.

See Also:
AbstractMessageDispatcherFactory

Constructor Summary
KeyedPoolMessageDispatcherFactoryAdapter(MessageDispatcherFactory factory)
           
 
Method Summary
 void activate(OutboundEndpoint endpoint, MessageDispatcher dispatcher)
          Invoked before the given dispatcher is handed out to a client, but not after MessageDispatcherFactory.create(OutboundEndpoint).
 void activateObject(Object key, Object obj)
           
 MessageDispatcher create(OutboundEndpoint endpoint)
          Creates a new message dispatcher instance, initialised with the passed endpoint.
 void destroy(OutboundEndpoint endpoint, MessageDispatcher dispatcher)
          Invoked when a dispatcher returned false for MessageDispatcherFactory.validate(OutboundEndpoint, MessageDispatcher).
 void destroyObject(Object key, Object obj)
           
 boolean isCreateDispatcherPerRequest()
          Controls whether dispatchers are cached or created per request.
 Object makeObject(Object key)
           
 void passivate(OutboundEndpoint endpoint, MessageDispatcher dispatcher)
          Invoked immediately before the given dispatcher is returned to its pool.
 void passivateObject(Object key, Object obj)
           
 boolean validate(OutboundEndpoint endpoint, MessageDispatcher dispatcher)
          Invoked after the dispatcher is returned from a client but before it is prepared for return to its pool via MessageDispatcherFactory.passivate(OutboundEndpoint, MessageDispatcher).
 boolean validateObject(Object key, Object obj)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

KeyedPoolMessageDispatcherFactoryAdapter

public KeyedPoolMessageDispatcherFactoryAdapter(MessageDispatcherFactory factory)
Method Detail

activateObject

public void activateObject(Object key,
                           Object obj)
                    throws Exception
Specified by:
activateObject in interface KeyedPoolableObjectFactory
Throws:
Exception

destroyObject

public void destroyObject(Object key,
                          Object obj)
                   throws Exception
Specified by:
destroyObject in interface KeyedPoolableObjectFactory
Throws:
Exception

makeObject

public Object makeObject(Object key)
                  throws Exception
Specified by:
makeObject in interface KeyedPoolableObjectFactory
Throws:
Exception

passivateObject

public void passivateObject(Object key,
                            Object obj)
                     throws Exception
Specified by:
passivateObject in interface KeyedPoolableObjectFactory
Throws:
Exception

validateObject

public boolean validateObject(Object key,
                              Object obj)
Specified by:
validateObject in interface KeyedPoolableObjectFactory

isCreateDispatcherPerRequest

public boolean isCreateDispatcherPerRequest()
Description copied from interface: MessageDispatcherFactory
Controls whether dispatchers are 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. This allows dispatchers to recover from loss of connection and other faults. When invoked by MessageDispatcherFactory.validate(OutboundEndpoint, MessageDispatcher) it takes precedence over the dispatcher's own return value of MessageDispatcher.validate().

Specified by:
isCreateDispatcherPerRequest in interface MessageDispatcherFactory
Returns:
true if created per request

create

public MessageDispatcher create(OutboundEndpoint endpoint)
                         throws MuleException
Description copied from interface: MessageDispatcherFactory
Creates a new message dispatcher instance, initialised with the passed endpoint. The returned instance should be immediately useable.

Specified by:
create in interface MessageDispatcherFactory
Parameters:
endpoint - the endoint for which this dispatcher should be created
Returns:
a properly created MessageDispatcher for this transport
Throws:
MuleException - if the dispatcher cannot be created

activate

public void activate(OutboundEndpoint endpoint,
                     MessageDispatcher dispatcher)
              throws MuleException
Description copied from interface: MessageDispatcherFactory
Invoked before the given dispatcher is handed out to a client, but not after MessageDispatcherFactory.create(OutboundEndpoint).

Specified by:
activate in interface MessageDispatcherFactory
Parameters:
endpoint - the endpoint of the dispatcher
dispatcher - the dispatcher to be activated
Throws:
MuleException - if the dispatcher cannot be activated

destroy

public void destroy(OutboundEndpoint endpoint,
                    MessageDispatcher dispatcher)
Description copied from interface: MessageDispatcherFactory
Invoked when a dispatcher returned false for MessageDispatcherFactory.validate(OutboundEndpoint, MessageDispatcher).

Specified by:
destroy in interface MessageDispatcherFactory
Parameters:
endpoint - the endpoint of the dispatcher
dispatcher - the dispatcher to be validated

passivate

public void passivate(OutboundEndpoint endpoint,
                      MessageDispatcher dispatcher)
Description copied from interface: MessageDispatcherFactory
Invoked immediately before the given dispatcher is returned to its pool.

Specified by:
passivate in interface MessageDispatcherFactory
Parameters:
endpoint - the endpoint of the dispatcher
dispatcher - the dispatcher to be passivated

validate

public boolean validate(OutboundEndpoint endpoint,
                        MessageDispatcher dispatcher)
Description copied from interface: MessageDispatcherFactory
Invoked after the dispatcher is returned from a client but before it is prepared for return to its pool via MessageDispatcherFactory.passivate(OutboundEndpoint, MessageDispatcher).

Specified by:
validate in interface MessageDispatcherFactory
Parameters:
endpoint - the endpoint of the dispatcher
dispatcher - the dispatcher to be validated
Returns:
true if the dispatcher is valid for reuse, false otherwise.


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