Top Description Inners Fields Constructors Methods
org.springframework.jca.endpoint

public abstract Class AbstractMessageEndpointFactory

extends Object
implements MessageEndpointFactory, BeanNameAware
Class Inheritance
All Implemented Interfaces
org.springframework.beans.factory.BeanNameAware, org.springframework.beans.factory.Aware, jakarta.resource.spi.endpoint.MessageEndpointFactory
Known Direct Subclasses
org.springframework.jca.endpoint.GenericMessageEndpointFactory
Imports
java.lang.reflect.Method, javax.transaction.xa.XAResource, jakarta.resource.ResourceException, jakarta.resource.spi.ApplicationServerInternalException, .UnavailableException, jakarta.resource.spi.endpoint.MessageEndpoint, .MessageEndpointFactory, jakarta.transaction.Transaction, .TransactionManager, org.apache.commons.logging.Log, .LogFactory, org.springframework.beans.factory.BeanNameAware, org.springframework.lang.Nullable, org.springframework.transaction.jta.SimpleTransactionFactory, .TransactionFactory, org.springframework.util.Assert

Abstract base implementation of the JCA 1.7 jakarta.resource.spi.endpoint.MessageEndpointFactory interface, providing transaction management capabilities as well as ClassLoader exposure for endpoint invocations.
Author
Juergen Hoeller
Since
2.5
See Also
setTransactionManager

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected abstract class
AbstractMessageEndpointFactory.AbstractMessageEndpoint

Inner class for actual endpoint implementations, based on template method to allow for any kind of concrete endpoint implementation.

private class
AbstractMessageEndpointFactory.TransactionDelegate

Private inner class that performs the actual transaction handling, including enlistment of the endpoint's XAResource.

Field Summary

Modifier and TypeField and Description
private String
protected final Log
logger

Logger available to subclasses.

private TransactionFactory
private String
private int

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public MessageEndpoint
createEndpoint(XAResource
an optional XAResource instance used to get transaction notifications when the message delivery is transacted.
xaResource
)

Implements jakarta.resource.spi.endpoint.MessageEndpointFactory.createEndpoint.

The standard JCA 1.5 version of createEndpoint.

public MessageEndpoint
createEndpoint(XAResource
an optional XAResource instance used to get transaction notifications when the message delivery is transacted.
xaResource
,
long
an optional value used to specify the time duration (in milliseconds) within which the message endpoint needs to be created by the MessageEndpointFactory. Otherwise, the MessageEndpointFactory rejects the creation of the MessageEndpoint with an UnavailableException. Note, this does not offer real-time guarantees.
timeout
)

Implements jakarta.resource.spi.endpoint.MessageEndpointFactory.createEndpoint.

The alternative JCA 1.6 version of createEndpoint.

protected abstract AbstractMessageEndpointFactory.AbstractMessageEndpoint

Returns:

the actual endpoint instance (never null)
createEndpointInternal
()

Create the actual endpoint instance, as a subclass of the AbstractMessageEndpoint inner class of this factory.

public String
getActivationName()

Implements jakarta.resource.spi.endpoint.MessageEndpointFactory.getActivationName.

Implementation of the JCA 1.7 #getActivationName() method, returning the bean name as set on this MessageEndpointFactory.

public Class<?>
getEndpointClass()

Implements jakarta.resource.spi.endpoint.MessageEndpointFactory.getEndpointClass.

Implementation of the JCA 1.7 #getEndpointClass() method, returning null in order to indicate a synthetic endpoint type.

public boolean
isDeliveryTransacted(Method
description of a target method. This information about the intended target method allows an application server to find out whether the target method call will be transacted or not.
method
)

Implements jakarta.resource.spi.endpoint.MessageEndpointFactory.isDeliveryTransacted.

This implementation returns true if a transaction manager has been specified; false otherwise.

public void
setBeanName(String
the name of the bean in the factory. Note that this name is the actual bean name used in the factory, which may differ from the originally specified name: in particular for inner bean names, the actual bean name might have been made unique through appending "#..." suffixes. Use the BeanFactoryUtils#originalBeanName(String) method to extract the original bean name (without suffix), if desired.
beanName
)

Implements org.springframework.beans.factory.BeanNameAware.setBeanName.

Set the name of this message endpoint.

public void
setTransactionFactory(TransactionFactory transactionFactory)

Set the Spring TransactionFactory to use for wrapping endpoint invocations, enlisting the endpoint resource in each such transaction.

