/** Match a set of connections from the pool */ public ManagedConnection matchManagedConnections( Set connectionSet, Subject subject, ConnectionRequestInfo info) throws ResourceException { boolean trace = log.isTraceEnabled(); // Get cred info = getInfo(info); JmsCred cred = JmsCred.getJmsCred(this, subject, info); if (trace) log.trace("Looking for connection matching credentials: " + cred); // Traverse the pooled connections and look for a match, return first // found Iterator connections = connectionSet.iterator(); while (connections.hasNext()) { Object obj = connections.next(); // We only care for connections of our own type if (obj instanceof JmsManagedConnection) { // This is one from the pool JmsManagedConnection mc = (JmsManagedConnection) obj; // Check if we even created this on ManagedConnectionFactory mcf = mc.getManagedConnectionFactory(); // Only admit a connection if it has the same username as our // asked for creds // FIXME, Here we have a problem, jms connection // may be anonymous, have a user name if ((mc.getUserName() == null || (mc.getUserName() != null && mc.getUserName().equals(cred.name))) && mcf.equals(this)) { // Now check if ConnectionInfo equals if (info.equals(mc.getInfo())) { if (trace) log.trace("Found matching connection: " + mc); return mc; } } } } if (trace) log.trace("No matching connection was found"); return null; }