org.mule.transport
Class KeyedPoolMessageRequesterFactoryAdapter

java.lang.Object
  extended by org.mule.transport.KeyedPoolMessageRequesterFactoryAdapter
All Implemented Interfaces:
KeyedPoolableObjectFactory, MessageRequesterFactory

public class KeyedPoolMessageRequesterFactoryAdapter
extends Object
implements MessageRequesterFactory, KeyedPoolableObjectFactory

KeyedPoolMessageRequesterFactoryAdapter adapts a MessageRequesterFactory with methods from commons-pool KeyedPoolableObjectFactory. It is only required for requester factories that do not inherit from AbstractMessageRequesterFactory.

See Also:
AbstractMessageRequesterFactory

Constructor Summary
KeyedPoolMessageRequesterFactoryAdapter(MessageRequesterFactory factory)
           
 
Method Summary
 void activate(InboundEndpoint endpoint, MessageRequester requester)
          Invoked before the given requester is handed out to a client, but not after MessageRequesterFactory.create(org.mule.api.endpoint.InboundEndpoint).
 void activateObject(Object key, Object obj)
           
 MessageRequester create(InboundEndpoint endpoint)
          Creates a new message requester instance, initialised with the passed endpoint.
 void destroy(InboundEndpoint endpoint, MessageRequester requester)
          Invoked when a requester returned false for MessageRequesterFactory.validate(org.mule.api.endpoint.InboundEndpoint, org.mule.api.transport.MessageRequester).
 void destroyObject(Object key, Object obj)
           
 boolean isCreateRequesterPerRequest()
          Controls whether dispatchers are cached or created per request.
 Object makeObject(Object key)
           
 void passivate(InboundEndpoint endpoint, MessageRequester requester)
          Invoked immediately before the given requester is returned to its pool.
 void passivateObject(Object key, Object obj)
           
 boolean validate(InboundEndpoint endpoint, MessageRequester requester)
          Invoked after the requester is returned from a client but before it is prepared for return to its pool via MessageRequesterFactory.passivate(org.mule.api.endpoint.InboundEndpoint, org.mule.api.transport.MessageRequester).
 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

KeyedPoolMessageRequesterFactoryAdapter

public KeyedPoolMessageRequesterFactoryAdapter(MessageRequesterFactory 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

isCreateRequesterPerRequest

public boolean isCreateRequesterPerRequest()
Description copied from interface: MessageRequesterFactory
Controls whether dispatchers are cached or created per request. Note that if an exception occurs in the requester, it is automatically disposed of and a new one is created for the next request. This allows requesters to recover from loss of connection and other faults. When invoked by MessageRequesterFactory.validate(org.mule.api.endpoint.InboundEndpoint, org.mule.api.transport.MessageRequester) it takes precedence over the dispatcher's own return value of MessageDispatcher.validate().

Specified by:
isCreateRequesterPerRequest in interface MessageRequesterFactory
Returns:
true if created per request

create

public MessageRequester create(InboundEndpoint endpoint)
                        throws MuleException
Description copied from interface: MessageRequesterFactory
Creates a new message requester instance, initialised with the passed endpoint. The returned instance should be immediately useable.

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

activate

public void activate(InboundEndpoint endpoint,
                     MessageRequester requester)
              throws MuleException
Description copied from interface: MessageRequesterFactory
Invoked before the given requester is handed out to a client, but not after MessageRequesterFactory.create(org.mule.api.endpoint.InboundEndpoint).

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

destroy

public void destroy(InboundEndpoint endpoint,
                    MessageRequester requester)
Description copied from interface: MessageRequesterFactory
Invoked when a requester returned false for MessageRequesterFactory.validate(org.mule.api.endpoint.InboundEndpoint, org.mule.api.transport.MessageRequester).

Specified by:
destroy in interface MessageRequesterFactory
Parameters:
endpoint - the endpoint of the requester
requester - the requester to be validated

passivate

public void passivate(InboundEndpoint endpoint,
                      MessageRequester requester)
Description copied from interface: MessageRequesterFactory
Invoked immediately before the given requester is returned to its pool.

Specified by:
passivate in interface MessageRequesterFactory
Parameters:
endpoint - the endpoint of the requester
requester - the requester to be passivated

validate

public boolean validate(InboundEndpoint endpoint,
                        MessageRequester requester)
Description copied from interface: MessageRequesterFactory
Invoked after the requester is returned from a client but before it is prepared for return to its pool via MessageRequesterFactory.passivate(org.mule.api.endpoint.InboundEndpoint, org.mule.api.transport.MessageRequester).

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


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