activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hadr...@apache.org
Subject [10/16] activemq git commit: https://issues.apache.org/jira/browse/AMQ-5268
Date Tue, 16 Dec 2014 22:09:58 GMT
https://issues.apache.org/jira/browse/AMQ-5268

Explicity set the properties from the generic JMS pooled
connectionfactory as the introspection based tools can easily get stuck
on getters that cause recursion or on inner types that have methods
which allow chaining.


Project: http://git-wip-us.apache.org/repos/asf/activemq/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/00426a9a
Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/00426a9a
Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/00426a9a

Branch: refs/heads/activemq-5.10.x
Commit: 00426a9ae138df4d10b1e3beb72b2f60c9b786f9
Parents: f8ccdfb
Author: Timothy Bish <tabish121@gmail.com>
Authored: Thu Jul 10 19:03:31 2014 -0400
Committer: Hadrian Zbarcea <hadrian@apache.org>
Committed: Mon Dec 15 19:27:25 2014 -0500

----------------------------------------------------------------------
 .../jms/pool/PooledConnectionFactory.java       | 21 +++++++++
 .../activemq/pool/PooledConnectionFactory.java  |  8 ++--
 .../pool/PooledConnectionFactoryTest.java       | 47 ++++++++++++++++++++
 3 files changed, 73 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/00426a9a/activemq-jms-pool/src/main/java/org/apache/activemq/jms/pool/PooledConnectionFactory.java
----------------------------------------------------------------------
diff --git a/activemq-jms-pool/src/main/java/org/apache/activemq/jms/pool/PooledConnectionFactory.java
b/activemq-jms-pool/src/main/java/org/apache/activemq/jms/pool/PooledConnectionFactory.java
index 12852ce..35e460a 100644
--- a/activemq-jms-pool/src/main/java/org/apache/activemq/jms/pool/PooledConnectionFactory.java
+++ b/activemq-jms-pool/src/main/java/org/apache/activemq/jms/pool/PooledConnectionFactory.java
@@ -16,6 +16,7 @@
  */
 package org.apache.activemq.jms.pool;
 
+import java.util.Properties;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicReference;
 
@@ -539,4 +540,24 @@ public class PooledConnectionFactory implements ConnectionFactory {
     public void setBlockIfSessionPoolIsFullTimeout(long blockIfSessionPoolIsFullTimeout)
{
         this.blockIfSessionPoolIsFullTimeout = blockIfSessionPoolIsFullTimeout;
     }
+
+    /**
+     * Called by any superclass that implements a JNDIReferencable or similar that needs
to collect
+     * the properties of this class for storage etc.
+     *
+     * This method should be updated any time there is a new property added.
+     *
+     * @param props
+     *        a properties object that should be filled in with this objects property values.
+     */
+    protected void populateProperties(Properties props) {
+        props.setProperty("maximumActiveSessionPerConnection", Integer.toString(getMaximumActiveSessionPerConnection()));
+        props.setProperty("maxConnections", Integer.toString(getMaxConnections()));
+        props.setProperty("idleTimeout", Integer.toString(getIdleTimeout()));
+        props.setProperty("expiryTimeout", Long.toString(getExpiryTimeout()));
+        props.setProperty("timeBetweenExpirationCheckMillis", Long.toString(getTimeBetweenExpirationCheckMillis()));
+        props.setProperty("createConnectionOnStartup", Boolean.toString(isCreateConnectionOnStartup()));
+        props.setProperty("useAnonymousProducers", Boolean.toString(isUseAnonymousProducers()));
+        props.setProperty("blockIfSessionPoolIsFullTimeout", Long.toString(getBlockIfSessionPoolIsFullTimeout()));
+    }
 }

