| java.lang.Object org.springframework.jms.connection.UserCredentialsConnectionFactoryAdapter
UserCredentialsConnectionFactoryAdapter | public class UserCredentialsConnectionFactoryAdapter implements ConnectionFactory,QueueConnectionFactory,TopicConnectionFactory,InitializingBean(Code) | | An adapter for a target JMS
javax.jms.ConnectionFactory , applying the
given user credentials to every standard createConnection() call,
that is, implicitly invoking createConnection(username, password)
on the target. All other methods simply delegate to the corresponding methods
of the target ConnectionFactory.
Can be used to proxy a target JNDI ConnectionFactory that does not have user
credentials configured. Client code can work with the ConnectionFactory without
passing in username and password on every createConnection() call.
In the following example, client code can simply transparently work
with the preconfigured "myConnectionFactory", implicitly accessing
"myTargetConnectionFactory" with the specified user credentials.
<bean id="myTargetConnectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="java:comp/env/jms/mycf"/>
</bean>
<bean id="myConnectionFactory" class="org.springframework.jms.connection.UserCredentialsConnectionFactoryAdapter">
<property name="targetConnectionFactory" ref="myTargetConnectionFactory"/>
<property name="username" value="myusername"/>
<property name="password" value="mypassword"/>
</bean>
If the "username" is empty, this proxy will simply delegate to the standard
createConnection() method of the target ConnectionFactory.
This can be used to keep a UserCredentialsConnectionFactoryAdapter bean
definition just for the option of implicitly passing in user credentials
if the particular target ConnectionFactory requires it.
author: Juergen Hoeller since: 1.2 See Also: UserCredentialsConnectionFactoryAdapter.createConnection See Also: UserCredentialsConnectionFactoryAdapter.createQueueConnection See Also: UserCredentialsConnectionFactoryAdapter.createTopicConnection |
Method Summary | |
public void | afterPropertiesSet() | final public Connection | createConnection() Determine whether there are currently thread-bound credentials,
using them if available, falling back to the statically specified
username and password (i.e. | public Connection | createConnection(String username, String password) Delegate the call straight to the target ConnectionFactory. | final public QueueConnection | createQueueConnection() Determine whether there are currently thread-bound credentials,
using them if available, falling back to the statically specified
username and password (i.e. | public QueueConnection | createQueueConnection(String username, String password) Delegate the call straight to the target QueueConnectionFactory. | final public TopicConnection | createTopicConnection() Determine whether there are currently thread-bound credentials,
using them if available, falling back to the statically specified
username and password (i.e. | public TopicConnection | createTopicConnection(String username, String password) Delegate the call straight to the target TopicConnectionFactory. | protected Connection | doCreateConnection(String username, String password) This implementation delegates to the createConnection(username, password)
method of the target ConnectionFactory, passing in the specified user credentials. | protected QueueConnection | doCreateQueueConnection(String username, String password) This implementation delegates to the createQueueConnection(username, password)
method of the target QueueConnectionFactory, passing in the specified user credentials. | protected TopicConnection | doCreateTopicConnection(String username, String password) This implementation delegates to the createTopicConnection(username, password)
method of the target TopicConnectionFactory, passing in the specified user credentials. | public void | removeCredentialsFromCurrentThread() Remove any user credentials for this proxy from the current thread. | public void | setCredentialsForCurrentThread(String username, String password) Set user credententials for this proxy and the current thread. | public void | setPassword(String password) Set the password that this adapter should use for retrieving Connections. | public void | setTargetConnectionFactory(ConnectionFactory targetConnectionFactory) Set the target ConnectionFactory that this ConnectionFactory should delegate to. | public void | setUsername(String username) Set the username that this adapter should use for retrieving Connections. |
afterPropertiesSet | public void afterPropertiesSet()(Code) | | |
createConnection | final public Connection createConnection() throws JMSException(Code) | | Determine whether there are currently thread-bound credentials,
using them if available, falling back to the statically specified
username and password (i.e. values of the bean properties) else.
See Also: UserCredentialsConnectionFactoryAdapter.doCreateConnection |
createConnection | public Connection createConnection(String username, String password) throws JMSException(Code) | | Delegate the call straight to the target ConnectionFactory.
|
createQueueConnection | final public QueueConnection createQueueConnection() throws JMSException(Code) | | Determine whether there are currently thread-bound credentials,
using them if available, falling back to the statically specified
username and password (i.e. values of the bean properties) else.
See Also: UserCredentialsConnectionFactoryAdapter.doCreateQueueConnection |
createQueueConnection | public QueueConnection createQueueConnection(String username, String password) throws JMSException(Code) | | Delegate the call straight to the target QueueConnectionFactory.
|
createTopicConnection | final public TopicConnection createTopicConnection() throws JMSException(Code) | | Determine whether there are currently thread-bound credentials,
using them if available, falling back to the statically specified
username and password (i.e. values of the bean properties) else.
See Also: UserCredentialsConnectionFactoryAdapter.doCreateTopicConnection |
createTopicConnection | public TopicConnection createTopicConnection(String username, String password) throws JMSException(Code) | | Delegate the call straight to the target TopicConnectionFactory.
|
doCreateConnection | protected Connection doCreateConnection(String username, String password) throws JMSException(Code) | | This implementation delegates to the createConnection(username, password)
method of the target ConnectionFactory, passing in the specified user credentials.
If the specified username is empty, it will simply delegate to the standard
createConnection() method of the target ConnectionFactory.
Parameters: username - the username to use Parameters: password - the password to use the Connection See Also: javax.jms.ConnectionFactory.createConnection(StringString) See Also: javax.jms.ConnectionFactory.createConnection |
doCreateQueueConnection | protected QueueConnection doCreateQueueConnection(String username, String password) throws JMSException(Code) | | This implementation delegates to the createQueueConnection(username, password)
method of the target QueueConnectionFactory, passing in the specified user credentials.
If the specified username is empty, it will simply delegate to the standard
createQueueConnection() method of the target ConnectionFactory.
Parameters: username - the username to use Parameters: password - the password to use the Connection See Also: javax.jms.QueueConnectionFactory.createQueueConnection(StringString) See Also: javax.jms.QueueConnectionFactory.createQueueConnection |
doCreateTopicConnection | protected TopicConnection doCreateTopicConnection(String username, String password) throws JMSException(Code) | | This implementation delegates to the createTopicConnection(username, password)
method of the target TopicConnectionFactory, passing in the specified user credentials.
If the specified username is empty, it will simply delegate to the standard
createTopicConnection() method of the target ConnectionFactory.
Parameters: username - the username to use Parameters: password - the password to use the Connection See Also: javax.jms.TopicConnectionFactory.createTopicConnection(StringString) See Also: javax.jms.TopicConnectionFactory.createTopicConnection |
setCredentialsForCurrentThread | public void setCredentialsForCurrentThread(String username, String password)(Code) | | Set user credententials for this proxy and the current thread.
The given username and password will be applied to all subsequent
createConnection() calls on this ConnectionFactory proxy.
This will override any statically specified user credentials,
that is, values of the "username" and "password" bean properties.
Parameters: username - the username to apply Parameters: password - the password to apply See Also: UserCredentialsConnectionFactoryAdapter.removeCredentialsFromCurrentThread |
setPassword | public void setPassword(String password)(Code) | | Set the password that this adapter should use for retrieving Connections.
Default is no specific password.
|
setTargetConnectionFactory | public void setTargetConnectionFactory(ConnectionFactory targetConnectionFactory)(Code) | | Set the target ConnectionFactory that this ConnectionFactory should delegate to.
|
setUsername | public void setUsername(String username)(Code) | | Set the username that this adapter should use for retrieving Connections.
Default is no specific user.
|
|
|