activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject svn commit: r381762 - in /incubator/activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra: ActiveMQConnectionRequestInfo.java ActiveMQResourceAdapter.java
Date Tue, 28 Feb 2006 19:49:16 GMT
Author: jstrachan
Date: Tue Feb 28 11:49:15 2006
New Revision: 381762

URL: http://svn.apache.org/viewcvs?rev=381762&view=rev
Log:
change so that the connectionFactory property is always used if it is customized; if necessary,
creating a copy and configuring it if the ConnectionRequestInfo has some configuration inside
it

Modified:
    incubator/activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQConnectionRequestInfo.java
    incubator/activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQResourceAdapter.java

Modified: incubator/activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQConnectionRequestInfo.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQConnectionRequestInfo.java?rev=381762&r1=381761&r2=381762&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQConnectionRequestInfo.java
(original)
+++ incubator/activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQConnectionRequestInfo.java
Tue Feb 28 11:49:15 2006
@@ -18,6 +18,7 @@
 
 import org.apache.activemq.ActiveMQPrefetchPolicy;
 import org.apache.activemq.RedeliveryPolicy;
+import org.apache.activemq.ActiveMQConnectionFactory;
 
 import javax.resource.spi.ConnectionRequestInfo;
 import java.io.Serializable;
@@ -36,13 +37,15 @@
     private String serverUrl;
     private String clientid;
     private Boolean useInboundSession;
