类 UserCredentialsConnectionFactoryAdapter

  • 所有已实现的接口:
    ConnectionFactory, QueueConnectionFactory, TopicConnectionFactory, InitializingBean

    public class UserCredentialsConnectionFactoryAdapter
    extends Object
    implements ConnectionFactory, QueueConnectionFactory, TopicConnectionFactory, InitializingBean
    An adapter for a target 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.

    从以下版本开始:
    1.2
    作者:
    Juergen Hoeller
    另请参阅:
    createConnection(), createQueueConnection(), createTopicConnection()