Top Description Inners Fields Constructors Methods
org.springframework.jms.connection

public Class TransactionAwareConnectionFactoryProxy

extends Object
implements ConnectionFactory, QueueConnectionFactory, TopicConnectionFactory
Class Inheritance
All Implemented Interfaces
jakarta.jms.TopicConnectionFactory, jakarta.jms.ConnectionFactory, jakarta.jms.QueueConnectionFactory
Imports
java.lang.reflect.InvocationHandler, .InvocationTargetException, .Method, .Proxy, java.util.ArrayList, .List, jakarta.jms.Connection, .ConnectionFactory, .JMSContext, .JMSException, .QueueConnection, .QueueConnectionFactory, .QueueSession, .Session, .TopicConnection, .TopicConnectionFactory, .TopicSession, .TransactionInProgressException, org.springframework.lang.Nullable, org.springframework.util.Assert, .ClassUtils

Proxy for a target JMS jakarta.jms.ConnectionFactory, adding awareness of Spring-managed transactions. Similar to a transactional JNDI ConnectionFactory as provided by a Jakarta EE application server.

Messaging code which should remain unaware of Spring's JMS support can work with this proxy to seamlessly participate in Spring-managed transactions. Note that the transaction manager, for example JmsTransactionManager, still needs to work with the underlying ConnectionFactory, not with this proxy.

Make sure that TransactionAwareConnectionFactoryProxy is the outermost ConnectionFactory of a chain of ConnectionFactory proxies/adapters. TransactionAwareConnectionFactoryProxy can delegate either directly to the target factory or to some intermediary adapter like UserCredentialsConnectionFactoryAdapter.

Delegates to ConnectionFactoryUtils for automatically participating in thread-bound transactions, for example managed by JmsTransactionManager. createSession calls and close calls on returned Sessions will behave properly within a transaction, that is, always work on the transactional Session. If not within a transaction, normal ConnectionFactory behavior applies.

Note that transactional JMS Sessions will be registered on a per-Connection basis. To share the same JMS Session across a transaction, make sure that you operate on the same JMS Connection handle - either through reusing the handle or through configuring a SingleConnectionFactory underneath.

Returned transactional Session proxies will implement the SessionProxy interface to allow for access to the underlying target Session. This is only intended for accessing vendor-specific Session API or for testing purposes (e.g. to perform manual transaction control). For typical application purposes, simply use the standard JMS Session interface.

As of Spring Framework 5, this class delegates JMS 2.0 JMSContext calls and therefore requires the JMS 2.0 API to be present at runtime. It may nevertheless run against a JMS 1.1 driver (bound to the JMS 2.0 API) as long as no actual JMS 2.0 calls are triggered by the application's setup.

Author
Juergen Hoeller
Since
2.0
See Also
UserCredentialsConnectionFactoryAdapter, SingleConnectionFactory

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
TransactionAwareConnectionFactoryProxy.CloseSuppressingSessionInvocationHandler

Invocation handler that suppresses close calls for a transactional JMS Session.

private class
TransactionAwareConnectionFactoryProxy.TransactionAwareConnectionInvocationHandler

Invocation handler that exposes transactional Sessions for the underlying Connection.

Field Summary

Modifier and TypeField and Description
private boolean
private ConnectionFactory

Constructor Summary

AccessConstructor and Description
public
TransactionAwareConnectionFactoryProxy()

Create a new TransactionAwareConnectionFactoryProxy.

public
TransactionAwareConnectionFactoryProxy(ConnectionFactory
the target ConnectionFactory
targetConnectionFactory
)

Create a new TransactionAwareConnectionFactoryProxy.

Method Summary

Modifier and TypeMethod and Description
public Connection
createConnection()

Implements jakarta.jms.ConnectionFactory.createConnection.

Creates a connection with the default user identity.

public Connection
createConnection(String
the caller's user name
username
,
String
the caller's password
password
)

Implements jakarta.jms.ConnectionFactory.createConnection.

Creates a connection with the specified user identity.

public JMSContext
createContext()

Implements jakarta.jms.ConnectionFactory.createContext.

Creates a JMSContext with the default user identity and an unspecified sessionMode.

public JMSContext
createContext(String
the caller's user name
userName
,
String
the caller's password
password
)

Implements jakarta.jms.ConnectionFactory.createContext.