public void
setTransactionManager(Object transactionManager)

Set the XA transaction manager to use for wrapping endpoint invocations, enlisting the endpoint resource in each such transaction.

public void
setTransactionName(String transactionName)

Specify the name of the transaction, if any.

public void
setTransactionTimeout(int transactionTimeout)

Specify the transaction timeout, if any.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

beanNameback to summary
private String beanName
Annotations
@Nullable
loggerback to summary
protected final Log logger

Logger available to subclasses.

transactionFactoryback to summary
private TransactionFactory transactionFactory
Annotations
@Nullable
transactionNameback to summary
private String transactionName
Annotations
@Nullable
transactionTimeoutback to summary
private int transactionTimeout

Constructor Detail

AbstractMessageEndpointFactoryback to summary
public AbstractMessageEndpointFactory()

Method Detail

createEndpointback to summary
public MessageEndpoint createEndpoint(XAResource xaResource) throws UnavailableException

Implements jakarta.resource.spi.endpoint.MessageEndpointFactory.createEndpoint.

The standard JCA 1.5 version of createEndpoint.

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

Parameters
xaResource:XAResource

Doc from jakarta.resource.spi.endpoint.MessageEndpointFactory.createEndpoint.

an optional XAResource instance used to get transaction notifications when the message delivery is transacted.

Returns:MessageEndpoint

Doc from jakarta.resource.spi.endpoint.MessageEndpointFactory.createEndpoint.

a message endpoint instance.

Annotations
@Override
Exceptions
UnavailableException:

Doc from jakarta.resource.spi.endpoint.MessageEndpointFactory.createEndpoint.

indicates a transient failure in creating a message endpoint. Subsequent attempts to create a message endpoint might succeed.

createEndpointback to summary
public MessageEndpoint createEndpoint(XAResource xaResource, long timeout) throws UnavailableException

Implements jakarta.resource.spi.endpoint.MessageEndpointFactory.createEndpoint.

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.

Parameters
xaResource:XAResource

Doc from jakarta.resource.spi.endpoint.MessageEndpointFactory.createEndpoint.

an optional XAResource instance used to get transaction notifications when the message delivery is transacted.

timeout:long

Doc from jakarta.resource.spi.endpoint.MessageEndpointFactory.createEndpoint.

an optional value used to specify the time duration (in milliseconds) within which the message endpoint needs to be created by the MessageEndpointFactory. Otherwise, the MessageEndpointFactory rejects the creation of the MessageEndpoint with an UnavailableException. Note, this does not offer real-time guarantees.

Returns:MessageEndpoint

Doc from jakarta.resource.spi.endpoint.MessageEndpointFactory.createEndpoint.

a message endpoint instance.

Annotations
@Override
Exceptions
UnavailableException:

Doc from jakarta.resource.spi.endpoint.MessageEndpointFactory.createEndpoint.

indicates a transient failure in creating a message endpoint. Subsequent attempts to create a message endpoint might succeed.

createEndpointInternalback to summary
protected abstract AbstractMessageEndpointFactory.AbstractMessageEndpoint createEndpointInternal() throws UnavailableException

Create the actual endpoint instance, as a subclass of the AbstractMessageEndpoint inner class of this factory.

Returns:AbstractMessageEndpointFactory.AbstractMessageEndpoint

the actual endpoint instance (never null)

Exceptions
UnavailableException:
if no endpoint is available at present
getActivationNameback to summary
public String getActivationName()

Implements jakarta.resource.spi.endpoint.MessageEndpointFactory.getActivationName.

Implementation of the JCA 1.7 #getActivationName() method, returning the bean name as set on this MessageEndpointFactory.

Returns:String

Doc from jakarta.resource.spi.endpoint.MessageEndpointFactory.getActivationName.

a new String instance representing the unique name of the message endpoint deployment

Annotations
@Override
@Nullable
See Also
setBeanName
getEndpointClassback to summary
public Class<?> getEndpointClass()

Implements jakarta.resource.spi.endpoint.MessageEndpointFactory.getEndpointClass.

Implementation of the JCA 1.7 #getEndpointClass() method, returning null in order to indicate a synthetic endpoint type.

Returns:Class<?>

Doc from jakarta.resource.spi.endpoint.MessageEndpointFactory.getEndpointClass.

A Class corresponding to the message endpoint class.

