in geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/SinglePoolMatchAllConnectionInterceptor.java [54:99]
protected void internalGetConnection(ConnectionInfo connectionInfo) throws ResourceException {
synchronized (pool) {
if (destroyed) {
throw new ResourceException("ManagedConnection pool has been destroyed");
}
if (!pool.isEmpty()) {
ManagedConnectionInfo mci = connectionInfo.getManagedConnectionInfo();
ManagedConnectionFactory managedConnectionFactory = mci.getManagedConnectionFactory();
ManagedConnection matchedMC =
managedConnectionFactory
.matchManagedConnections(pool.keySet(),
mci.getSubject(),
mci.getConnectionRequestInfo());
if (matchedMC != null) {
connectionInfo.setManagedConnectionInfo(pool.get(matchedMC));
pool.remove(matchedMC);
if (log.isLoggable(Level.FINEST)) {
log.log(Level.FINEST,"Supplying existing connection from pool " + this + " " + connectionInfo);
}
if (connectionCount < minSize) {
timer.schedule(new FillTask(connectionInfo), 10);
}
return;
}
}
//matching failed or pool is empty
//if pool is at maximum size, pick a cx to kill
if (connectionCount == maxSize) {
log.log(Level.FINEST,"Pool is at max size but no connections match, picking one to destroy");
Iterator iterator = pool.entrySet().iterator();
ManagedConnectionInfo kill = (ManagedConnectionInfo) ((Map.Entry) iterator.next()).getValue();
iterator.remove();
ConnectionInfo killInfo = new ConnectionInfo(kill);
internalReturn(killInfo, ConnectionReturnAction.DESTROY);
}
next.getConnection(connectionInfo);
connectionCount++;
if (log.isLoggable(Level.FINEST)) {
log.log(Level.FINEST,"Supplying new connection from pool " + this + " " + connectionInfo);
}
if (connectionCount < minSize) {
timer.schedule(new FillTask(connectionInfo), 10);
}
}
}