Creates a JMSContext with the specified user identity and an unspecified sessionMode.

public JMSContext
createContext(String
the caller's user name
userName
,
String
the caller's password
password
,
int
indicates which of four possible session modes will be used.
  • If this method is called in a Java SE environment or in the Jakarta EE application client container, the permitted values are JMSContext.SESSION_TRANSACTED, JMSContext.CLIENT_ACKNOWLEDGE, JMSContext.AUTO_ACKNOWLEDGE and JMSContext.DUPS_OK_ACKNOWLEDGE.
  • If this method is called in the Jakarta EE web or EJB container when there is an active JTA transaction in progress then this argument is ignored.
  • If this method is called in the Jakarta EE web or EJB container when there is no active JTA transaction in progress, the permitted values are JMSContext.AUTO_ACKNOWLEDGE and JMSContext.DUPS_OK_ACKNOWLEDGE. In this case the values JMSContext.TRANSACTED and JMSContext.CLIENT_ACKNOWLEDGE are not permitted.
sessionMode
)

Implements jakarta.jms.ConnectionFactory.createContext.

Creates a JMSContext with the specified user identity and the specified session mode.

public JMSContext
createContext(int
indicates which of four possible session modes will be used.
  • If this method is called in a Java SE environment or in the Jakarta EE application client container, the permitted values are JMSContext.SESSION_TRANSACTED, JMSContext.CLIENT_ACKNOWLEDGE, JMSContext.AUTO_ACKNOWLEDGE and JMSContext.DUPS_OK_ACKNOWLEDGE.
  • If this method is called in the Jakarta EE web or EJB container when there is an active JTA transaction in progress then this argument is ignored.
  • If this method is called in the Jakarta EE web or EJB container when there is no active JTA transaction in progress, the permitted values are JMSContext.AUTO_ACKNOWLEDGE and JMSContext.DUPS_OK_ACKNOWLEDGE. In this case the values JMSContext.TRANSACTED and JMSContext.CLIENT_ACKNOWLEDGE are not permitted.
sessionMode
)

Implements jakarta.jms.ConnectionFactory.createContext.

Creates a JMSContext with the default user identity and the specified session mode.

public QueueConnection
createQueueConnection()

Implements jakarta.jms.QueueConnectionFactory.createQueueConnection.

Creates a queue connection with the default user identity.

public QueueConnection
createQueueConnection(String
the caller's user name
username
,
String
the caller's password
password
)

Implements jakarta.jms.QueueConnectionFactory.createQueueConnection.

Creates a queue connection with the specified user identity.

public TopicConnection
createTopicConnection()

Implements jakarta.jms.TopicConnectionFactory.createTopicConnection.

Creates a topic connection with the default user identity.

public TopicConnection
createTopicConnection(String
the caller's user name
username
,
String
the caller's password
password
)

Implements jakarta.jms.TopicConnectionFactory.createTopicConnection.

Creates a topic connection with the specified user identity.

protected ConnectionFactory
getTargetConnectionFactory()

Return the target ConnectionFactory that this ConnectionFactory should delegate to.

protected Connection

Returns:

the wrapped Connection
getTransactionAwareConnectionProxy
(Connection
the original Connection to wrap
target
)

Wrap the given Connection with a proxy that delegates every method call to it but handles Session lookup in a transaction-aware fashion.

protected boolean
isSynchedLocalTransactionAllowed()

Return whether to allow for a local JMS transaction that is synchronized with a Spring-managed transaction.

public void
setSynchedLocalTransactionAllowed(boolean synchedLocalTransactionAllowed)

Set whether to allow for a local JMS transaction that is synchronized with a Spring-managed transaction (where the main transaction might be a JDBC-based one for a specific DataSource, for example), with the JMS transaction committing right after the main transaction.

public final void
setTargetConnectionFactory(ConnectionFactory targetConnectionFactory)

Set the target ConnectionFactory that this ConnectionFactory should delegate to.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

synchedLocalTransactionAllowedback to summary
private boolean synchedLocalTransactionAllowed
targetConnectionFactoryback to summary
private ConnectionFactory targetConnectionFactory
Annotations
@Nullable

Constructor Detail

TransactionAwareConnectionFactoryProxyback to summary
public TransactionAwareConnectionFactoryProxy()

