Spring Framework

org.springframework.jca.endpoint
Class AbstractMessageEndpointFactory

java.lang.Object
  extended by org.springframework.jca.endpoint.AbstractMessageEndpointFactory
All Implemented Interfaces:
javax.resource.spi.endpoint.MessageEndpointFactory
Direct Known Subclasses:
GenericMessageEndpointFactory, JmsMessageEndpointFactory

public abstract class AbstractMessageEndpointFactory
extends java.lang.Object
implements javax.resource.spi.endpoint.MessageEndpointFactory

Abstract base implementation of the JCA 1.5/1.6 MessageEndpointFactory interface, providing transaction management capabilities as well as ClassLoader exposure for endpoint invocations.

Since:
2.5
Author:
Juergen Hoeller
See Also:
setTransactionManager(java.lang.Object)

Nested Class Summary
protected  class AbstractMessageEndpointFactory.AbstractMessageEndpoint
          Inner class for actual endpoint implementations, based on template method to allow for any kind of concrete endpoint implementation.
 
Field Summary
protected  org.apache.commons.logging.Log logger
          Logger available to subclasses
 
Constructor Summary
AbstractMessageEndpointFactory()
           
 
Method Summary
 javax.resource.spi.endpoint.MessageEndpoint createEndpoint(javax.transaction.xa.XAResource xaResource)
          The standard JCA 1.5 version of createEndpoint.
 javax.resource.spi.endpoint.MessageEndpoint createEndpoint(javax.transaction.xa.XAResource xaResource, long timeout)
          The alternative JCA 1.6 version of createEndpoint.
protected abstract  AbstractMessageEndpointFactory.AbstractMessageEndpoint createEndpointInternal()
          Create the actual endpoint instance, as a subclass of the AbstractMessageEndpointFactory.AbstractMessageEndpoint inner class of this factory.
 boolean isDeliveryTransacted(java.lang.reflect.Method method)
          This implementation returns true if a transaction manager has been specified; false otherwise.
 void setTransactionFactory(TransactionFactory transactionFactory)
          Set the Spring TransactionFactory to use for wrapping endpoint invocations, enlisting the endpoint resource in each such transaction.
 void setTransactionManager(java.lang.Object transactionManager)
          Set the the XA transaction manager to use for wrapping endpoint invocations, enlisting the endpoint resource in each such transaction.
 void setTransactionName(java.lang.String transactionName)
          Specify the name of the transaction, if any.
 void setTransactionTimeout(int transactionTimeout)
          Specify the transaction timeout, if any.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected final org.apache.commons.logging.Log logger
Logger available to subclasses

Constructor Detail

AbstractMessageEndpointFactory

public AbstractMessageEndpointFactory()
Method Detail

setTransactionManager

public void setTransactionManager(java.lang.Object transactionManager)
Set the the XA transaction manager to use for wrapping endpoint invocations, enlisting the endpoint resource in each such transaction.

The passed-in object may be a transaction manager which implements Spring's TransactionFactory interface, or a plain TransactionManager.

If no transaction manager is specified, the endpoint invocation will simply not be wrapped in an XA transaction. Check out your resource provider's ActivationSpec documentation for local transaction options of your particular provider.

See Also:
setTransactionName(java.lang.String), setTransactionTimeout(int)

setTransactionFactory

public void setTransactionFactory(TransactionFactory transactionFactory)
Set the Spring TransactionFactory to use for wrapping endpoint invocations, enlisting the endpoint resource in each such transaction.

Alternatively, specify an appropriate transaction manager through the "transactionManager" property.

If no transaction factory is specified, the endpoint invocation will simply not be wrapped in an XA transaction. Check out your resource provider's ActivationSpec documentation for local transaction options of your particular provider.

See Also:
setTransactionName(java.lang.String), setTransactionTimeout(int)

setTransactionName

public void setTransactionName(java.lang.String transactionName)
Specify the name of the transaction, if any.

Default is none. A specified name will be passed on to the transaction manager, allowing to identify the transaction in a transaction monitor.


setTransactionTimeout

public void setTransactionTimeout(int transactionTimeout)
Specify the transaction timeout, if any.

Default is -1: rely on the transaction manager's default timeout. Specify a concrete timeout to restrict the maximum duration of each endpoint invocation.


isDeliveryTransacted

public boolean isDeliveryTransacted(java.lang.reflect.Method method)
                             throws java.lang.NoSuchMethodException
This implementation returns true if a transaction manager has been specified; false otherwise.

Specified by:
isDeliveryTransacted in interface javax.resource.spi.endpoint.MessageEndpointFactory
Throws:
java.lang.NoSuchMethodException
See Also:
setTransactionManager(java.lang.Object), setTransactionFactory(org.springframework.transaction.jta.TransactionFactory)

createEndpoint

public javax.resource.spi.endpoint.MessageEndpoint createEndpoint(javax.transaction.xa.XAResource xaResource)
                                                           throws javax.resource.spi.UnavailableException
The standard JCA 1.5 version of createEndpoint.

This implementation delegates to createEndpointInternal(), initializing the endpoint's XAResource before the endpoint gets invoked.

Specified by:
createEndpoint in interface javax.resource.spi.endpoint.MessageEndpointFactory
Throws:
javax.resource.spi.UnavailableException

createEndpoint

public javax.resource.spi.endpoint.MessageEndpoint createEndpoint(javax.transaction.xa.XAResource xaResource,
                                                                  long timeout)
                                                           throws javax.resource.spi.UnavailableException
The alternative JCA 1.6 version of createEndpoint.

This implementation delegates to createEndpointInternal(), ignoring the specified timeout. It is only here for JCA 1.6 compliance.

Throws:
javax.resource.spi.UnavailableException

createEndpointInternal

protected abstract AbstractMessageEndpointFactory.AbstractMessageEndpoint createEndpointInternal()
                                                                                          throws javax.resource.spi.UnavailableException
Create the actual endpoint instance, as a subclass of the AbstractMessageEndpointFactory.AbstractMessageEndpoint inner class of this factory.

Returns:
the actual endpoint instance (never null)
Throws:
javax.resource.spi.UnavailableException - if no endpoint is available at present

Spring Framework