[jboss-cvs] JBossAS SVN: r106984 - in projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager: listener and 5 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Jul 21 11:57:09 EDT 2010
Author: jesper.pedersen
Date: 2010-07-21 11:57:08 -0400 (Wed, 21 Jul 2010)
New Revision: 106984
Added:
projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/ManagedConnectionPool.java
Removed:
projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/InternalManagedConnectionPool.java
Modified:
projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/AbstractConnectionManager.java
projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/ConnectionManager.java
projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/ConnectionRecord.java
projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/listener/AbstractConnectionListener.java
projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/listener/NoTxConnectionListener.java
projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/listener/TxConnectionListener.java
projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/AbstractPool.java
projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/PoolFiller.java
projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/SubPoolContext.java
projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/api/Pool.java
projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/strategy/OnePool.java
projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/validator/ConnectionValidator.java
projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/xa/LocalXAResource.java
Log:
[JBJCA-384] Refactor connection manager (Part 4)
Modified: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/AbstractConnectionManager.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/AbstractConnectionManager.java 2010-07-21 15:32:07 UTC (rev 106983)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/AbstractConnectionManager.java 2010-07-21 15:57:08 UTC (rev 106984)
@@ -517,11 +517,10 @@
if (unsharableResources.contains(jndiName))
{
log.trace("disconnect for unshareable connection: nothing to do");
-
return;
}
- Set<ConnectionListener> cls = new HashSet<ConnectionListener>();
+ Set<ConnectionListener> cls = new HashSet<ConnectionListener>(conRecords.size());
for (Iterator<ConnectionRecord> i = conRecords.iterator(); i.hasNext();)
{
ConnectionRecord cr = i.next();
@@ -553,7 +552,7 @@
}
Map<ConnectionRequestInfo, ConnectionListener> criToCLMap =
- new HashMap<ConnectionRequestInfo, ConnectionListener>();
+ new HashMap<ConnectionRequestInfo, ConnectionListener>(conns.size());
for (Iterator<ConnectionRecord> i = conns.iterator(); i.hasNext();)
{
@@ -577,9 +576,6 @@
registerAssociation(cl, cr.getConnection());
cr.setConnectionListener(cl);
}
-
- criToCLMap.clear();
-
}
/**
Modified: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/ConnectionManager.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/ConnectionManager.java 2010-07-21 15:32:07 UTC (rev 106983)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/ConnectionManager.java 2010-07-21 15:57:08 UTC (rev 106984)
@@ -21,7 +21,9 @@
*/
package org.jboss.jca.core.connectionmanager;
+import org.jboss.jca.core.connectionmanager.ccm.CachedConnectionManager;
import org.jboss.jca.core.connectionmanager.listener.ConnectionCacheListener;
+import org.jboss.jca.core.connectionmanager.listener.ConnectionListener;
import org.jboss.jca.core.connectionmanager.listener.ConnectionListenerFactory;
import org.jboss.jca.core.connectionmanager.pool.api.Pool;
import org.jboss.jca.core.connectionmanager.transaction.JTATransactionChecker;
@@ -61,4 +63,24 @@
* @return the pool
*/
public Pool getPool();
+
+ /**
+ * Gets cached connection manager
+ * @return The cached connection manager
+ */
+ public CachedConnectionManager getCachedConnectionManager();
+
+ /**
+ * Kill given connection listener wrapped connection instance.
+ * @param cl connection listener that wraps connection
+ * @param kill kill connection or not
+ */
+ public void returnManagedConnection(ConnectionListener cl, boolean kill);
+
+ /**
+ * Unregister association.
+ * @param cl connection listener
+ * @param c connection
+ */
+ public void unregisterAssociation(ConnectionListener cl, Object c);
}
Modified: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/ConnectionRecord.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/ConnectionRecord.java 2010-07-21 15:32:07 UTC (rev 106983)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/ConnectionRecord.java 2010-07-21 15:57:08 UTC (rev 106984)
@@ -31,7 +31,7 @@
* @author <a href="mailto:d_jencks at users.sourceforge.net">David Jencks</a>
* @author <a href="mailto:adrian at jboss.org">Adrian Brock</a>
* @author <a href="mailto:gurkanerdogdu at yahoo.com">Gurkan Erdogdu</a>
- * @version $Revision: 71554 $
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
*/
public class ConnectionRecord
{
@@ -55,7 +55,8 @@
}
/**
- * @return the cl
+ * Get the connection listener
+ * @return The listener
*/
public ConnectionListener getConnectionListener()
{
@@ -63,7 +64,8 @@
}
/**
- * @param cl the cl to set
+ * Set the connection listener
+ * @param cl The listener
*/
void setConnectionListener(ConnectionListener cl)
{
@@ -71,7 +73,8 @@
}
/**
- * @return the connection
+ * Get the connection
+ * @return The connection
*/
public Object getConnection()
{
@@ -79,11 +82,11 @@
}
/**
- * @return the cri
+ * Get the connection request info information
+ * @return The information
*/
public ConnectionRequestInfo getCri()
{
return cri;
}
-
}
Modified: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/listener/AbstractConnectionListener.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/listener/AbstractConnectionListener.java 2010-07-21 15:32:07 UTC (rev 106983)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/listener/AbstractConnectionListener.java 2010-07-21 15:57:08 UTC (rev 106984)
@@ -21,7 +21,7 @@
*/
package org.jboss.jca.core.connectionmanager.listener;
-import org.jboss.jca.core.connectionmanager.AbstractConnectionManager;
+import org.jboss.jca.core.connectionmanager.ConnectionManager;
import org.jboss.jca.core.connectionmanager.ccm.CachedConnectionManager;
import org.jboss.jca.core.connectionmanager.pool.api.Pool;
@@ -48,39 +48,39 @@
{
private Logger log = Logger.getLogger(getClass());
- /** Wraps managed connection instance*/
+ /** Log trace */
+ protected boolean trace;
+
+ /** Connection Manager */
+ private ConnectionManager cm;
+
+ /** Managed connection */
private final ManagedConnection managedConnection;
- /** Pool for this connection*/
+ /** Pool for this connection */
private final Pool pool;
- /** Pool internal context*/
+ /** Pool internal context */
private final Object internalManagedPoolContext;
- /** Connection State*/
+ /** Connection State */
private ConnectionState state = ConnectionState.NORMAL;
- /** Connection handles*/
+ /** Connection handles */
private final CopyOnWriteArrayList<Object> connectionHandles = new CopyOnWriteArrayList<Object>();
- /**Track by transaction or not*/
+ /** Track by transaction or not */
private AtomicBoolean trackByTx = new AtomicBoolean(false);
- /**Connection permit*/
+ /** Connection permit */
private boolean permit;
- /**Connection last use*/
+ /** Connection last use */
private long lastUse;
- /**Connection last validated time*/
+ /** Connection last validated time */
private long lastValidated;
- /**Log trace*/
- protected boolean trace;
-
- /**Connection Manager*/
- private AbstractConnectionManager cm;
-
/**
* Creates a new instance of the listener that is responsible for
* tracking the owned connection instance.
@@ -89,7 +89,7 @@
* @param context pool internal context
* @param cm connection manager
*/
- protected AbstractConnectionListener(AbstractConnectionManager cm, ManagedConnection managedConnection,
+ protected AbstractConnectionListener(ConnectionManager cm, ManagedConnection managedConnection,
Pool pool, Object context)
{
this.cm = cm;
@@ -113,7 +113,7 @@
* Gets connection manager.
* @return connection manager
*/
- protected AbstractConnectionManager getConnectionManager()
+ protected ConnectionManager getConnectionManager()
{
return this.cm;
}
@@ -289,8 +289,8 @@
while (itHandles.hasNext())
{
Object handle = itHandles.next();
- this.log.info("Unregister connection handle : " + handle + " from Cached connection manager");
- //getCcm().unregisterConnection(BaseConnectionManager2.this, i.next());
+ if (getCachedConnectionManager() != null)
+ getCachedConnectionManager().unregisterConnection(getConnectionManager(), handle);
}
}
finally
Modified: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/listener/NoTxConnectionListener.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/listener/NoTxConnectionListener.java 2010-07-21 15:32:07 UTC (rev 106983)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/listener/NoTxConnectionListener.java 2010-07-21 15:57:08 UTC (rev 106984)
@@ -21,7 +21,7 @@
*/
package org.jboss.jca.core.connectionmanager.listener;
-import org.jboss.jca.core.connectionmanager.AbstractConnectionManager;
+import org.jboss.jca.core.connectionmanager.ConnectionManager;
import org.jboss.jca.core.connectionmanager.pool.api.Pool;
import javax.resource.spi.ConnectionEvent;
@@ -32,7 +32,7 @@
* NoTx Connection Listener.
*
* @author <a href="mailto:gurkanerdogdu at yahoo.com">Gurkan Erdogdu</a>
- * @version $Rev$
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
* @see AbstractConnectionListener
*/
public class NoTxConnectionListener extends AbstractConnectionListener
@@ -44,7 +44,7 @@
* @param pool pool
* @param context context
*/
- public NoTxConnectionListener(final AbstractConnectionManager cm, final ManagedConnection mc,
+ public NoTxConnectionListener(final ConnectionManager cm, final ManagedConnection mc,
final Pool pool, final Object context)
{
super(cm, mc, pool, context);
@@ -74,5 +74,4 @@
getConnectionManager().returnManagedConnection(this, false);
}
}
-
}
Modified: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/listener/TxConnectionListener.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/listener/TxConnectionListener.java 2010-07-21 15:32:07 UTC (rev 106983)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/listener/TxConnectionListener.java 2010-07-21 15:57:08 UTC (rev 106984)
@@ -22,7 +22,7 @@
package org.jboss.jca.core.connectionmanager.listener;
import org.jboss.jca.common.JBossResourceException;
-import org.jboss.jca.core.connectionmanager.AbstractConnectionManager;
+import org.jboss.jca.core.connectionmanager.ConnectionManager;
import org.jboss.jca.core.connectionmanager.pool.api.Pool;
import org.jboss.jca.core.connectionmanager.transaction.TransactionSynchronizer;
import org.jboss.jca.core.connectionmanager.tx.TxConnectionManager;
@@ -71,7 +71,7 @@
* @param xaResource xaresource instance
* @throws ResourceException if aexception while creating
*/
- public TxConnectionListener(final AbstractConnectionManager cm, final ManagedConnection mc,
+ public TxConnectionListener(final ConnectionManager cm, final ManagedConnection mc,
final Pool pool, final Object context, final XAResource xaResource)
throws ResourceException
{
Modified: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/AbstractPool.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/AbstractPool.java 2010-07-21 15:32:07 UTC (rev 106983)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/AbstractPool.java 2010-07-21 15:57:08 UTC (rev 106984)
@@ -182,7 +182,7 @@
/**
* {@inheritDoc}
*/
- public void emptySubPool(InternalManagedConnectionPool pool)
+ public void emptySubPool(ManagedConnectionPool pool)
{
if (pool != null)
{
@@ -239,7 +239,7 @@
SubPoolContext subPoolContext = getSubPool(key, subject, cri);
//Sub-pool internal managed connection pool
- InternalManagedConnectionPool imcp = subPoolContext.getSubPool();
+ ManagedConnectionPool imcp = subPoolContext.getSubPool();
// Are we doing track by transaction?
TransactionLocal trackByTx = subPoolContext.getTrackByTx();
@@ -277,7 +277,7 @@
throws ResourceException
{
ConnectionListener cl = null;
- InternalManagedConnectionPool imcp = null;
+ ManagedConnectionPool imcp = null;
try
{
@@ -379,7 +379,7 @@
* @throws ResourceException
*/
private ConnectionListener getTransactionNewConnection(TransactionLocal trackByTx, Transaction trackByTransaction,
- InternalManagedConnectionPool mcp, Subject subject, ConnectionRequestInfo cri)
+ ManagedConnectionPool mcp, Subject subject, ConnectionRequestInfo cri)
throws ResourceException
{
ConnectionListener cl = null;
@@ -462,7 +462,7 @@
{
cl.setTrackByTx(false);
//Get connection listener pool
- InternalManagedConnectionPool mcp = (InternalManagedConnectionPool) cl.getContext();
+ ManagedConnectionPool mcp = (ManagedConnectionPool) cl.getContext();
//Return connection to the pool
mcp.returnConnection(cl, kill);
Deleted: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/InternalManagedConnectionPool.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/InternalManagedConnectionPool.java 2010-07-21 15:32:07 UTC (rev 106983)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/InternalManagedConnectionPool.java 2010-07-21 15:57:08 UTC (rev 106984)
@@ -1,939 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008-2009, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.jca.core.connectionmanager.pool;
-
-import org.jboss.jca.common.JBossResourceException;
-import org.jboss.jca.core.connectionmanager.listener.ConnectionListener;
-import org.jboss.jca.core.connectionmanager.listener.ConnectionListenerFactory;
-import org.jboss.jca.core.connectionmanager.listener.ConnectionState;
-import org.jboss.jca.core.connectionmanager.pool.api.PoolConfiguration;
-import org.jboss.jca.core.connectionmanager.pool.idle.IdleConnectionRemovalSupport;
-import org.jboss.jca.core.connectionmanager.pool.idle.IdleRemover;
-import org.jboss.jca.core.connectionmanager.pool.validator.ConnectionValidator;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-import java.util.concurrent.CopyOnWriteArrayList;
-import java.util.concurrent.CopyOnWriteArraySet;
-import java.util.concurrent.Semaphore;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-import javax.resource.ResourceException;
-import javax.resource.spi.ConnectionRequestInfo;
-import javax.resource.spi.ManagedConnection;
-import javax.resource.spi.ManagedConnectionFactory;
-import javax.resource.spi.RetryableUnavailableException;
-import javax.resource.spi.ValidatingManagedConnectionFactory;
-import javax.security.auth.Subject;
-
-import org.jboss.logging.Logger;
-import org.jboss.util.UnreachableStatementException;
-
-
-/**
- * Actual internal managed connection pool.
- *
- * <p>
- * Contains and manages the {@link ConnectionListener} instances.
- * Each pool strategy can contains several {@link SubPoolContext} instance
- * that contains {@link InternalManagedConnectionPool} internally.
- * </p>
- *
- * <p>
- * Each internal managed connection pool instances could be
- * differentiated by a key.
- * </p>
- * @author <a href="mailto:d_jencks at users.sourceforge.net">David Jencks</a>
- * @author <a href="mailto:adrian at jboss.org">Adrian Brock</a>
- * @author <a href="mailto:weston.price at jboss.com">Weston Price</a>
- * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
- * @author <a href="mailto:gurkanerdogdu at yahoo.com">Gurkan Erdogdu</a>
- *
- * @version $Rev: $
- *
- * @see AbstractPool
- */
-public class InternalManagedConnectionPool implements IdleConnectionRemovalSupport
-{
- /** The log */
- private static Logger log = Logger.getLogger(InternalManagedConnectionPool.class);
-
- /** Whether trace is enabled */
- private final boolean trace = log.isTraceEnabled();
-
- /** The managed connection factory */
- private final ManagedConnectionFactory mcf;
-
- /** The connection listener factory */
- private final ConnectionListenerFactory clf;
-
- /** The default subject */
- private final Subject defaultSubject;
-
- /** The default connection request information */
- private final ConnectionRequestInfo defaultCri;
-
- /** The pool configuration */
- private final PoolConfiguration poolConfiguration;
-
- /** Copy of the maximum size from the pooling parameters.
- * Dynamic changes to this value are not compatible with
- * the semaphore which cannot change be dynamically changed.
- */
- private int maxSize;
-
- /** The available connection event listeners */
- private CopyOnWriteArrayList<ConnectionListener> cls = new CopyOnWriteArrayList<ConnectionListener>();
-
- /** The permits used to control who can checkout a connection */
- private final Semaphore permits;
-
- /** The checked out connections */
- private final CopyOnWriteArraySet<ConnectionListener> checkedOut = new CopyOnWriteArraySet<ConnectionListener>();
-
- /** Whether the pool has been started */
- private AtomicBoolean started = new AtomicBoolean(false);
-
- /** Whether the pool has been shutdown */
- private AtomicBoolean shutdown = new AtomicBoolean(false);
-
- /** the max connections ever checked out **/
- private volatile int maxUsedConnections = 0;
-
- /**
- * Create a new InternalManagedConnectionPool.
- *
- * @param mcf the managed connection factory
- * @param clf the connection listener factory
- * @param subject the subject
- * @param cri the connection request info
- * @param pc the pool configuration
- */
- public InternalManagedConnectionPool(ManagedConnectionFactory mcf, ConnectionListenerFactory clf, Subject subject,
- ConnectionRequestInfo cri, PoolConfiguration pc)
- {
- if (mcf == null)
- throw new IllegalArgumentException("MCF is null");
-
- if (clf == null)
- throw new IllegalArgumentException("CLF is null");
-
- if (pc == null)
- throw new IllegalArgumentException("PoolConfiguration is null");
-
- this.mcf = mcf;
- this.clf = clf;
- this.defaultSubject = subject;
- this.defaultCri = cri;
- this.poolConfiguration = pc;
- this.maxSize = pc.getMaxSize();
- this.permits = new Semaphore(this.maxSize, true);
-
- if (pc.isPrefill())
- {
- PoolFiller.fillPool(this);
- }
- }
-
- /**
- * Returns a connection listener that wraps managed connection.
- * @param subject subject
- * @param cri connection request info
- * @return connection listener wrapped managed connection
- * @throws ResourceException exception
- */
- public ConnectionListener getConnection(Subject subject, ConnectionRequestInfo cri) throws ResourceException
- {
- ConnectionListener connectionListener = null;
-
- if (subject == null)
- {
- subject = this.defaultSubject;
- }
-
- if (cri == null)
- {
- cri = this.defaultCri;
- }
-
- //Use in blocked time
- long startWait = System.currentTimeMillis();
-
- try
- {
- //Check connection is available, and if not waits for the blocking timeout
- if (this.permits.tryAcquire(this.poolConfiguration.getBlockingTimeout(), TimeUnit.MILLISECONDS))
- {
- do
- {
- //Check shutdown
- if (this.shutdown.get())
- {
- permits.release();
- throw new RetryableUnavailableException("The pool has been shut down");
- }
-
- if (cls.size() > 0)
- {
- connectionListener = this.cls.remove(this.cls.size() - 1);
- this.checkedOut.add(connectionListener);
-
- //Max used connections, maxSize - permits.aval --> gives current used connection!
- int size = (maxSize - permits.availablePermits());
- if (size > maxUsedConnections)
- {
- maxUsedConnections = size;
- }
-
- if (connectionListener != null)
- {
- try
- {
- //Match connection
- ConnectionListener matchedConnectionListener =
- isManagedConnectionMatched(connectionListener, subject, cri);
-
- //Connection matched
- if (matchedConnectionListener != null)
- {
- connectionListener = matchedConnectionListener;
- break;
- }
-
- //Match did not succeed but no exception was thrown.
- //Either we have the matching strategy wrong or the
- //connection died while being checked. We need to
- //distinguish these cases, but for now we always
- //destroy the connection.
- log.warn("Destroying connection that could not be successfully matched: " + connectionListener);
- removesAndDestorysConnectionListener(connectionListener);
-
- }
- catch (Throwable t)
- {
- log.warn("Throwable while trying to match ManagedConnection,destroying connection: "
- + connectionListener, t);
- removesAndDestorysConnectionListener(connectionListener);
- }
-
- //We made it here, something went wrong and we should validate if
- //we should continue attempting to acquire a connection
- if (this.poolConfiguration.isUseFastFail())
- {
- log.trace("Fast failing for connection attempt. No more attempts will " +
- "be made to acquire connection from pool and a new connection " +
- "will be created immeadiately");
- break;
- }
-
- } //connectionListener != null
- } //cls.size > 0
- }
- while (this.cls.size() > 0);
-
- //Check connection
- if (connectionListener == null)
- {
- //Ok, no connection in the pool. Creates a new managed connection instance!
- connectionListener = createsNewManagedConnection(subject, cri);
- }
-
- }
- else
- {
- // we timed out
- throw new ResourceException("No ManagedConnections available within configured blocking timeout ( "
- + this.poolConfiguration.getBlockingTimeout() + " [ms] )");
- }
-
- }
- catch (InterruptedException e)
- {
- long end = System.currentTimeMillis() - startWait;
- throw new ResourceException("Interrupted while requesting permit! Waited " + end + " ms");
- }
-
- return connectionListener;
- }
-
- /**
- * Removes and destroys given connection.
- * @param connectionListener connection listener
- */
- private void removesAndDestorysConnectionListener(ConnectionListener connectionListener)
- {
- this.checkedOut.remove(connectionListener);
-
- //Destroy it
- doDestroy(connectionListener);
- }
-
- /**
- * Returns given listener if there is a matched connection false ow.
- * @param connectionListener connection listener
- * @param subject subject
- * @param cri connection request info
- * @return true if there is a matched connection false ow.
- */
- private ConnectionListener isManagedConnectionMatched(ConnectionListener connectionListener,
- Subject subject, ConnectionRequestInfo cri) throws ResourceException
- {
- ManagedConnection managedConnection = connectionListener.getManagedConnection();
- managedConnection = this.mcf.matchManagedConnections(Collections.singleton(managedConnection), subject , cri);
-
- //There is a match
- if (managedConnection != null)
- {
- if (trace)
- {
- log.trace("supplying ManagedConnection from pool: " + connectionListener);
- }
-
- connectionListener.grantPermit(true);
-
- return connectionListener;
- }
-
- return null;
- }
-
- /**
- * Creates a new connection listener.
- * @param subject subject instance
- * @param cri connection request info
- * @return new connection listener
- * @throws ResourceException
- */
- private ConnectionListener createsNewManagedConnection(Subject subject, ConnectionRequestInfo cri)
- throws ResourceException
- {
- ConnectionListener cl = null;
- try
- {
- //No, the pool was empty, so we have to make a new one.
- cl = createsConnectionEventListener(subject, cri);
-
- checkedOut.add(cl);
- int size = (maxSize - permits.availablePermits());
- if (size > maxUsedConnections)
- {
- maxUsedConnections = size;
- }
-
- if (!started.get())
- {
- started.set(true);
- if (poolConfiguration.getMinSize() > 0)
- {
- PoolFiller.fillPool(this);
- }
- }
-
- if (trace)
- log.trace("supplying new ManagedConnection: " + cl);
-
- cl.grantPermit(true);
-
- return cl;
- }
- catch (Throwable t)
- {
- log.warn("Throwable while attempting to get a new connection: " + cl, t);
- //return permit and rethrow
-
- checkedOut.remove(cl);
- permits.release();
- JBossResourceException.rethrowAsResourceException("Unexpected throwable while trying to create a connection: "
- + cl, t);
- throw new UnreachableStatementException();
- }
- }
-
-
- /**
- * Create a connection event listener
- *
- * @param subject the subject
- * @param cri the connection request information
- * @return the new listener
- * @throws ResourceException for any error
- */
- private ConnectionListener createsConnectionEventListener(Subject subject, ConnectionRequestInfo cri)
- throws ResourceException
- {
- ManagedConnection mc = mcf.createManagedConnection(subject, cri);
- try
- {
- return clf.createConnectionListener(mc, this);
- }
- catch (ResourceException re)
- {
- mc.destroy();
- throw re;
- }
- }
-
-
- /**
- * Destroy a connection
- *
- * @param cl the connection to destroy
- */
- private void doDestroy(ConnectionListener cl)
- {
- if (cl.getState() == ConnectionState.DESTROYED)
- {
- log.trace("ManagedConnection is already destroyed " + cl);
- return;
- }
-
- cl.setState(ConnectionState.DESTROYED);
-
- try
- {
- cl.getManagedConnection().destroy();
- }
- catch (Throwable t)
- {
- log.debug("Exception destroying ManagedConnection " + cl, t);
- }
-
- }
-
- /**
- * {@inheritDoc}
- */
- public void removeIdleConnections()
- {
- ArrayList<ConnectionListener> destroy = null;
- long timeout = System.currentTimeMillis() - poolConfiguration.getIdleTimeout();
-
- while (true)
- {
- // Nothing left to destroy
- if (cls.size() == 0)
- break;
-
- // Check the first in the list
- ConnectionListener cl = cls.get(0);
- if (cl.isTimedOut(timeout) && shouldRemove())
- {
- // We need to destroy this one
- cls.remove(0);
- if (destroy == null)
- {
- destroy = new ArrayList<ConnectionListener>();
- }
-
- destroy.add(cl);
- }
- else
- {
- //They were inserted chronologically, so if this one isn't timed out, following ones won't be either.
- break;
- }
- }
-
- // We found some connections to destroy
- if (destroy != null)
- {
- for (int i = 0; i < destroy.size(); ++i)
- {
- ConnectionListener cl = destroy.get(i);
- if (trace)
- {
- log.trace("Destroying timedout connection " + cl);
- }
-
- doDestroy(cl);
- }
-
- // We destroyed something, check the minimum.
- if (!shutdown.get() && poolConfiguration.getMinSize() > 0)
- {
- PoolFiller.fillPool(this);
- }
-
-// // Empty sub-pool
-// if (jmcp != null)
-// {
-// jmcp.getPoolingStrategy().emptySubPool(this);
-// }
- }
-
- }
-
- /**
- * Returns true if check is ok.
- * @return true if check is ok.
- */
- private boolean shouldRemove()
- {
- boolean remove = true;
-
- if (this.poolConfiguration.isStrictMin())
- {
- remove = cls.size() > poolConfiguration.getMinSize();
-
- log.trace("StrictMin is active. Current connection will be removed is " + remove);
-
- }
-
- return remove;
-
- }
-
-
- /**
- * Initialize the subpool
- */
- public void initialize()
- {
- if (this.poolConfiguration.getIdleTimeout() != 0L)
- {
- //Register removal support
- IdleRemover.registerPool(this, this.poolConfiguration.getIdleTimeout());
- }
-
- if (this.poolConfiguration.getBackgroundValidationInterval() > 0)
- {
- log.debug("Registering for background validation at interval " +
- this.poolConfiguration.getBackgroundValidationInterval());
-
- //Register validation
- ConnectionValidator.registerPool(this, this.poolConfiguration.getBackgroundValidationInterval());
- }
-
- shutdown.set(false);
- }
-
- /**
- * Return connection to the pool.
- * @param cl connection listener
- * @param kill kill connection
- */
- public void returnConnection(ConnectionListener cl, boolean kill)
- {
- if (cl.getState().equals(ConnectionState.DESTROYED))
- {
- returnConnectionWithDestroyedState(cl);
- return;
- }
-
- if (trace)
- {
- log.trace("putting ManagedConnection back into pool kill=" + kill + " cl=" + cl);
- }
-
- returnConnectionWithKillState(cl, kill);
-
- }
-
- /**
- * Connection is returned with destroyed state.
- * @param cl connection listener
- */
- private void returnConnectionWithDestroyedState(ConnectionListener cl)
- {
- if (this.trace)
- {
- log.trace("ManagedConnection is being returned after it was destroyed" + cl);
- }
-
- if (cl.hasPermit())
- {
- cl.grantPermit(false);
- this.permits.release();
- }
- }
-
- /**
- * Connection is returned with destroyed state.
- * @param cl connection listener
- */
- private void returnConnectionWithKillState(ConnectionListener cl, boolean kill)
- {
- try
- {
- cl.getManagedConnection().cleanup();
- }
- catch (ResourceException re)
- {
- log.warn("ResourceException cleaning up ManagedConnection: " + cl, re);
- kill = true;
- }
-
- // We need to destroy this one
- if (cl.getState().equals(ConnectionState.DESTROY))
- {
- kill = true;
- checkedOut.remove(cl);
- }
-
- // This is really an error
- if (!kill && cls.size() >= poolConfiguration.getMaxSize())
- {
- log.warn("Destroying returned connection, maximum pool size exceeded " + cl);
- kill = true;
- }
-
- // If we are destroying, check the connection is not in the pool
- if (kill)
- {
- // Adrian Brock: A resource adapter can asynchronously notify us that
- // a connection error occurred.
- // This could happen while the connection is not checked out.
- // e.g. JMS can do this via an ExceptionListener on the connection.
- // I have twice had to reinstate this line of code, PLEASE DO NOT REMOVE IT!
- cls.remove(cl);
- }
- // return to the pool
- else
- {
- cl.used();
- if (!cls.contains(cl))
- {
- cls.add(cl);
- }
- else
- {
- log.warn("Attempt to return connection twice (ignored): " + cl, new Throwable("STACKTRACE"));
- }
- }
-
- if (cl.hasPermit())
- {
- // release semaphore
- cl.grantPermit(false);
- permits.release();
- }
-
- if (kill)
- {
- if (trace)
- {
- log.trace("Destroying returned connection " + cl);
- }
-
- doDestroy(cl);
- }
-
- }
-
- /**
- * Pool is shut down.
- */
- public void shutdown()
- {
- shutdown.set(true);
-
- //Unregister from idle check
- IdleRemover.unregisterPool(this);
-
- //Unregister from connection validation check
- ConnectionValidator.unregisterPool(this);
-
- //Destroy connections
- flush();
- }
-
- /**
- * Flush pool.
- */
- public void flush()
- {
- ArrayList<ConnectionListener> destroyList = new ArrayList<ConnectionListener>();
-
- if (this.trace)
- {
- log.trace("Flushing pool checkedOut=" + checkedOut + " inPool=" + cls);
- }
-
- Iterator<ConnectionListener> itCheckOut = this.checkedOut.iterator();
- ConnectionListener listener = null;
- while (itCheckOut.hasNext())
- {
- listener = itCheckOut.next();
- listener.setState(ConnectionState.DESTROY);
- }
-
- itCheckOut = this.cls.iterator();
- while (itCheckOut.hasNext())
- {
- listener = itCheckOut.next();
- destroyList.add(listener);
- }
-
- for (ConnectionListener listenerDestroy : destroyList)
- {
- if (this.trace)
- {
- log.trace("Destroying flushed connection " + listenerDestroy);
- }
-
- doDestroy(listenerDestroy);
- }
-
- // We destroyed something, check the minimum.
- if (!shutdown.get() && poolConfiguration.getMinSize() > 0)
- {
- PoolFiller.fillPool(this);
- }
- }
-
- /**
- * Checks that pool is empty or not
- * @return true if is emtpy false otherwise
- */
- boolean isEmpty()
- {
- return this.cls.size() == 0;
- }
-
- /**
- * Gets connection listeners.
- * @return connection listeners
- */
- Set<ConnectionListener> getConnectionListeners()
- {
- Set<ConnectionListener> cls = new HashSet<ConnectionListener>();
- Iterator<ConnectionListener> it = this.cls.iterator();
- while (it.hasNext())
- {
- cls.add(it.next());
- }
-
- it = this.checkedOut.iterator();
- while (it.hasNext())
- {
- cls.add(it.next());
- }
-
- return cls;
- }
-
- /**
- * Returns true if pool is not shut down.
- * @return true if pool is not shut down
- */
- public boolean isRunning()
- {
- return !shutdown.get();
- }
-
- /**
- * Fill to min.
- */
- public void fillToMin()
- {
- while (true)
- {
- // Get a permit - avoids a race when the pool is nearly full
- // Also avoids unnessary fill checking when all connections are checked out
- try
- {
- if (permits.tryAcquire(poolConfiguration.getBlockingTimeout(), TimeUnit.MILLISECONDS))
- {
- try
- {
- //pool shuts down
- if (shutdown.get())
- {
- return;
- }
-
- // We already have enough connections -- TODO
- //if (getMinSize() - connectionCounter.getGuaranteedCount() <= 0)
- //{
- return;
- //}
-
- /* -- TODO
- // Create a connection to fill the pool
- try
- {
- ConnectionListener cl = createsConnectionEventListener(defaultSubject, defaultCri);
- if (trace)
- {
- log.trace("Filling pool cl=" + cl);
- }
-
- cls.add(cl);
- }
- catch (ResourceException re)
- {
- log.warn("Unable to fill pool ", re);
- return;
- }
- */
- }
- finally
- {
- permits.release();
- }
- }
- }
- catch (InterruptedException ignored)
- {
- log.trace("Interrupted while requesting permit in fillToMin");
- }
- }
- }
-
- /**
- * Guard against configurations or
- * dynamic changes that may increase the minimum
- * beyond the maximum
- */
- private int getMinSize()
- {
- if (this.poolConfiguration.getMinSize() > this.maxSize)
- {
- return maxSize;
- }
-
- return this.poolConfiguration.getMinSize();
- }
-
- /**
- * Validate connecitons.
- * @throws Exception for exception
- */
- @SuppressWarnings("unchecked")
- public void validateConnections() throws Exception
- {
- if (this.trace)
- {
- log.trace("Attempting to validate connections for pool " + this);
- }
-
- if (this.permits.tryAcquire(this.poolConfiguration.getBlockingTimeout(), TimeUnit.MILLISECONDS))
- {
- boolean destroyed = false;
- try
- {
- while (true)
- {
- ConnectionListener cl = null;
- if (cls.size() == 0)
- {
- break;
- }
-
- cl = removeForFrequencyCheck();
-
- if (cl == null)
- {
- break;
- }
-
- try
- {
- Set<ManagedConnection> candidateSet = Collections.singleton(cl.getManagedConnection());
- if (mcf instanceof ValidatingManagedConnectionFactory)
- {
- ValidatingManagedConnectionFactory vcf = (ValidatingManagedConnectionFactory) mcf;
- candidateSet = vcf.getInvalidConnections(candidateSet);
-
- if (candidateSet != null && candidateSet.size() > 0)
- {
- if (!cl.getState().equals(ConnectionState.DESTROY))
- {
- doDestroy(cl);
- destroyed = true;
- }
- }
- }
- else
- {
- log.warn("warning: background validation was specified with a " +
- "non compliant ManagedConnectionFactory interface.");
- }
- }
- finally
- {
- if (!destroyed)
- {
- returnForFrequencyCheck(cl);
- }
- }
- }
- }
- finally
- {
- permits.release();
-
- //Check min size pool after validation
- if (destroyed && !shutdown.get() && poolConfiguration.getMinSize() > 0)
- {
- PoolFiller.fillPool(this);
- }
- }
- }
- }
-
- /**
- * Remove for frequency check.
- * @return connection listener
- */
- private ConnectionListener removeForFrequencyCheck()
- {
- log.debug("Checking for connection within frequency");
- ConnectionListener cl = null;
- for (Iterator<ConnectionListener> iter = cls.iterator(); iter.hasNext();)
- {
- cl = iter.next();
- long lastCheck = cl.getLastValidatedTime();
-
- if ((System.currentTimeMillis() - lastCheck) >= poolConfiguration.getBackgroundValidationInterval())
- {
- cls.remove(cl);
- break;
- }
- else
- {
- cl = null;
- }
- }
-
- return cl;
- }
-
- /**
- * Returns connection to pool again.
- * @param cl connection listener
- */
- private void returnForFrequencyCheck(ConnectionListener cl)
- {
-
- log.debug("Returning for connection within frequency");
-
- cl.setLastValidatedTime(System.currentTimeMillis());
- cls.add(cl);
- }
-
-}
Copied: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/ManagedConnectionPool.java (from rev 106978, projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/InternalManagedConnectionPool.java)
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/ManagedConnectionPool.java (rev 0)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/ManagedConnectionPool.java 2010-07-21 15:57:08 UTC (rev 106984)
@@ -0,0 +1,936 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008-2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.jca.core.connectionmanager.pool;
+
+import org.jboss.jca.common.JBossResourceException;
+import org.jboss.jca.core.connectionmanager.listener.ConnectionListener;
+import org.jboss.jca.core.connectionmanager.listener.ConnectionListenerFactory;
+import org.jboss.jca.core.connectionmanager.listener.ConnectionState;
+import org.jboss.jca.core.connectionmanager.pool.api.PoolConfiguration;
+import org.jboss.jca.core.connectionmanager.pool.idle.IdleConnectionRemovalSupport;
+import org.jboss.jca.core.connectionmanager.pool.idle.IdleRemover;
+import org.jboss.jca.core.connectionmanager.pool.validator.ConnectionValidator;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.CopyOnWriteArraySet;
+import java.util.concurrent.Semaphore;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import javax.resource.ResourceException;
+import javax.resource.spi.ConnectionRequestInfo;
+import javax.resource.spi.ManagedConnection;
+import javax.resource.spi.ManagedConnectionFactory;
+import javax.resource.spi.RetryableUnavailableException;
+import javax.resource.spi.ValidatingManagedConnectionFactory;
+import javax.security.auth.Subject;
+
+import org.jboss.logging.Logger;
+import org.jboss.util.UnreachableStatementException;
+
+
+/**
+ * Actual internal managed connection pool.
+ *
+ * <p>
+ * Contains and manages the {@link ConnectionListener} instances.
+ * Each pool strategy can contains several {@link SubPoolContext} instance
+ * that contains {@link ManagedConnectionPool} internally.
+ * </p>
+ *
+ * <p>
+ * Each internal managed connection pool instances could be
+ * differentiated by a key.
+ * </p>
+ * @author <a href="mailto:d_jencks at users.sourceforge.net">David Jencks</a>
+ * @author <a href="mailto:adrian at jboss.org">Adrian Brock</a>
+ * @author <a href="mailto:weston.price at jboss.com">Weston Price</a>
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ * @author <a href="mailto:gurkanerdogdu at yahoo.com">Gurkan Erdogdu</a>
+ * @see AbstractPool
+ */
+public class ManagedConnectionPool implements IdleConnectionRemovalSupport
+{
+ /** The log */
+ private static Logger log = Logger.getLogger(ManagedConnectionPool.class);
+
+ /** Whether trace is enabled */
+ private final boolean trace = log.isTraceEnabled();
+
+ /** The managed connection factory */
+ private final ManagedConnectionFactory mcf;
+
+ /** The connection listener factory */
+ private final ConnectionListenerFactory clf;
+
+ /** The default subject */
+ private final Subject defaultSubject;
+
+ /** The default connection request information */
+ private final ConnectionRequestInfo defaultCri;
+
+ /** The pool configuration */
+ private final PoolConfiguration poolConfiguration;
+
+ /** Copy of the maximum size from the pooling parameters.
+ * Dynamic changes to this value are not compatible with
+ * the semaphore which cannot change be dynamically changed.
+ */
+ private int maxSize;
+
+ /** The available connection event listeners */
+ private CopyOnWriteArrayList<ConnectionListener> cls = new CopyOnWriteArrayList<ConnectionListener>();
+
+ /** The permits used to control who can checkout a connection */
+ private final Semaphore permits;
+
+ /** The checked out connections */
+ private final CopyOnWriteArraySet<ConnectionListener> checkedOut = new CopyOnWriteArraySet<ConnectionListener>();
+
+ /** Whether the pool has been started */
+ private AtomicBoolean started = new AtomicBoolean(false);
+
+ /** Whether the pool has been shutdown */
+ private AtomicBoolean shutdown = new AtomicBoolean(false);
+
+ /** the max connections ever checked out **/
+ private volatile int maxUsedConnections = 0;
+
+ /**
+ * Create a new ManagedConnectionPool.
+ *
+ * @param mcf the managed connection factory
+ * @param clf the connection listener factory
+ * @param subject the subject
+ * @param cri the connection request info
+ * @param pc the pool configuration
+ */
+ public ManagedConnectionPool(ManagedConnectionFactory mcf, ConnectionListenerFactory clf, Subject subject,
+ ConnectionRequestInfo cri, PoolConfiguration pc)
+ {
+ if (mcf == null)
+ throw new IllegalArgumentException("MCF is null");
+
+ if (clf == null)
+ throw new IllegalArgumentException("CLF is null");
+
+ if (pc == null)
+ throw new IllegalArgumentException("PoolConfiguration is null");
+
+ this.mcf = mcf;
+ this.clf = clf;
+ this.defaultSubject = subject;
+ this.defaultCri = cri;
+ this.poolConfiguration = pc;
+ this.maxSize = pc.getMaxSize();
+ this.permits = new Semaphore(this.maxSize, true);
+
+ if (pc.isPrefill())
+ {
+ PoolFiller.fillPool(this);
+ }
+ }
+
+ /**
+ * Returns a connection listener that wraps managed connection.
+ * @param subject subject
+ * @param cri connection request info
+ * @return connection listener wrapped managed connection
+ * @throws ResourceException exception
+ */
+ public ConnectionListener getConnection(Subject subject, ConnectionRequestInfo cri) throws ResourceException
+ {
+ ConnectionListener connectionListener = null;
+
+ if (subject == null)
+ {
+ subject = this.defaultSubject;
+ }
+
+ if (cri == null)
+ {
+ cri = this.defaultCri;
+ }
+
+ //Use in blocked time
+ long startWait = System.currentTimeMillis();
+
+ try
+ {
+ //Check connection is available, and if not waits for the blocking timeout
+ if (this.permits.tryAcquire(this.poolConfiguration.getBlockingTimeout(), TimeUnit.MILLISECONDS))
+ {
+ do
+ {
+ //Check shutdown
+ if (this.shutdown.get())
+ {
+ permits.release();
+ throw new RetryableUnavailableException("The pool has been shut down");
+ }
+
+ if (cls.size() > 0)
+ {
+ connectionListener = this.cls.remove(this.cls.size() - 1);
+ this.checkedOut.add(connectionListener);
+
+ //Max used connections, maxSize - permits.aval --> gives current used connection!
+ int size = (maxSize - permits.availablePermits());
+ if (size > maxUsedConnections)
+ {
+ maxUsedConnections = size;
+ }
+
+ if (connectionListener != null)
+ {
+ try
+ {
+ //Match connection
+ ConnectionListener matchedConnectionListener =
+ isManagedConnectionMatched(connectionListener, subject, cri);
+
+ //Connection matched
+ if (matchedConnectionListener != null)
+ {
+ connectionListener = matchedConnectionListener;
+ break;
+ }
+
+ //Match did not succeed but no exception was thrown.
+ //Either we have the matching strategy wrong or the
+ //connection died while being checked. We need to
+ //distinguish these cases, but for now we always
+ //destroy the connection.
+ log.warn("Destroying connection that could not be successfully matched: " + connectionListener);
+ removesAndDestorysConnectionListener(connectionListener);
+
+ }
+ catch (Throwable t)
+ {
+ log.warn("Throwable while trying to match ManagedConnection,destroying connection: "
+ + connectionListener, t);
+ removesAndDestorysConnectionListener(connectionListener);
+ }
+
+ //We made it here, something went wrong and we should validate if
+ //we should continue attempting to acquire a connection
+ if (this.poolConfiguration.isUseFastFail())
+ {
+ log.trace("Fast failing for connection attempt. No more attempts will " +
+ "be made to acquire connection from pool and a new connection " +
+ "will be created immeadiately");
+ break;
+ }
+
+ } //connectionListener != null
+ } //cls.size > 0
+ }
+ while (this.cls.size() > 0);
+
+ //Check connection
+ if (connectionListener == null)
+ {
+ //Ok, no connection in the pool. Creates a new managed connection instance!
+ connectionListener = createsNewManagedConnection(subject, cri);
+ }
+
+ }
+ else
+ {
+ // we timed out
+ throw new ResourceException("No ManagedConnections available within configured blocking timeout ( "
+ + this.poolConfiguration.getBlockingTimeout() + " [ms] )");
+ }
+
+ }
+ catch (InterruptedException e)
+ {
+ long end = System.currentTimeMillis() - startWait;
+ throw new ResourceException("Interrupted while requesting permit! Waited " + end + " ms");
+ }
+
+ return connectionListener;
+ }
+
+ /**
+ * Removes and destroys given connection.
+ * @param connectionListener connection listener
+ */
+ private void removesAndDestorysConnectionListener(ConnectionListener connectionListener)
+ {
+ this.checkedOut.remove(connectionListener);
+
+ //Destroy it
+ doDestroy(connectionListener);
+ }
+
+ /**
+ * Returns given listener if there is a matched connection false ow.
+ * @param connectionListener connection listener
+ * @param subject subject
+ * @param cri connection request info
+ * @return true if there is a matched connection false ow.
+ */
+ private ConnectionListener isManagedConnectionMatched(ConnectionListener connectionListener,
+ Subject subject, ConnectionRequestInfo cri) throws ResourceException
+ {
+ ManagedConnection managedConnection = connectionListener.getManagedConnection();
+ managedConnection = this.mcf.matchManagedConnections(Collections.singleton(managedConnection), subject , cri);
+
+ //There is a match
+ if (managedConnection != null)
+ {
+ if (trace)
+ {
+ log.trace("supplying ManagedConnection from pool: " + connectionListener);
+ }
+
+ connectionListener.grantPermit(true);
+
+ return connectionListener;
+ }
+
+ return null;
+ }
+
+ /**
+ * Creates a new connection listener.
+ * @param subject subject instance
+ * @param cri connection request info
+ * @return new connection listener
+ * @throws ResourceException
+ */
+ private ConnectionListener createsNewManagedConnection(Subject subject, ConnectionRequestInfo cri)
+ throws ResourceException
+ {
+ ConnectionListener cl = null;
+ try
+ {
+ //No, the pool was empty, so we have to make a new one.
+ cl = createsConnectionEventListener(subject, cri);
+
+ checkedOut.add(cl);
+ int size = (maxSize - permits.availablePermits());
+ if (size > maxUsedConnections)
+ {
+ maxUsedConnections = size;
+ }
+
+ if (!started.get())
+ {
+ started.set(true);
+ if (poolConfiguration.getMinSize() > 0)
+ {
+ PoolFiller.fillPool(this);
+ }
+ }
+
+ if (trace)
+ log.trace("supplying new ManagedConnection: " + cl);
+
+ cl.grantPermit(true);
+
+ return cl;
+ }
+ catch (Throwable t)
+ {
+ log.warn("Throwable while attempting to get a new connection: " + cl, t);
+ //return permit and rethrow
+
+ checkedOut.remove(cl);
+ permits.release();
+ JBossResourceException.rethrowAsResourceException("Unexpected throwable while trying to create a connection: "
+ + cl, t);
+ throw new UnreachableStatementException();
+ }
+ }
+
+
+ /**
+ * Create a connection event listener
+ *
+ * @param subject the subject
+ * @param cri the connection request information
+ * @return the new listener
+ * @throws ResourceException for any error
+ */
+ private ConnectionListener createsConnectionEventListener(Subject subject, ConnectionRequestInfo cri)
+ throws ResourceException
+ {
+ ManagedConnection mc = mcf.createManagedConnection(subject, cri);
+ try
+ {
+ return clf.createConnectionListener(mc, this);
+ }
+ catch (ResourceException re)
+ {
+ mc.destroy();
+ throw re;
+ }
+ }
+
+
+ /**
+ * Destroy a connection
+ *
+ * @param cl the connection to destroy
+ */
+ private void doDestroy(ConnectionListener cl)
+ {
+ if (cl.getState() == ConnectionState.DESTROYED)
+ {
+ log.trace("ManagedConnection is already destroyed " + cl);
+ return;
+ }
+
+ cl.setState(ConnectionState.DESTROYED);
+
+ try
+ {
+ cl.getManagedConnection().destroy();
+ }
+ catch (Throwable t)
+ {
+ log.debug("Exception destroying ManagedConnection " + cl, t);
+ }
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void removeIdleConnections()
+ {
+ ArrayList<ConnectionListener> destroy = null;
+ long timeout = System.currentTimeMillis() - poolConfiguration.getIdleTimeout();
+
+ while (true)
+ {
+ // Nothing left to destroy
+ if (cls.size() == 0)
+ break;
+
+ // Check the first in the list
+ ConnectionListener cl = cls.get(0);
+ if (cl.isTimedOut(timeout) && shouldRemove())
+ {
+ // We need to destroy this one
+ cls.remove(0);
+ if (destroy == null)
+ {
+ destroy = new ArrayList<ConnectionListener>();
+ }
+
+ destroy.add(cl);
+ }
+ else
+ {
+ //They were inserted chronologically, so if this one isn't timed out, following ones won't be either.
+ break;
+ }
+ }
+
+ // We found some connections to destroy
+ if (destroy != null)
+ {
+ for (int i = 0; i < destroy.size(); ++i)
+ {
+ ConnectionListener cl = destroy.get(i);
+ if (trace)
+ {
+ log.trace("Destroying timedout connection " + cl);
+ }
+
+ doDestroy(cl);
+ }
+
+ // We destroyed something, check the minimum.
+ if (!shutdown.get() && poolConfiguration.getMinSize() > 0)
+ {
+ PoolFiller.fillPool(this);
+ }
+
+// // Empty sub-pool
+// if (jmcp != null)
+// {
+// jmcp.getPoolingStrategy().emptySubPool(this);
+// }
+ }
+
+ }
+
+ /**
+ * Returns true if check is ok.
+ * @return true if check is ok.
+ */
+ private boolean shouldRemove()
+ {
+ boolean remove = true;
+
+ if (this.poolConfiguration.isStrictMin())
+ {
+ remove = cls.size() > poolConfiguration.getMinSize();
+
+ log.trace("StrictMin is active. Current connection will be removed is " + remove);
+
+ }
+
+ return remove;
+
+ }
+
+
+ /**
+ * Initialize the subpool
+ */
+ public void initialize()
+ {
+ if (this.poolConfiguration.getIdleTimeout() != 0L)
+ {
+ //Register removal support
+ IdleRemover.registerPool(this, this.poolConfiguration.getIdleTimeout());
+ }
+
+ if (this.poolConfiguration.getBackgroundValidationInterval() > 0)
+ {
+ log.debug("Registering for background validation at interval " +
+ this.poolConfiguration.getBackgroundValidationInterval());
+
+ //Register validation
+ ConnectionValidator.registerPool(this, this.poolConfiguration.getBackgroundValidationInterval());
+ }
+
+ shutdown.set(false);
+ }
+
+ /**
+ * Return connection to the pool.
+ * @param cl connection listener
+ * @param kill kill connection
+ */
+ public void returnConnection(ConnectionListener cl, boolean kill)
+ {
+ if (cl.getState().equals(ConnectionState.DESTROYED))
+ {
+ returnConnectionWithDestroyedState(cl);
+ return;
+ }
+
+ if (trace)
+ {
+ log.trace("putting ManagedConnection back into pool kill=" + kill + " cl=" + cl);
+ }
+
+ returnConnectionWithKillState(cl, kill);
+
+ }
+
+ /**
+ * Connection is returned with destroyed state.
+ * @param cl connection listener
+ */
+ private void returnConnectionWithDestroyedState(ConnectionListener cl)
+ {
+ if (this.trace)
+ {
+ log.trace("ManagedConnection is being returned after it was destroyed" + cl);
+ }
+
+ if (cl.hasPermit())
+ {
+ cl.grantPermit(false);
+ this.permits.release();
+ }
+ }
+
+ /**
+ * Connection is returned with destroyed state.
+ * @param cl connection listener
+ */
+ private void returnConnectionWithKillState(ConnectionListener cl, boolean kill)
+ {
+ try
+ {
+ cl.getManagedConnection().cleanup();
+ }
+ catch (ResourceException re)
+ {
+ log.warn("ResourceException cleaning up ManagedConnection: " + cl, re);
+ kill = true;
+ }
+
+ // We need to destroy this one
+ if (cl.getState().equals(ConnectionState.DESTROY))
+ {
+ kill = true;
+ checkedOut.remove(cl);
+ }
+
+ // This is really an error
+ if (!kill && cls.size() >= poolConfiguration.getMaxSize())
+ {
+ log.warn("Destroying returned connection, maximum pool size exceeded " + cl);
+ kill = true;
+ }
+
+ // If we are destroying, check the connection is not in the pool
+ if (kill)
+ {
+ // Adrian Brock: A resource adapter can asynchronously notify us that
+ // a connection error occurred.
+ // This could happen while the connection is not checked out.
+ // e.g. JMS can do this via an ExceptionListener on the connection.
+ // I have twice had to reinstate this line of code, PLEASE DO NOT REMOVE IT!
+ cls.remove(cl);
+ }
+ // return to the pool
+ else
+ {
+ cl.used();
+ if (!cls.contains(cl))
+ {
+ cls.add(cl);
+ }
+ else
+ {
+ log.warn("Attempt to return connection twice (ignored): " + cl, new Throwable("STACKTRACE"));
+ }
+ }
+
+ if (cl.hasPermit())
+ {
+ // release semaphore
+ cl.grantPermit(false);
+ permits.release();
+ }
+
+ if (kill)
+ {
+ if (trace)
+ {
+ log.trace("Destroying returned connection " + cl);
+ }
+
+ doDestroy(cl);
+ }
+
+ }
+
+ /**
+ * Pool is shut down.
+ */
+ public void shutdown()
+ {
+ shutdown.set(true);
+
+ //Unregister from idle check
+ IdleRemover.unregisterPool(this);
+
+ //Unregister from connection validation check
+ ConnectionValidator.unregisterPool(this);
+
+ //Destroy connections
+ flush();
+ }
+
+ /**
+ * Flush pool.
+ */
+ public void flush()
+ {
+ ArrayList<ConnectionListener> destroyList = new ArrayList<ConnectionListener>();
+
+ if (this.trace)
+ {
+ log.trace("Flushing pool checkedOut=" + checkedOut + " inPool=" + cls);
+ }
+
+ Iterator<ConnectionListener> itCheckOut = this.checkedOut.iterator();
+ ConnectionListener listener = null;
+ while (itCheckOut.hasNext())
+ {
+ listener = itCheckOut.next();
+ listener.setState(ConnectionState.DESTROY);
+ }
+
+ itCheckOut = this.cls.iterator();
+ while (itCheckOut.hasNext())
+ {
+ listener = itCheckOut.next();
+ destroyList.add(listener);
+ }
+
+ for (ConnectionListener listenerDestroy : destroyList)
+ {
+ if (this.trace)
+ {
+ log.trace("Destroying flushed connection " + listenerDestroy);
+ }
+
+ doDestroy(listenerDestroy);
+ }
+
+ // We destroyed something, check the minimum.
+ if (!shutdown.get() && poolConfiguration.getMinSize() > 0)
+ {
+ PoolFiller.fillPool(this);
+ }
+ }
+
+ /**
+ * Checks that pool is empty or not
+ * @return true if is emtpy false otherwise
+ */
+ boolean isEmpty()
+ {
+ return this.cls.size() == 0;
+ }
+
+ /**
+ * Gets connection listeners.
+ * @return connection listeners
+ */
+ Set<ConnectionListener> getConnectionListeners()
+ {
+ Set<ConnectionListener> cls = new HashSet<ConnectionListener>();
+ Iterator<ConnectionListener> it = this.cls.iterator();
+ while (it.hasNext())
+ {
+ cls.add(it.next());
+ }
+
+ it = this.checkedOut.iterator();
+ while (it.hasNext())
+ {
+ cls.add(it.next());
+ }
+
+ return cls;
+ }
+
+ /**
+ * Returns true if pool is not shut down.
+ * @return true if pool is not shut down
+ */
+ public boolean isRunning()
+ {
+ return !shutdown.get();
+ }
+
+ /**
+ * Fill to min.
+ */
+ public void fillToMin()
+ {
+ while (true)
+ {
+ // Get a permit - avoids a race when the pool is nearly full
+ // Also avoids unnessary fill checking when all connections are checked out
+ try
+ {
+ if (permits.tryAcquire(poolConfiguration.getBlockingTimeout(), TimeUnit.MILLISECONDS))
+ {
+ try
+ {
+ //pool shuts down
+ if (shutdown.get())
+ {
+ return;
+ }
+
+ // We already have enough connections -- TODO
+ //if (getMinSize() - connectionCounter.getGuaranteedCount() <= 0)
+ //{
+ return;
+ //}
+
+ /* -- TODO
+ // Create a connection to fill the pool
+ try
+ {
+ ConnectionListener cl = createsConnectionEventListener(defaultSubject, defaultCri);
+ if (trace)
+ {
+ log.trace("Filling pool cl=" + cl);
+ }
+
+ cls.add(cl);
+ }
+ catch (ResourceException re)
+ {
+ log.warn("Unable to fill pool ", re);
+ return;
+ }
+ */
+ }
+ finally
+ {
+ permits.release();
+ }
+ }
+ }
+ catch (InterruptedException ignored)
+ {
+ log.trace("Interrupted while requesting permit in fillToMin");
+ }
+ }
+ }
+
+ /**
+ * Guard against configurations or
+ * dynamic changes that may increase the minimum
+ * beyond the maximum
+ */
+ private int getMinSize()
+ {
+ if (this.poolConfiguration.getMinSize() > this.maxSize)
+ {
+ return maxSize;
+ }
+
+ return this.poolConfiguration.getMinSize();
+ }
+
+ /**
+ * Validate connecitons.
+ * @throws Exception for exception
+ */
+ @SuppressWarnings("unchecked")
+ public void validateConnections() throws Exception
+ {
+ if (this.trace)
+ {
+ log.trace("Attempting to validate connections for pool " + this);
+ }
+
+ if (this.permits.tryAcquire(this.poolConfiguration.getBlockingTimeout(), TimeUnit.MILLISECONDS))
+ {
+ boolean destroyed = false;
+ try
+ {
+ while (true)
+ {
+ ConnectionListener cl = null;
+ if (cls.size() == 0)
+ {
+ break;
+ }
+
+ cl = removeForFrequencyCheck();
+
+ if (cl == null)
+ {
+ break;
+ }
+
+ try
+ {
+ Set<ManagedConnection> candidateSet = Collections.singleton(cl.getManagedConnection());
+ if (mcf instanceof ValidatingManagedConnectionFactory)
+ {
+ ValidatingManagedConnectionFactory vcf = (ValidatingManagedConnectionFactory) mcf;
+ candidateSet = vcf.getInvalidConnections(candidateSet);
+
+ if (candidateSet != null && candidateSet.size() > 0)
+ {
+ if (!cl.getState().equals(ConnectionState.DESTROY))
+ {
+ doDestroy(cl);
+ destroyed = true;
+ }
+ }
+ }
+ else
+ {
+ log.warn("warning: background validation was specified with a " +
+ "non compliant ManagedConnectionFactory interface.");
+ }
+ }
+ finally
+ {
+ if (!destroyed)
+ {
+ returnForFrequencyCheck(cl);
+ }
+ }
+ }
+ }
+ finally
+ {
+ permits.release();
+
+ //Check min size pool after validation
+ if (destroyed && !shutdown.get() && poolConfiguration.getMinSize() > 0)
+ {
+ PoolFiller.fillPool(this);
+ }
+ }
+ }
+ }
+
+ /**
+ * Remove for frequency check.
+ * @return connection listener
+ */
+ private ConnectionListener removeForFrequencyCheck()
+ {
+ log.debug("Checking for connection within frequency");
+ ConnectionListener cl = null;
+ for (Iterator<ConnectionListener> iter = cls.iterator(); iter.hasNext();)
+ {
+ cl = iter.next();
+ long lastCheck = cl.getLastValidatedTime();
+
+ if ((System.currentTimeMillis() - lastCheck) >= poolConfiguration.getBackgroundValidationInterval())
+ {
+ cls.remove(cl);
+ break;
+ }
+ else
+ {
+ cl = null;
+ }
+ }
+
+ return cl;
+ }
+
+ /**
+ * Returns connection to pool again.
+ * @param cl connection listener
+ */
+ private void returnForFrequencyCheck(ConnectionListener cl)
+ {
+
+ log.debug("Returning for connection within frequency");
+
+ cl.setLastValidatedTime(System.currentTimeMillis());
+ cls.add(cl);
+ }
+
+}
Modified: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/PoolFiller.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/PoolFiller.java 2010-07-21 15:32:07 UTC (rev 106983)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/PoolFiller.java 2010-07-21 15:57:08 UTC (rev 106984)
@@ -46,8 +46,8 @@
private static final PoolFiller FILLER = new PoolFiller();
/** Pools list */
- private final LinkedBlockingQueue<InternalManagedConnectionPool> pools =
- new LinkedBlockingQueue<InternalManagedConnectionPool>();
+ private final LinkedBlockingQueue<ManagedConnectionPool> pools =
+ new LinkedBlockingQueue<ManagedConnectionPool>();
/** Filler thread */
private final Thread fillerThread;
@@ -69,7 +69,7 @@
*
* @param mcp internal managed connection pool
*/
- public static void fillPool(InternalManagedConnectionPool mcp)
+ public static void fillPool(ManagedConnectionPool mcp)
{
FILLER.internalFillPool(mcp);
}
@@ -94,7 +94,7 @@
// keep going unless interrupted
while (true)
{
- InternalManagedConnectionPool mcp = null;
+ ManagedConnectionPool mcp = null;
try
{
// keep iterating through pools till empty, exception escapes.
@@ -137,10 +137,10 @@
}
/**
- * Internal fill pool.
+ * fill pool.
* @param mcp connection pool
*/
- private void internalFillPool(InternalManagedConnectionPool mcp)
+ private void internalFillPool(ManagedConnectionPool mcp)
{
if (this.threadStarted.compareAndSet(false, true))
{
Modified: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/SubPoolContext.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/SubPoolContext.java 2010-07-21 15:32:07 UTC (rev 106983)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/SubPoolContext.java 2010-07-21 15:57:08 UTC (rev 106984)
@@ -41,7 +41,7 @@
public class SubPoolContext
{
/** Underlying sub-pool */
- private InternalManagedConnectionPool subPool;
+ private ManagedConnectionPool subPool;
/** The track by transaction*/
private TransactionLocal trackByTx;
@@ -59,7 +59,7 @@
public SubPoolContext(TransactionManager tm, ManagedConnectionFactory mcf, ConnectionListenerFactory clf,
Subject subject, ConnectionRequestInfo cri, PoolConfiguration pc)
{
- subPool = new InternalManagedConnectionPool(mcf, clf, subject, cri, pc);
+ subPool = new ManagedConnectionPool(mcf, clf, subject, cri, pc);
if (tm != null)
{
trackByTx = new TransactionLocal(tm);
@@ -71,7 +71,7 @@
*
* @return the sub pool
*/
- public InternalManagedConnectionPool getSubPool()
+ public ManagedConnectionPool getSubPool()
{
return subPool;
}
Modified: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/api/Pool.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/api/Pool.java 2010-07-21 15:32:07 UTC (rev 106983)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/api/Pool.java 2010-07-21 15:57:08 UTC (rev 106984)
@@ -23,7 +23,7 @@
import org.jboss.jca.core.connectionmanager.listener.ConnectionListener;
import org.jboss.jca.core.connectionmanager.listener.ConnectionListenerFactory;
-import org.jboss.jca.core.connectionmanager.pool.InternalManagedConnectionPool;
+import org.jboss.jca.core.connectionmanager.pool.ManagedConnectionPool;
import javax.resource.ResourceException;
import javax.resource.spi.ConnectionRequestInfo;
@@ -90,5 +90,5 @@
* Remove the matching SubPoolContext if the pool is empty
* @param pool the internal managed connection pool
*/
- void emptySubPool(InternalManagedConnectionPool pool);
+ void emptySubPool(ManagedConnectionPool pool);
}
Modified: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/strategy/OnePool.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/strategy/OnePool.java 2010-07-21 15:32:07 UTC (rev 106983)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/strategy/OnePool.java 2010-07-21 15:57:08 UTC (rev 106984)
@@ -23,7 +23,7 @@
package org.jboss.jca.core.connectionmanager.pool.strategy;
import org.jboss.jca.core.connectionmanager.pool.AbstractPrefillPool;
-import org.jboss.jca.core.connectionmanager.pool.InternalManagedConnectionPool;
+import org.jboss.jca.core.connectionmanager.pool.ManagedConnectionPool;
import org.jboss.jca.core.connectionmanager.pool.api.PoolConfiguration;
import javax.resource.ResourceException;
@@ -91,7 +91,7 @@
/**
* {@inheritDoc}
*/
- public void emptySubPool(InternalManagedConnectionPool pool)
+ public void emptySubPool(ManagedConnectionPool pool)
{
// No-operation
}
Modified: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/validator/ConnectionValidator.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/validator/ConnectionValidator.java 2010-07-21 15:32:07 UTC (rev 106983)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/validator/ConnectionValidator.java 2010-07-21 15:57:08 UTC (rev 106984)
@@ -22,7 +22,7 @@
package org.jboss.jca.core.connectionmanager.pool.validator;
-import org.jboss.jca.core.connectionmanager.pool.InternalManagedConnectionPool;
+import org.jboss.jca.core.connectionmanager.pool.ManagedConnectionPool;
import java.security.AccessController;
import java.security.PrivilegedAction;
@@ -52,8 +52,8 @@
private static final String VALIDATOR_THREAD_NAME = "JBossConnectionValidator";
/**Registered internal pool instances*/
- private CopyOnWriteArrayList<InternalManagedConnectionPool> registeredPools =
- new CopyOnWriteArrayList<InternalManagedConnectionPool>();
+ private CopyOnWriteArrayList<ManagedConnectionPool> registeredPools =
+ new CopyOnWriteArrayList<ManagedConnectionPool>();
/**Validator executor service*/
private ExecutorService executorService = null;
@@ -89,7 +89,7 @@
* @param mcp managed connection pool
* @param interval validation interval
*/
- public static void registerPool(InternalManagedConnectionPool mcp, long interval)
+ public static void registerPool(ManagedConnectionPool mcp, long interval)
{
instance.internalRegisterPool(mcp, interval);
}
@@ -98,12 +98,12 @@
* Unregister pool instance for connection validation.
* @param mcp pool instance
*/
- public static void unregisterPool(InternalManagedConnectionPool mcp)
+ public static void unregisterPool(ManagedConnectionPool mcp)
{
instance.internalUnregisterPool(mcp);
}
- private void internalRegisterPool(InternalManagedConnectionPool mcp, long interval)
+ private void internalRegisterPool(ManagedConnectionPool mcp, long interval)
{
try
{
@@ -136,7 +136,7 @@
}
}
- private void internalUnregisterPool(InternalManagedConnectionPool mcp)
+ private void internalUnregisterPool(ManagedConnectionPool mcp)
{
this.registeredPools.remove(mcp);
@@ -263,7 +263,7 @@
logger.debug("run: ConnectionValidator notifying pools, interval: " + interval);
}
- for (InternalManagedConnectionPool mcp : registeredPools)
+ for (ManagedConnectionPool mcp : registeredPools)
{
mcp.validateConnections();
}
Modified: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/xa/LocalXAResource.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/xa/LocalXAResource.java 2010-07-21 15:32:07 UTC (rev 106983)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/xa/LocalXAResource.java 2010-07-21 15:57:08 UTC (rev 106984)
@@ -21,7 +21,7 @@
*/
package org.jboss.jca.core.connectionmanager.xa;
-import org.jboss.jca.core.connectionmanager.AbstractConnectionManager;
+import org.jboss.jca.core.connectionmanager.ConnectionManager;
import org.jboss.jca.core.connectionmanager.listener.ConnectionListener;
import javax.resource.ResourceException;
@@ -50,7 +50,7 @@
private boolean trace;
/**Connection manager*/
- private AbstractConnectionManager connectionManager = null;
+ private ConnectionManager connectionManager = null;
/**
* <code>warned</code> is set after one warning about a local participant in
@@ -65,7 +65,7 @@
* Creates a new instance.
* @param connectionManager connection manager
*/
- public LocalXAResource(AbstractConnectionManager connectionManager)
+ public LocalXAResource(ConnectionManager connectionManager)
{
this.trace = log.isTraceEnabled();
this.connectionManager = connectionManager;
More information about the jboss-cvs-commits
mailing list