Create a new TransactionAwareConnectionFactoryProxy.

TransactionAwareConnectionFactoryProxyback to summary
public TransactionAwareConnectionFactoryProxy(ConnectionFactory targetConnectionFactory)

Create a new TransactionAwareConnectionFactoryProxy.

Parameters
targetConnectionFactory:ConnectionFactory

the target ConnectionFactory

Method Detail

createConnectionback to summary
public Connection createConnection() throws JMSException

Implements jakarta.jms.ConnectionFactory.createConnection.

Doc from jakarta.jms.ConnectionFactory.createConnection.

Creates a connection with the default user identity. The connection is created in stopped mode. No messages will be delivered until the Connection.start method is explicitly called.

Returns:Connection

a newly created connection

Annotations
@Override
Exceptions
JMSException:
if the Jakarta Messaging provider fails to create the connection due to some internal error.
createConnectionback to summary
public Connection createConnection(String username, String password) throws JMSException

Implements jakarta.jms.ConnectionFactory.createConnection.

Doc from jakarta.jms.ConnectionFactory.createConnection.

Creates a connection with the specified user identity. The connection is created in stopped mode. No messages will be delivered until the Connection.start method is explicitly called.

Parameters
username:String

the caller's user name

password:String

the caller's password

Returns:Connection

a newly created connection

Annotations
@Override
Exceptions
JMSException:
if the Jakarta Messaging provider fails to create the connection due to some internal error.
createContextback to summary
public JMSContext createContext()

Implements jakarta.jms.ConnectionFactory.createContext.

Doc from jakarta.jms.ConnectionFactory.createContext.

Creates a JMSContext with the default user identity and an unspecified sessionMode.

A connection and session are created for use by the new JMSContext. The connection is created in stopped mode but will be automatically started when a JMSConsumer is created.

The behaviour of the session that is created depends on whether this method is called in a Java SE environment, in the Jakarta EE application client container, or in the Jakarta EE web or EJB container. If this method is called in the Jakarta EE web or EJB container then the behaviour of the session also depends on whether or not there is an active JTA transaction in progress.

In a Java SE environment or in the Jakarta EE application client container:

  • The session will be non-transacted and received messages will be acknowledged automatically using an acknowledgement mode of JMSContext.AUTO_ACKNOWLEDGE For a definition of the meaning of this acknowledgement mode see the link below.

In a Jakarta EE web or EJB container, when there is an active JTA transaction in progress:

  • The session will participate in the JTA transaction and will be committed or rolled back when that transaction is committed or rolled back, not by calling the JMSContext's commit or rollback methods.

In the Jakarta EE web or EJB container, when there is no active JTA transaction in progress:

  • The session will be non-transacted and received messages will be acknowledged automatically using an acknowledgement mode of JMSContext.AUTO_ACKNOWLEDGE For a definition of the meaning of this acknowledgement mode see the link below.
Returns:JMSContext

a newly created JMSContext

Annotations
@Override
createContextback to summary
public JMSContext createContext(String userName, String password)

Implements jakarta.jms.ConnectionFactory.createContext.

Doc from jakarta.jms.ConnectionFactory.createContext.

Creates a JMSContext with the specified user identity and an unspecified sessionMode.

A connection and session are created for use by the new JMSContext. The connection is created in stopped mode but will be automatically started when a JMSConsumer.

The behaviour of the session that is created depends on whether this method is called in a Java SE environment, in the Jakarta EE application client container, or in the Jakarta EE web or EJB container. If this method is called in the Jakarta EE web or EJB container then the behaviour of the session also depends on whether or not there is an active JTA transaction in progress.

In a Java SE environment or in the Jakarta EE application client container:

  • The session will be non-transacted and received messages will be acknowledged automatically using an acknowledgement mode of JMSContext.AUTO_ACKNOWLEDGE For a definition of the meaning of this acknowledgement mode see the link below.

In a Jakarta EE web or EJB container, when there is an active JTA transaction in progress:

  • The session will participate in the JTA transaction and will be committed or rolled back when that transaction is committed or rolled back, not by calling the JMSContext's commit or rollback methods.

In the Jakarta EE web or EJB container, when there is no active JTA transaction in progress:

  • The session will be non-transacted and received messages will be acknowledged automatically using an acknowledgement mode of JMSContext.AUTO_ACKNOWLEDGE For a definition of the meaning of this acknowledgement mode see the link below.