Annotations
@Override
@Nullable
isDeliveryTransactedback to summary
public boolean isDeliveryTransacted(Method method) throws NoSuchMethodException

Implements jakarta.resource.spi.endpoint.MessageEndpointFactory.isDeliveryTransacted.

This implementation returns true if a transaction manager has been specified; false otherwise.

Parameters
method:Method

Doc from jakarta.resource.spi.endpoint.MessageEndpointFactory.isDeliveryTransacted.

description of a target method. This information about the intended target method allows an application server to find out whether the target method call will be transacted or not.

Returns:boolean

Doc from jakarta.resource.spi.endpoint.MessageEndpointFactory.isDeliveryTransacted.

true, if message endpoint requires transacted message delivery.

Annotations
@Override
Exceptions
NoSuchMethodException:

Doc from jakarta.resource.spi.endpoint.MessageEndpointFactory.isDeliveryTransacted.

indicates that the specified method does not exist on the target endpoint.

See Also
setTransactionManager, setTransactionFactory
setBeanNameback to summary
public void setBeanName(String beanName)

Implements org.springframework.beans.factory.BeanNameAware.setBeanName.

Set the name of this message endpoint. Populated with the bean name automatically when defined within Spring's bean factory.

Parameters
beanName:String

Doc from org.springframework.beans.factory.BeanNameAware.setBeanName.

the name of the bean in the factory. Note that this name is the actual bean name used in the factory, which may differ from the originally specified name: in particular for inner bean names, the actual bean name might have been made unique through appending "#..." suffixes. Use the BeanFactoryUtils#originalBeanName(String) method to extract the original bean name (without suffix), if desired.

Annotations
@Override
setTransactionFactoryback to summary
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, setTransactionTimeout
setTransactionManagerback to summary
public void setTransactionManager(Object transactionManager)

