org.mule.providers
Class KeyedPoolMessageDispatcherFactoryAdapter

java.lang.Object
  extended by org.mule.providers.KeyedPoolMessageDispatcherFactoryAdapter
All Implemented Interfaces:
KeyedPoolableObjectFactory, UMOMessageDispatcherFactory

public class KeyedPoolMessageDispatcherFactoryAdapter
extends Object
implements UMOMessageDispatcherFactory, KeyedPoolableObjectFactory

KeyedPoolMessageDispatcherFactoryAdapter adapts a UMOMessageDispatcherFactory 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(UMOMessageDispatcherFactory factory)
           
 
Method Summary
 void activate(UMOImmutableEndpoint endpoint, UMOMessageDispatcher dispatcher)
          Invoked before the given dispatcher is handed out to a client, but not after UMOMessageDispatcherFactory.create(UMOImmutableEndpoint).
 void activateObject(Object key, Object obj)
           
 UMOMessageDispatcher create(UMOImmutableEndpoint endpoint)
          Creates a new message dispatcher instance, initialised with the passed endpoint.
 void destroy(UMOImmutableEndpoint endpoint, UMOMessageDispatcher dispatcher)
          Invoked when a dispatcher returned false for UMOMessageDispatcherFactory.validate(UMOImmutableEndpoint, UMOMessageDispatcher).
 void destroyObject(Object key, Object obj)
           
 boolean isCreateDispatcherPerRequest()
          Controls whether dispatchers are cached or created per request.
 Object makeObject(Object key)
           
 void passivate(UMOImmutableEndpoint endpoint, UMOMessageDispatcher dispatcher)
          Invoked immediately before the given dispatcher is returned to its pool.
 void passivateObject(Object key, Object obj)
           
 boolean validate(UMOImmutableEndpoint endpoint, UMOMessageDispatcher dispatcher)
          Invoked after the dispatcher is returned from a client but before it is prepared for return to its pool via UMOMessageDispatcherFactory.passivate(UMOImmutableEndpoint, UMOMessageDispatcher).
 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(UMOMessageDispatcherFactory 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: UMOMessageDispatcherFactory
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 UMOMessageDispatcherFactory.validate(UMOImmutableEndpoint, UMOMessageDispatcher) it takes precedence over the dispatcher's own return value of UMOMessageDispatcher.validate().

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

create

public UMOMessageDispatcher create(UMOImmutableEndpoint endpoint)
                            throws UMOException
Description copied from interface: UMOMessageDispatcherFactory
Creates a new message dispatcher instance, initialised with the passed endpoint. The returned instance should be immediately useable.

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

activate

public void activate(UMOImmutableEndpoint endpoint,
                     UMOMessageDispatcher dispatcher)
              throws UMOException
Description copied from interface: UMOMessageDispatcherFactory
Invoked before the given dispatcher is handed out to a client, but not after UMOMessageDispatcherFactory.create(UMOImmutableEndpoint).

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

destroy

public void destroy(UMOImmutableEndpoint endpoint,
                    UMOMessageDispatcher dispatcher)
Description copied from interface: UMOMessageDispatcherFactory
Invoked when a dispatcher returned false for UMOMessageDispatcherFactory.validate(UMOImmutableEndpoint, UMOMessageDispatcher).

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

passivate

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

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

validate

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

Specified by:
validate in interface UMOMessageDispatcherFactory
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-2008 MuleSource, Inc.. All Rights Reserved.