Parameters
userName:String

the caller's user name

password:String

the caller's password

Returns:JMSContext

a newly created JMSContext

Annotations
@Override
createContextback to summary
public JMSContext createContext(String userName, String password, int sessionMode)

Implements jakarta.jms.ConnectionFactory.createContext.

Doc from jakarta.jms.ConnectionFactory.createContext.

Creates a JMSContext with the specified user identity and the specified session mode.

A connection and session are created for use by the new JMSContext. The JMSContext is created in stopped mode but will be automatically started when a JMSConsumer is created.

The effect of setting the sessionMode argument depends on whether this method is called in a Java SE environment, in the Jakarta EE application client container, or in the Jakarta EE web or EJB container. If this method is called in the Jakarta EE web or EJB container then the effect of setting the sessionMode argument also depends on whether or not there is an active JTA transaction in progress.

In a Java SE environment or in the Jakarta EE application client container:

  • If sessionMode is set to JMSContext.SESSION_TRANSACTED then the session will use a local transaction which may subsequently be committed or rolled back by calling the JMSContext's commit or rollback methods.
  • If sessionMode is set to any of JMSContext.CLIENT_ACKNOWLEDGE, JMSContext.AUTO_ACKNOWLEDGE or JMSContext.DUPS_OK_ACKNOWLEDGE. then the session will be non-transacted and messages received by this session will be acknowledged according to the value of sessionMode. For a definition of the meaning of these acknowledgement modes see the links below.

In a Jakarta EE web or EJB container, when there is an active JTA transaction in progress:

  • The argument sessionMode is ignored. The session will participate in the JTA transaction and will be committed or rolled back when that transaction is committed or rolled back, not by calling the JMSContext's commit or rollback methods. Since the argument is ignored, developers are recommended to use createContext(String userName, String password) instead of this method.

In the Jakarta EE web or EJB container, when there is no active JTA transaction in progress:

  • The argument acknowledgeMode must be set to either of JMSContext.AUTO_ACKNOWLEDGE or JMSContext.DUPS_OK_ACKNOWLEDGE. The session will be non-transacted and messages received by this session will be acknowledged automatically according to the value of acknowledgeMode. For a definition of the meaning of these acknowledgement modes see the links below. The values JMSContext.SESSION_TRANSACTED and JMSContext.CLIENT_ACKNOWLEDGE may not be used.
Parameters
userName:String

the caller's user name

password:String

the caller's password

sessionMode:int

indicates which of four possible session modes will be used.

  • If this method is called in a Java SE environment or in the Jakarta EE application client container, the permitted values are JMSContext.SESSION_TRANSACTED, JMSContext.CLIENT_ACKNOWLEDGE, JMSContext.AUTO_ACKNOWLEDGE and JMSContext.DUPS_OK_ACKNOWLEDGE.
  • If this method is called in the Jakarta EE web or EJB container when there is an active JTA transaction in progress then this argument is ignored.
  • If this method is called in the Jakarta EE web or EJB container when there is no active JTA transaction in progress, the permitted values are JMSContext.AUTO_ACKNOWLEDGE and JMSContext.DUPS_OK_ACKNOWLEDGE. In this case the values JMSContext.TRANSACTED and JMSContext.CLIENT_ACKNOWLEDGE are not permitted.
Returns:JMSContext

a newly created JMSContext

Annotations
@Override
createContextback to summary
public JMSContext createContext(int sessionMode)

Implements jakarta.jms.ConnectionFactory.createContext.

Doc from jakarta.jms.ConnectionFactory.createContext.

Creates a JMSContext with the default user identity and the specified session mode.

A connection and session are created for use by the new JMSContext. The JMSContext is created in stopped mode but will be automatically started when a JMSConsumer is created.

The effect of setting the sessionMode argument depends on whether this method is called in a Java SE environment, in the Jakarta EE application client container, or in the Jakarta EE web or EJB container. If this method is called in the Jakarta EE web or EJB container then the effect of setting the sessionMode argument also depends on whether or not there is an active JTA transaction in progress.