-    private RedeliveryPolicy redeliveryPolicy = new RedeliveryPolicy();
-    private ActiveMQPrefetchPolicy prefetchPolicy = new ActiveMQPrefetchPolicy();
+    private RedeliveryPolicy redeliveryPolicy;
+    private ActiveMQPrefetchPolicy prefetchPolicy;
 
     public ActiveMQConnectionRequestInfo copy() {
         try {
             ActiveMQConnectionRequestInfo answer = (ActiveMQConnectionRequestInfo) clone();
-            answer.redeliveryPolicy = redeliveryPolicy.copy();
+            if (redeliveryPolicy != null) {
+                answer.redeliveryPolicy = redeliveryPolicy.copy();
+            }
             return answer;
         }
         catch (CloneNotSupportedException e) {
@@ -51,6 +54,31 @@
     }
 
     /**
+     * Returns true if this object will configure an ActiveMQConnectionFactory in any way
+     */
+    public boolean isConnectionFactoryConfigured() {
+        return serverUrl != null || clientid != null || redeliveryPolicy != null || prefetchPolicy
!= null;
+    }
+
+    /**
+     * Configures the given connection factory
+     */
+    public void configure(ActiveMQConnectionFactory factory) {
+        if (serverUrl != null) {
+            factory.setBrokerURL(serverUrl);
+        }
+        if (clientid != null) {
+            factory.setClientID(clientid);
+        }
+        if (redeliveryPolicy != null) { 
+            factory.setRedeliveryPolicy(redeliveryPolicy);
+        }
+        if (prefetchPolicy != null) {
+            factory.setPrefetchPolicy(prefetchPolicy);
+        }
+    }
+    
+    /**
      * @see javax.resource.spi.ConnectionRequestInfo#hashCode()
      */
     public int hashCode() {
@@ -170,98 +198,98 @@
     }
 
     public Short getRedeliveryBackOffMultiplier() {
-        return new Short(redeliveryPolicy.getBackOffMultiplier());
+        return new Short(redeliveryPolicy().getBackOffMultiplier());
     }
 
     public Long getInitialRedeliveryDelay() {
-        return new Long(redeliveryPolicy.getInitialRedeliveryDelay());
+        return new Long(redeliveryPolicy().getInitialRedeliveryDelay());
     }
 
     public Integer getMaximumRedeliveries() {
-        return new Integer(redeliveryPolicy.getMaximumRedeliveries());
+        return new Integer(redeliveryPolicy().getMaximumRedeliveries());
     }
 
     public Boolean getRedeliveryUseExponentialBackOff() {
-        return new Boolean(redeliveryPolicy.isUseExponentialBackOff());
+        return new Boolean(redeliveryPolicy().isUseExponentialBackOff());
     }
 
     public void setRedeliveryBackOffMultiplier(Short value) {
         if (value != null) {
-            redeliveryPolicy.setBackOffMultiplier(value.shortValue());
+            redeliveryPolicy().setBackOffMultiplier(value.shortValue());
         }
     }
 
     public void setInitialRedeliveryDelay(Long value) {
         if (value != null) {
-            redeliveryPolicy.setInitialRedeliveryDelay(value.longValue());
+            redeliveryPolicy().setInitialRedeliveryDelay(value.longValue());
         }
     }
 
     public void setMaximumRedeliveries(Integer value) {
         if (value != null) {
-            redeliveryPolicy.setMaximumRedeliveries(value.intValue());
+            redeliveryPolicy().setMaximumRedeliveries(value.intValue());
         }
     }
 
     public void setRedeliveryUseExponentialBackOff(Boolean value) {
         if (value != null) {
-            redeliveryPolicy.setUseExponentialBackOff(value.booleanValue());
+            redeliveryPolicy().setUseExponentialBackOff(value.booleanValue());
         }
     }
 
     public Integer getDurableTopicPrefetch() {
-        return new Integer(prefetchPolicy.getDurableTopicPrefetch());
+        return new Integer(prefetchPolicy().getDurableTopicPrefetch());
     }
 
     public Integer getInputStreamPrefetch() {
-        return new Integer(prefetchPolicy.getInputStreamPrefetch());
+        return new Integer(prefetchPolicy().getInputStreamPrefetch());
     }
 
     public Integer getQueueBrowserPrefetch() {
-        return new Integer(prefetchPolicy.getQueueBrowserPrefetch());
+        return new Integer(prefetchPolicy().getQueueBrowserPrefetch());
     }
 
     public Integer getQueuePrefetch() {
-        return new Integer(prefetchPolicy.getQueuePrefetch());
+        return new Integer(prefetchPolicy().getQueuePrefetch());
     }
 
     public Integer getTopicPrefetch() {
-        return new Integer(prefetchPolicy.getTopicPrefetch());
+        return new Integer(prefetchPolicy().getTopicPrefetch());
     }
 
     public void setAllPrefetchValues(Integer i) {
         if (i != null) {
-            prefetchPolicy.setAll(i.intValue());
+            prefetchPolicy().setAll(i.intValue());
         }
     }
 
     public void setDurableTopicPrefetch(Integer durableTopicPrefetch) {
         if (durableTopicPrefetch != null) {
-            prefetchPolicy.setDurableTopicPrefetch(durableTopicPrefetch.intValue());
+            prefetchPolicy().setDurableTopicPrefetch(durableTopicPrefetch.intValue());
         }
     }
 
     public void setInputStreamPrefetch(Integer inputStreamPrefetch) {
         if (inputStreamPrefetch != null) {
-            prefetchPolicy.setInputStreamPrefetch(inputStreamPrefetch.intValue());
+            prefetchPolicy().setInputStreamPrefetch(inputStreamPrefetch.intValue());
         }
     }
 
     public void setQueueBrowserPrefetch(Integer queueBrowserPrefetch) {
         if (queueBrowserPrefetch != null) {
-            prefetchPolicy.setQueueBrowserPrefetch(queueBrowserPrefetch.intValue());
+            prefetchPolicy().setQueueBrowserPrefetch(queueBrowserPrefetch.intValue());
         }
     }
 
     public void setQueuePrefetch(Integer queuePrefetch) {
         if (queuePrefetch != null) {
-            prefetchPolicy.setQueuePrefetch(queuePrefetch.intValue());
+            prefetchPolicy().setQueuePrefetch(queuePrefetch.intValue());
         }
     }
 
     public void setTopicPrefetch(Integer topicPrefetch) {
         if (topicPrefetch != null) {
-            prefetchPolicy.setTopicPrefetch(topicPrefetch.intValue());
+            prefetchPolicy().setTopicPrefetch(topicPrefetch.intValue());
         }
     }
 
@@ -270,6 +298,9 @@
      * breaking compatibility with JCA configuration in J2EE
      */
     public RedeliveryPolicy redeliveryPolicy() {
+        if (redeliveryPolicy != null) {
+            redeliveryPolicy = new RedeliveryPolicy();
+        }
         return redeliveryPolicy;
     }
 
@@ -278,6 +309,9 @@
      * breaking compatibility with JCA configuration in J2EE
      */
     public ActiveMQPrefetchPolicy prefetchPolicy() {
+        if (prefetchPolicy != null) {
+            prefetchPolicy = new ActiveMQPrefetchPolicy();
+        }
         return prefetchPolicy;
     }
 }

Modified: incubator/activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQResourceAdapter.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQResourceAdapter.java?rev=381762&r1=381761&r2=381762&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQResourceAdapter.java
(original)
+++ incubator/activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQResourceAdapter.java
Tue Feb 28 11:49:15 2006
@@ -128,9 +128,14 @@
      * @throws URISyntaxException
      */
     synchronized private ActiveMQConnectionFactory createConnectionFactory(ActiveMQConnectionRequestInfo
info) throws JMSException {
-        ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(info.getServerUrl());
-        factory.setRedeliveryPolicy(info.redeliveryPolicy());
-        factory.setPrefetchPolicy(info.prefetchPolicy());
+        ActiveMQConnectionFactory factory = connectionFactory;
+        if (factory != null && info.isConnectionFactoryConfigured()) {
+            factory = factory.copy();
+        }
+        else if (factory == null) {
+            factory = new ActiveMQConnectionFactory();
+        }
+        info.configure(factory);
         return factory;
     }
 



Mime
View raw message