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 6316810FF8 for ; Mon, 4 Nov 2013 21:51:30 +0000 (UTC) Received: (qmail 10849 invoked by uid 500); 4 Nov 2013 21:51:30 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 10824 invoked by uid 500); 4 Nov 2013 21:51:30 -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 10817 invoked by uid 99); 4 Nov 2013 21:51:30 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 04 Nov 2013 21:51:30 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 050443D3D3; Mon, 4 Nov 2013 21:51:29 +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: <4e0cad879d3644ffa335be0411967ea7@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: git commit: polish Date: Mon, 4 Nov 2013 21:51:29 +0000 (UTC) Updated Branches: refs/heads/trunk 4e3595d48 -> d87299426 polish Project: http://git-wip-us.apache.org/repos/asf/activemq/repo Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/d8729942 Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/d8729942 Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/d8729942 Branch: refs/heads/trunk Commit: d872994260df2f7591f35d6a260cb474e9508e4d Parents: 4e3595d Author: Timothy Bish Authored: Mon Nov 4 16:50:37 2013 -0500 Committer: Timothy Bish Committed: Mon Nov 4 16:51:09 2013 -0500 ---------------------------------------------------------------------- .../jms/pool/PooledConnectionFactory.java | 96 ++++++++++---------- 1 file changed, 48 insertions(+), 48 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/activemq/blob/d8729942/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 bf49f2d..64eaad2 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 @@ -21,8 +21,8 @@ import java.util.concurrent.atomic.AtomicBoolean; import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.JMSException; - import javax.jms.XAConnectionFactory; + import org.apache.commons.pool.KeyedPoolableObjectFactory; import org.apache.commons.pool.impl.GenericKeyedObjectPool; import org.slf4j.Logger; @@ -71,62 +71,61 @@ public class PooledConnectionFactory implements ConnectionFactory { private long expiryTimeout = 0l; private boolean createConnectionOnStartup = true; - public void initConnectionsPool() { if (this.connectionsPool == null) { this.connectionsPool = new GenericKeyedObjectPool( - new KeyedPoolableObjectFactory() { + new KeyedPoolableObjectFactory() { - @Override - public void activateObject(ConnectionKey key, ConnectionPool connection) throws Exception { - } + @Override + public void activateObject(ConnectionKey key, ConnectionPool connection) throws Exception { + } - @Override - public void destroyObject(ConnectionKey key, ConnectionPool connection) throws Exception { - try { - if (LOG.isTraceEnabled()) { - LOG.trace("Destroying connection: {}", connection); - } - connection.close(); - } catch (Exception e) { - LOG.warn("Close connection failed for connection: " + connection + ". This exception will be ignored.",e); + @Override + public void destroyObject(ConnectionKey key, ConnectionPool connection) throws Exception { + try { + if (LOG.isTraceEnabled()) { + LOG.trace("Destroying connection: {}", connection); } + connection.close(); + } catch (Exception e) { + LOG.warn("Close connection failed for connection: " + connection + ". This exception will be ignored.",e); } + } - @Override - public ConnectionPool makeObject(ConnectionKey key) throws Exception { - Connection delegate = createConnection(key); + @Override + public ConnectionPool makeObject(ConnectionKey key) throws Exception { + Connection delegate = createConnection(key); - ConnectionPool connection = createConnectionPool(delegate); - connection.setIdleTimeout(getIdleTimeout()); - connection.setExpiryTimeout(getExpiryTimeout()); - connection.setMaximumActiveSessionPerConnection(getMaximumActiveSessionPerConnection()); - connection.setBlockIfSessionPoolIsFull(isBlockIfSessionPoolIsFull()); + ConnectionPool connection = createConnectionPool(delegate); + connection.setIdleTimeout(getIdleTimeout()); + connection.setExpiryTimeout(getExpiryTimeout()); + connection.setMaximumActiveSessionPerConnection(getMaximumActiveSessionPerConnection()); + connection.setBlockIfSessionPoolIsFull(isBlockIfSessionPoolIsFull()); - if (LOG.isTraceEnabled()) { - LOG.trace("Created new connection: {}", connection); - } - - return connection; + if (LOG.isTraceEnabled()) { + LOG.trace("Created new connection: {}", connection); } - @Override - public void passivateObject(ConnectionKey key, ConnectionPool connection) throws Exception { - } + return connection; + } - @Override - public boolean validateObject(ConnectionKey key, ConnectionPool connection) { - if (connection != null && connection.expiredCheck()) { - if (LOG.isTraceEnabled()) { - LOG.trace("Connection has expired: {} and will be destroyed", connection); - } + @Override + public void passivateObject(ConnectionKey key, ConnectionPool connection) throws Exception { + } - return false; + @Override + public boolean validateObject(ConnectionKey key, ConnectionPool connection) { + if (connection != null && connection.expiredCheck()) { + if (LOG.isTraceEnabled()) { + LOG.trace("Connection has expired: {} and will be destroyed", connection); } - return true; + return false; } - }); + + return true; + } + }); // Set max idle (not max active) since our connections always idle in the pool. this.connectionsPool.setMaxIdle(1); @@ -157,13 +156,15 @@ public class PooledConnectionFactory implements ConnectionFactory { public void setConnectionFactory(final ConnectionFactory toUse) { if (toUse instanceof XAConnectionFactory) { connectionFactory = new ConnectionFactory() { - public Connection createConnection() throws JMSException { - return ((XAConnectionFactory)toUse).createXAConnection(); - } - public Connection createConnection(String userName, String password) throws JMSException { - return ((XAConnectionFactory)toUse).createXAConnection(userName, password); - } - }; + @Override + public Connection createConnection() throws JMSException { + return ((XAConnectionFactory)toUse).createXAConnection(); + } + @Override + public Connection createConnection(String userName, String password) throws JMSException { + return ((XAConnectionFactory)toUse).createXAConnection(userName, password); + } + }; } else { this.connectionFactory = toUse; } @@ -475,5 +476,4 @@ public class PooledConnectionFactory implements ConnectionFactory { protected ConnectionPool createConnectionPool(Connection connection) { return new ConnectionPool(connection); } - }