In a Java SE environment or in the Jakarta EE application client container:

  • If sessionMode is set to JMSContext.SESSION_TRANSACTED then the session will use a local transaction which may subsequently be committed or rolled back by calling the JMSContext's commit or rollback methods.
  • If sessionMode is set to any of JMSContext.CLIENT_ACKNOWLEDGE, JMSContext.AUTO_ACKNOWLEDGE or JMSContext.DUPS_OK_ACKNOWLEDGE. then the session will be non-transacted and messages received by this session will be acknowledged according to the value of sessionMode. For a definition of the meaning of these acknowledgement modes see the links below.

In a Jakarta EE web or EJB container, when there is an active JTA transaction in progress:

  • The argument sessionMode is ignored. The session will participate in the JTA transaction and will be committed or rolled back when that transaction is committed or rolled back, not by calling the JMSContext's commit or rollback methods. Since the argument is ignored, developers are recommended to use createContext() instead of this method.

In the Jakarta EE web or EJB container, when there is no active JTA transaction in progress:

  • The argument acknowledgeMode must be set to either of JMSContext.AUTO_ACKNOWLEDGE or JMSContext.DUPS_OK_ACKNOWLEDGE. The session will be non-transacted and messages received by this session will be acknowledged automatically according to the value of acknowledgeMode. For a definition of the meaning of these acknowledgement modes see the links below. The values JMSContext.SESSION_TRANSACTED and JMSContext.CLIENT_ACKNOWLEDGE may not be used.
Parameters
sessionMode:int

indicates which of four possible session modes will be used.

  • If this method is called in a Java SE environment or in the Jakarta EE application client container, the permitted values are JMSContext.SESSION_TRANSACTED, JMSContext.CLIENT_ACKNOWLEDGE, JMSContext.AUTO_ACKNOWLEDGE and JMSContext.DUPS_OK_ACKNOWLEDGE.
  • If this method is called in the Jakarta EE web or EJB container when there is an active JTA transaction in progress then this argument is ignored.
  • If this method is called in the Jakarta EE web or EJB container when there is no active JTA transaction in progress, the permitted values are JMSContext.AUTO_ACKNOWLEDGE and JMSContext.DUPS_OK_ACKNOWLEDGE. In this case the values JMSContext.TRANSACTED and JMSContext.CLIENT_ACKNOWLEDGE are not permitted.
Returns:JMSContext

a newly created JMSContext

Annotations
@Override
createQueueConnectionback to summary
public QueueConnection createQueueConnection() throws JMSException

Implements jakarta.jms.QueueConnectionFactory.createQueueConnection.

Doc from jakarta.jms.QueueConnectionFactory.createQueueConnection.

Creates a queue connection with the default user identity. The connection is created in stopped mode. No messages will be delivered until the Connection.start method is explicitly called.

Returns:QueueConnection

a newly created queue connection

Annotations
@Override
Exceptions
JMSException:
if the Jakarta Messaging provider fails to create the queue connection due to some internal error.
createQueueConnectionback to summary
public QueueConnection createQueueConnection(String username, String password) throws JMSException

Implements jakarta.jms.QueueConnectionFactory.createQueueConnection.

Doc from jakarta.jms.QueueConnectionFactory.createQueueConnection.

Creates a queue connection with the specified user identity. The connection is created in stopped mode. No messages will be delivered until the Connection.start method is explicitly called.

Parameters
username:String

the caller's user name

password:String

the caller's password

Returns:QueueConnection

a newly created queue connection

Annotations
@Override
Exceptions
JMSException:
if the Jakarta Messaging provider fails to create the queue connection due to some internal error.
createTopicConnectionback to summary
public TopicConnection createTopicConnection() throws JMSException

Implements jakarta.jms.TopicConnectionFactory.createTopicConnection.

Doc from jakarta.jms.TopicConnectionFactory.createTopicConnection.

Creates a topic connection with the default user identity. The connection is created in stopped mode. No messages will be delivered until the Connection.start method is explicitly called.

Returns:TopicConnection

a newly created topic connection

Annotations
@Override
Exceptions
JMSException:
if the Jakarta Messaging provider fails to create a topic connection due to some internal error.
createTopicConnectionback to summary
public TopicConnection createTopicConnection(String username, String password) throws JMSException

Implements jakarta.jms.TopicConnectionFactory.createTopicConnection.

Doc from jakarta.jms.TopicConnectionFactory.createTopicConnection.