Set 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 org.springframework.transaction.jta.TransactionFactory interface, or a plain jakarta.transaction.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, setTransactionTimeout
setTransactionNameback to summary
public void setTransactionName(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.

setTransactionTimeoutback to summary
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.

org.springframework.jca.endpoint back to summary

protected abstract Class AbstractMessageEndpointFactory.AbstractMessageEndpoint

extends Object
implements MessageEndpoint
Class Inheritance
  • java.lang.Object
  • org.springframework.jca.endpoint.AbstractMessageEndpointFactory.AbstractMessageEndpoint
All Implemented Interfaces
jakarta.resource.spi.endpoint.MessageEndpoint
Known Direct Subclasses
org.springframework.jca.endpoint.GenericMessageEndpointFactory.GenericMessageEndpoint

Inner class for actual endpoint implementations, based on template method to allow for any kind of concrete endpoint implementation.

Field Summary

Modifier and TypeField and Description
private boolean
private ClassLoader
private AbstractMessageEndpointFactory.TransactionDelegate

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
public void
afterDelivery()

Implements jakarta.resource.spi.endpoint.MessageEndpoint.afterDelivery.

This afterDelivery implementation resets the thread context ClassLoader and completes the transaction, if any.

public void
beforeDelivery(Method
description of a target method. This information about the intended target method allows an application server to decide whether to start a transaction during this method call, depending on the transaction preferences of the target method. The processing (by the application server) of the actual message delivery method call on the endpoint must be independent of the class loader associated with this descriptive method object.
method
)

Implements jakarta.resource.spi.endpoint.MessageEndpoint.beforeDelivery.

This beforeDelivery implementation starts a transaction, if necessary, and exposes the endpoint ClassLoader as current thread context ClassLoader.

protected abstract ClassLoader

Returns:

the endpoint ClassLoader (never null)
getEndpointClassLoader
()

Template method for exposing the endpoint's ClassLoader (typically the ClassLoader that the message listener class has been loaded with).

protected final boolean
hasBeforeDeliveryBeenCalled()

Return whether the beforeDelivery method of this endpoint has already been called.

pack-priv void
initXAResource(XAResource
the XAResource for this endpoint
xaResource
)

Initialize this endpoint's TransactionDelegate.

protected void
onEndpointException(Throwable
the exception thrown from the concrete endpoint
ex
)

Callback method for notifying the endpoint base class that the concrete endpoint invocation led to an exception.

public void
release()

Implements jakarta.resource.spi.endpoint.MessageEndpoint.release.

This method may be called by the resource adapter to indicate that it no longer needs a proxy endpoint instance.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

beforeDeliveryCalledback to summary
private boolean beforeDeliveryCalled
previousContextClassLoaderback to summary
private ClassLoader previousContextClassLoader
Annotations
@Nullable
transactionDelegateback to summary
private AbstractMessageEndpointFactory.TransactionDelegate transactionDelegate
Annotations
@Nullable

Constructor Detail

AbstractMessageEndpointback to summary
protected AbstractMessageEndpoint()

Method Detail

afterDeliveryback to summary
public void afterDelivery() throws ResourceException

Implements jakarta.resource.spi.endpoint.MessageEndpoint.afterDelivery.

This afterDelivery implementation resets the thread context ClassLoader and completes the transaction, if any.

Note that the JCA 1.7 specification does not require a ResourceAdapter to call this method after invoking the concrete endpoint. See the explanation in beforeDelivery's javadoc.

Annotations
@Override
Exceptions
ResourceException:

Doc from jakarta.resource.spi.endpoint.MessageEndpoint.afterDelivery.

generic exception.

beforeDeliveryback to summary
public void beforeDelivery(Method method) throws ResourceException

Implements jakarta.resource.spi.endpoint.MessageEndpoint.beforeDelivery.

This beforeDelivery implementation starts a transaction, if necessary, and exposes the endpoint ClassLoader as current thread context ClassLoader.

Note that the JCA 1.7 specification does not require a ResourceAdapter to call this method before invoking the concrete endpoint. If this method has not been called (check hasBeforeDeliveryBeenCalled()), the concrete endpoint method should call beforeDelivery and its sibling afterDelivery() explicitly, as part of its own processing.

Parameters
method:Method

Doc from jakarta.resource.spi.endpoint.MessageEndpoint.beforeDelivery.

description of a target method. This information about the intended target method allows an application server to decide whether to start a transaction during this method call, depending on the transaction preferences of the target method. The processing (by the application server) of the actual message delivery method call on the endpoint must be independent of the class loader associated with this descriptive method object.

Annotations
@Override
Exceptions
ResourceException:

Doc from jakarta.resource.spi.endpoint.MessageEndpoint.beforeDelivery.

generic exception.

getEndpointClassLoaderback to summary
protected abstract ClassLoader getEndpointClassLoader()

Template method for exposing the endpoint's ClassLoader (typically the ClassLoader that the message listener class has been loaded with).

Returns:ClassLoader

the endpoint ClassLoader (never null)

hasBeforeDeliveryBeenCalledback to summary
protected final boolean hasBeforeDeliveryBeenCalled()

Return whether the beforeDelivery method of this endpoint has already been called.

initXAResourceback to summary
pack-priv void initXAResource(XAResource xaResource)

Initialize this endpoint's TransactionDelegate.

Parameters
xaResource:XAResource

the XAResource for this endpoint

onEndpointExceptionback to summary
protected void onEndpointException(Throwable ex)

Callback method for notifying the endpoint base class that the concrete endpoint invocation led to an exception.

To be invoked by subclasses in case of the concrete endpoint throwing an exception.

Parameters
ex:Throwable

the exception thrown from the concrete endpoint

releaseback to summary
public void release()

Implements jakarta.resource.spi.endpoint.MessageEndpoint.release.

Doc from jakarta.resource.spi.endpoint.MessageEndpoint.release.

This method may be called by the resource adapter to indicate that it no longer needs a proxy endpoint instance. This hint may be used by the application server for endpoint pooling decisions.

Annotations
@Override
org.springframework.jca.endpoint back to summary

private Class AbstractMessageEndpointFactory.TransactionDelegate

extends Object
Class Inheritance
  • java.lang.Object
  • org.springframework.jca.endpoint.AbstractMessageEndpointFactory.TransactionDelegate

Private inner class that performs the actual transaction handling, including enlistment of the endpoint's XAResource.

Field Summary

Modifier and TypeField and Description
private boolean
private Transaction
private final XAResource

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
public void
public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

rollbackOnlyback to summary
private boolean rollbackOnly
transactionback to summary
private Transaction transaction
Annotations
@Nullable
xaResourceback to summary
private final XAResource xaResource
Annotations
@Nullable

Constructor Detail

TransactionDelegateback to summary
public TransactionDelegate(XAResource xaResource)

Method Detail

beginTransactionback to summary
public void beginTransaction() throws Exception
endTransactionback to summary
public void endTransaction() throws Exception
setRollbackOnlyback to summary
public void setRollbackOnly()