use of javax.resource.spi.ManagedConnection in project wildfly by wildfly.
the class DistributedManagedConnectionFactory1 method matchManagedConnections.
/**
* Returns a matched connection from the candidate set of connections.
*
* @param connectionSet Candidate connection set
* @param subject Caller's security information
* @param cxRequestInfo Additional resource adapter specific connection request information
* @return ManagedConnection if resource adapter finds an acceptable match otherwise null
* @throws ResourceException generic exception
*/
public ManagedConnection matchManagedConnections(Set connectionSet, Subject subject, ConnectionRequestInfo cxRequestInfo) throws ResourceException {
ManagedConnection result = null;
Iterator it = connectionSet.iterator();
while (result == null && it.hasNext()) {
ManagedConnection mc = (ManagedConnection) it.next();
if (mc instanceof DistributedManagedConnection1) {
result = mc;
}
}
return result;
}
use of javax.resource.spi.ManagedConnection in project wildfly by wildfly.
the class MultipleManagedConnectionFactory2 method matchManagedConnections.
/**
* Returns a matched connection from the candidate set of connections.
*
* @param connectionSet Candidate connection set
* @param subject Caller's security information
* @param cxRequestInfo Additional resource adapter specific connection request information
* @return ManagedConnection if resource adapter finds an acceptable match otherwise null
* @throws ResourceException generic exception
*/
public ManagedConnection matchManagedConnections(Set connectionSet, Subject subject, ConnectionRequestInfo cxRequestInfo) throws ResourceException {
log.trace("matchManagedConnections()");
ManagedConnection result = null;
Iterator it = connectionSet.iterator();
while (result == null && it.hasNext()) {
ManagedConnection mc = (ManagedConnection) it.next();
if (mc instanceof MultipleManagedConnection2) {
result = mc;
}
}
return result;
}
use of javax.resource.spi.ManagedConnection in project wildfly by wildfly.
the class HelloWorldManagedConnectionFactory method matchManagedConnections.
/**
* Returns a matched connection from the candidate set of connections.
*
* @param connectionSet candidate connection set
* @param subject Caller's security information
* @param cxRequestInfo Additional resource adapter specific connection request information
* @throws ResourceException generic exception
* @return ManagedConnection if resource adapter finds an acceptable match otherwise null
*/
public ManagedConnection matchManagedConnections(Set connectionSet, Subject subject, ConnectionRequestInfo cxRequestInfo) throws ResourceException {
ManagedConnection result = null;
Iterator it = connectionSet.iterator();
while (result == null && it.hasNext()) {
ManagedConnection mc = (ManagedConnection) it.next();
if (mc instanceof HelloWorldManagedConnection) {
HelloWorldManagedConnection hwmc = (HelloWorldManagedConnection) mc;
result = hwmc;
}
}
return result;
}
use of javax.resource.spi.ManagedConnection in project wildfly by wildfly.
the class MultipleManagedConnectionFactory2 method matchManagedConnections.
/**
* Returns a matched connection from the candidate set of connections.
*
* @param connectionSet Candidate connection set
* @param subject Caller's security information
* @param cxRequestInfo Additional resource adapter specific connection request information
* @return ManagedConnection if resource adapter finds an acceptable match otherwise null
* @throws ResourceException generic exception
*/
public ManagedConnection matchManagedConnections(Set connectionSet, Subject subject, ConnectionRequestInfo cxRequestInfo) throws ResourceException {
log.trace("matchManagedConnections()");
ManagedConnection result = null;
Iterator it = connectionSet.iterator();
while (result == null && it.hasNext()) {
ManagedConnection mc = (ManagedConnection) it.next();
if (mc instanceof MultipleManagedConnection2) {
result = mc;
}
}
return result;
}
use of javax.resource.spi.ManagedConnection in project jackrabbit by apache.
the class ConnectionFactoryTest method testMatching.
/**
* Test the connection matching.
*/
public void testMatching() throws Exception {
// Create connection request infos
JCAConnectionRequestInfo cri1 = new JCAConnectionRequestInfo(JCR_SUPERUSER, JCR_WORKSPACE);
JCAConnectionRequestInfo cri2 = new JCAConnectionRequestInfo(JCR_ANONUSER, JCR_WORKSPACE);
// Check if not same
assertNotSame(cri1, cri2);
// Create the connection factory
mcf.createConnectionFactory();
// Allocate connections
ManagedConnection mc1 = mcf.createManagedConnection(null, cri1);
ManagedConnection mc2 = mcf.createManagedConnection(null, cri2);
// Check if not same
assertTrue(mc1 != mc2);
// Create a sef of connections
HashSet connectionSet = new HashSet();
connectionSet.add(mc1);
connectionSet.add(mc2);
// Match the first connection
JCAConnectionRequestInfo cri3 = new JCAConnectionRequestInfo(cri1);
assertTrue((cri1 != cri3) && cri1.equals(cri3));
ManagedConnection mc3 = mcf.matchManagedConnections(connectionSet, null, cri3);
assertTrue(mc1 == mc3);
// Match the second connection
JCAConnectionRequestInfo cri4 = new JCAConnectionRequestInfo(cri2);
assertTrue((cri2 != cri4) && cri2.equals(cri4));
ManagedConnection mc4 = mcf.matchManagedConnections(connectionSet, null, cri4);
assertTrue(mc2 == mc4);
}
Aggregations