Creates a topic connection with the specified user identity. The connection is created in stopped mode. No messages will be delivered until the Connection.start method is explicitly called.

Parameters
username:String

the caller's user name

password:String

the caller's password

Returns:TopicConnection

a newly created topic connection

Annotations
@Override
Exceptions
JMSException:
if the Jakarta Messaging provider fails to create a topic connection due to some internal error.
getTargetConnectionFactoryback to summary
protected ConnectionFactory getTargetConnectionFactory()

Return the target ConnectionFactory that this ConnectionFactory should delegate to.

getTransactionAwareConnectionProxyback to summary
protected Connection getTransactionAwareConnectionProxy(Connection target)

Wrap the given Connection with a proxy that delegates every method call to it but handles Session lookup in a transaction-aware fashion.

Parameters
target:Connection

the original Connection to wrap

Returns:Connection

the wrapped Connection

isSynchedLocalTransactionAllowedback to summary
protected boolean isSynchedLocalTransactionAllowed()

Return whether to allow for a local JMS transaction that is synchronized with a Spring-managed transaction.

setSynchedLocalTransactionAllowedback to summary
public void setSynchedLocalTransactionAllowed(boolean synchedLocalTransactionAllowed)

Set whether to allow for a local JMS transaction that is synchronized with a Spring-managed transaction (where the main transaction might be a JDBC-based one for a specific DataSource, for example), with the JMS transaction committing right after the main transaction. If not allowed, the given ConnectionFactory needs to handle transaction enlistment underneath the covers.

Default is "false": If not within a managed transaction that encompasses the underlying JMS ConnectionFactory, standard Sessions will be returned. Turn this flag on to allow participation in any Spring-managed transaction, with a local JMS transaction synchronized with the main transaction.

setTargetConnectionFactoryback to summary
public final void setTargetConnectionFactory(ConnectionFactory targetConnectionFactory)

Set the target ConnectionFactory that this ConnectionFactory should delegate to.

org.springframework.jms.connection back to summary

private Class TransactionAwareConnectionFactoryProxy.CloseSuppressingSessionInvocationHandler

extends Object
implements InvocationHandler
Class Inheritance
  • java.lang.Object
  • org.springframework.jms.connection.TransactionAwareConnectionFactoryProxy.CloseSuppressingSessionInvocationHandler
All Implemented Interfaces
java.lang.reflect.InvocationHandler

Invocation handler that suppresses close calls for a transactional JMS Session.

Field Summary

Modifier and TypeField and Description
private final Session

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public Object
invoke(Object
the proxy instance that the method was invoked on
proxy
,
Method
the Method instance corresponding to the interface method invoked on the proxy instance. The declaring class of the Method object will be the interface that the method was declared in, which may be a superinterface of the proxy interface that the proxy class inherits the method through.
method
,
Object[]
an array of objects containing the values of the arguments passed in the method invocation on the proxy instance, or null if interface method takes no arguments. Arguments of primitive types are wrapped in instances of the appropriate primitive wrapper class, such as java.lang.Integer or java.lang.Boolean.
args
)

Implements java.lang.reflect.InvocationHandler.invoke.

Processes a method invocation on a proxy instance and returns the result.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

targetback to summary
private final Session target

Constructor Detail

CloseSuppressingSessionInvocationHandlerback to summary
public CloseSuppressingSessionInvocationHandler(Session target)

Method Detail

invokeback to summary
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable

Implements java.lang.reflect.InvocationHandler.invoke.

Doc from java.lang.reflect.InvocationHandler.invoke.

Processes a method invocation on a proxy instance and returns the result. This method will be invoked on an invocation handler when a method is invoked on a proxy instance that it is associated with.

Parameters
proxy:Object

the proxy instance that the method was invoked on

method:Method

the Method instance corresponding to the interface method invoked on the proxy instance. The declaring class of the Method object will be the interface that the method was declared in, which may be a superinterface of the proxy interface that the proxy class inherits the method through.

args:Object[]

an array of objects containing the values of the arguments passed in the method invocation on the proxy instance, or null if interface method takes no arguments. Arguments of primitive types are wrapped in instances of the appropriate primitive wrapper class, such as java.lang.Integer or java.lang.Boolean.

Returns:Object