http://git-wip-us.apache.org/repos/asf/activemq/blob/00426a9a/activemq-pool/src/main/java/org/apache/activemq/pool/PooledConnectionFactory.java
----------------------------------------------------------------------
diff --git a/activemq-pool/src/main/java/org/apache/activemq/pool/PooledConnectionFactory.java
b/activemq-pool/src/main/java/org/apache/activemq/pool/PooledConnectionFactory.java
index 62b97f9..1cd5130 100644
--- a/activemq-pool/src/main/java/org/apache/activemq/pool/PooledConnectionFactory.java
+++ b/activemq-pool/src/main/java/org/apache/activemq/pool/PooledConnectionFactory.java
@@ -19,9 +19,11 @@ package org.apache.activemq.pool;
 import java.io.IOException;
 import java.util.HashMap;
 import java.util.Properties;
+
 import javax.jms.Connection;
 import javax.naming.NamingException;
 import javax.naming.Reference;
+
 import org.apache.activemq.ActiveMQConnection;
 import org.apache.activemq.ActiveMQConnectionFactory;
 import org.apache.activemq.Service;
@@ -55,6 +57,7 @@ public class PooledConnectionFactory extends org.apache.activemq.jms.pool.Pooled
         setConnectionFactory(new ActiveMQConnectionFactory(brokerURL));
     }
 
+    @SuppressWarnings({ "unchecked", "rawtypes" })
     protected void buildFromProperties(Properties props) {
         ActiveMQConnectionFactory activeMQConnectionFactory = new ActiveMQConnectionFactory();
         activeMQConnectionFactory.buildFromProperties(props);
@@ -62,9 +65,10 @@ public class PooledConnectionFactory extends org.apache.activemq.jms.pool.Pooled
         IntrospectionSupport.setProperties(this, new HashMap(props), POOL_PROPS_PREFIX);
     }
 
+    @Override
     protected void populateProperties(Properties props) {
         ((ActiveMQConnectionFactory)getConnectionFactory()).populateProperties(props);
-        IntrospectionSupport.getProperties(this, props, POOL_PROPS_PREFIX);
+        super.populateProperties(props);
     }
 
     @Override
@@ -79,7 +83,6 @@ public class PooledConnectionFactory extends org.apache.activemq.jms.pool.Pooled
         return properties;
     }
 
-
     @Override
     public Reference getReference() throws NamingException {
         return JNDIReferenceFactory.createReference(this.getClass().getName(), this);
@@ -137,5 +140,4 @@ public class PooledConnectionFactory extends org.apache.activemq.jms.pool.Pooled
             }
         };
     }
-
 }

http://git-wip-us.apache.org/repos/asf/activemq/blob/00426a9a/activemq-pool/src/test/java/org/apache/activemq/pool/PooledConnectionFactoryTest.java
----------------------------------------------------------------------
diff --git a/activemq-pool/src/test/java/org/apache/activemq/pool/PooledConnectionFactoryTest.java
b/activemq-pool/src/test/java/org/apache/activemq/pool/PooledConnectionFactoryTest.java
new file mode 100644
index 0000000..e2e33cd
--- /dev/null
+++ b/activemq-pool/src/test/java/org/apache/activemq/pool/PooledConnectionFactoryTest.java
@@ -0,0 +1,47 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.pool;
+
+import static org.junit.Assert.assertNotNull;
+
+import javax.naming.Reference;
+
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Test JNDI
+ */
+public class PooledConnectionFactoryTest {
+
+    private final Logger LOG = LoggerFactory.getLogger(PooledConnectionFactoryTest.class);
+
+    @Test(timeout=240000)
+    public void testGetReference() throws Exception {
+        PooledConnectionFactory factory = createPooledConnectionFactory();
+        Reference ref = factory.getReference();
+        assertNotNull(ref);
+    }
+
+    protected PooledConnectionFactory createPooledConnectionFactory() {
+        PooledConnectionFactory cf = new PooledConnectionFactory(
+            "vm://localhost?broker.persistent=false");
+        LOG.debug("ConnectionFactory initialized.");
+        return cf;
+    }
+}


Mime
View raw message