Return-Path: X-Original-To: apmail-activemq-commits-archive@www.apache.org Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 8D72111B86 for ; Thu, 10 Jul 2014 23:03:44 +0000 (UTC) Received: (qmail 3951 invoked by uid 500); 10 Jul 2014 23:03:44 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 3916 invoked by uid 500); 10 Jul 2014 23:03:44 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 3907 invoked by uid 99); 10 Jul 2014 23:03:44 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 10 Jul 2014 23:03:44 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 355079AC2A8; Thu, 10 Jul 2014 23:03:44 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: tabish@apache.org To: commits@activemq.apache.org Message-Id: <63c86590e1394b169e65447bb367ceb2@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: git commit: https://issues.apache.org/jira/browse/AMQ-5268 Date: Thu, 10 Jul 2014 23:03:44 +0000 (UTC) Repository: activemq Updated Branches: refs/heads/trunk e957937f0 -> b432173cf 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/b432173c Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/b432173c Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/b432173c Branch: refs/heads/trunk Commit: b432173cfcbf5dfbfad00849be4cf47021b455df Parents: e957937 Author: Timothy Bish Authored: Thu Jul 10 19:03:31 2014 -0400 Committer: Timothy Bish Committed: Thu Jul 10 19:03:31 2014 -0400 ---------------------------------------------------------------------- .../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/b432173c/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 a786691..67f45fd 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; @@ -557,4 +558,24 @@ public class PooledConnectionFactory implements ConnectionFactory, QueueConnecti 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/b432173c/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/b432173c/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; + } +}