the value to return from the method invocation on the proxy instance. If the declared return type of the interface method is a primitive type, then the value returned by this method must be an instance of the corresponding primitive wrapper class; otherwise, it must be a type assignable to the declared return type. If the value returned by this method is null and the interface method's return type is primitive, then a NullPointerException will be thrown by the method invocation on the proxy instance. If the value returned by this method is otherwise not compatible with the interface method's declared return type as described above, a ClassCastException will be thrown by the method invocation on the proxy instance.

Annotations
@Override
@Nullable
Exceptions
Throwable:
the exception to throw from the method invocation on the proxy instance. The exception's type must be assignable either to any of the exception types declared in the throws clause of the interface method or to the unchecked exception types java.lang.RuntimeException or java.lang.Error. If a checked exception is thrown by this method that is not assignable to any of the exception types declared in the throws clause of the interface method, then an UndeclaredThrowableException containing the exception that was thrown by this method will be thrown by the method invocation on the proxy instance.
org.springframework.jms.connection back to summary

private Class TransactionAwareConnectionFactoryProxy.TransactionAwareConnectionInvocationHandler

extends Object
implements InvocationHandler
Class Inheritance
  • java.lang.Object
  • org.springframework.jms.connection.TransactionAwareConnectionFactoryProxy.TransactionAwareConnectionInvocationHandler
All Implemented Interfaces
java.lang.reflect.InvocationHandler

Invocation handler that exposes transactional Sessions for the underlying Connection.

Field Summary

Modifier and TypeField and Description
private final Connection

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private Session
public Object
invoke(Object
the proxy instance that the method was invoked on
proxy
,
Method
the Method instance corresponding to the interface method invoked on the proxy instance. The declaring class of the Method object will be the interface that the method was declared in, which may be a superinterface of the proxy interface that the proxy class inherits the method through.
method
,
Object[]
an array of objects containing the values of the arguments passed in the method invocation on the proxy instance, or null if interface method takes no arguments. Arguments of primitive types are wrapped in instances of the appropriate primitive wrapper class, such as java.lang.Integer or java.lang.Boolean.
args
)

Implements java.lang.reflect.InvocationHandler.invoke.

Processes a method invocation on a proxy instance and returns the result.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

targetback to summary
private final Connection target

Constructor Detail

TransactionAwareConnectionInvocationHandlerback to summary
public TransactionAwareConnectionInvocationHandler(Connection target)

Method Detail

getCloseSuppressingSessionProxyback to summary
private Session getCloseSuppressingSessionProxy(Session target)
invokeback to summary
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable

Implements java.lang.reflect.InvocationHandler.invoke.

Doc from java.lang.reflect.InvocationHandler.invoke.

Processes a method invocation on a proxy instance and returns the result. This method will be invoked on an invocation handler when a method is invoked on a proxy instance that it is associated with.

Parameters
proxy:Object

the proxy instance that the method was invoked on

method:Method

the Method instance corresponding to the interface method invoked on the proxy instance. The declaring class of the Method object will be the interface that the method was declared in, which may be a superinterface of the proxy interface that the proxy class inherits the method through.

args:Object[]

an array of objects containing the values of the arguments passed in the method invocation on the proxy instance, or null if interface method takes no arguments. Arguments of primitive types are wrapped in instances of the appropriate primitive wrapper class, such as java.lang.Integer or java.lang.Boolean.

Returns:Object

the value to return from the method invocation on the proxy instance. If the declared return type of the interface method is a primitive type, then the value returned by this method must be an instance of the corresponding primitive wrapper class; otherwise, it must be a type assignable to the declared return type. If the value returned by this method is null and the interface method's return type is primitive, then a NullPointerException will be thrown by the method invocation on the proxy instance. If the value returned by this method is otherwise not compatible with the interface method's declared return type as described above, a ClassCastException will be thrown by the method invocation on the proxy instance.

Annotations
@Override
Exceptions
Throwable:
the exception to throw from the method invocation on the proxy instance. The exception's type must be assignable either to any of the exception types declared in the throws clause of the interface method or to the unchecked exception types java.lang.RuntimeException or java.lang.Error. If a checked exception is thrown by this method that is not assignable to any of the exception types declared in the throws clause of the interface method, then an UndeclaredThrowableException containing the exception that was thrown by this method will be thrown by the method invocation on the proxy instance.