activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject svn commit: r658393 - /activemq/trunk/activemq-core/src/main/java/org/apache/activemq/camel/component/ActiveMQConfiguration.java
Date Tue, 20 May 2008 18:53:20 GMT
Author: jstrachan
Date: Tue May 20 11:53:19 2008
New Revision: 658393

URL: http://svn.apache.org/viewvc?rev=658393&view=rev
Log:
add support for username/password properties

Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/camel/component/ActiveMQConfiguration.java

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/camel/component/ActiveMQConfiguration.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/camel/component/ActiveMQConfiguration.java?rev=658393&r1=658392&r2=658393&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/camel/component/ActiveMQConfiguration.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/camel/component/ActiveMQConfiguration.java
Tue May 20 11:53:19 2008
@@ -23,7 +23,9 @@
 import org.apache.activemq.spring.ActiveMQConnectionFactory;
 import org.apache.camel.component.jms.JmsConfiguration;
 import org.springframework.jms.connection.SingleConnectionFactory;
+import org.springframework.jms.connection.JmsTransactionManager;
 import org.springframework.jms.core.JmsTemplate;
+import org.springframework.transaction.PlatformTransactionManager;
 
 /**
  * @version $Revision$
@@ -32,6 +34,8 @@
     private String brokerURL = ActiveMQConnectionFactory.DEFAULT_BROKER_URL;
     private boolean useSingleConnection = false;
     private boolean usePooledConnection = true;
+    private String userName;
+    private String password;
 
     public ActiveMQConfiguration() {
     }
@@ -54,6 +58,31 @@
         return useSingleConnection;
     }
 
+    public String getUserName() {
+        return userName;
+    }
+
+    /**
+     * Sets the username to be used to login to ActiveMQ
+     * @param userName
+     */
+    public void setUserName(String userName) {
+        this.userName = userName;
+    }
+
+    public String getPassword() {
+        return password;
+    }
+
+    /**
+     * Sets the password/passcode used to login to ActiveMQ
+     *
+     * @param password
+     */
+    public void setPassword(String password) {
+        this.password = password;
+    }
+
     /**
      * Enables or disables whether a Spring {@link SingleConnectionFactory} will be used
so that when
      * messages are sent to ActiveMQ from outside of a message consuming thread, pooling
will be used rather
@@ -85,8 +114,35 @@
     }
 
     @Override
+    public PlatformTransactionManager getTransactionManager() {
+        PlatformTransactionManager answer = super.getTransactionManager();
+        if (isTransacted() && answer == null) {
+            // lets auto-default the transaction manager if its not specified
+            answer = createTransactionManager();
+            setTransactionManager(answer);
+            answer = getTransactionManager();
+        }
+        return answer;
+    }
+
+    /**
+     * Factory method to create a default transaction manager if one is not specified
+     */
+    protected PlatformTransactionManager createTransactionManager() {
+        JmsTransactionManager answer = new JmsTransactionManager(getConnectionFactory());
+        answer.afterPropertiesSet();
+        return answer;
+    }
+
+    @Override
     protected ConnectionFactory createConnectionFactory() {
         ActiveMQConnectionFactory answer = new ActiveMQConnectionFactory();
+        if (userName != null) {
+            answer.setUserName(userName);
+        }
+        if (password != null) {
+            answer.setPassword(password);
+        }
         if (answer.getBeanName() == null) {
             answer.setBeanName("Camel");
         }



Mime
View raw message