Java Code Examples for javax.resource.spi.ManagedConnectionFactory#createManagedConnection()

The following examples show how to use javax.resource.spi.ManagedConnectionFactory#createManagedConnection() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ActiveMQRAConnectionManager.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
/**
 * Allocates a connection
 *
 * @param mcf           The managed connection factory
 * @param cxRequestInfo The connection request information
 * @return The connection
 * @throws ResourceException Thrown if there is a problem obtaining the connection
 */
@Override
public Object allocateConnection(final ManagedConnectionFactory mcf,
                                 final ConnectionRequestInfo cxRequestInfo) throws ResourceException {
   if (ActiveMQRALogger.LOGGER.isTraceEnabled()) {
      ActiveMQRALogger.LOGGER.trace("allocateConnection(" + mcf + ", " + cxRequestInfo + ")");
   }

   ManagedConnection mc = mcf.createManagedConnection(null, cxRequestInfo);
   Object c = mc.getConnection(null, cxRequestInfo);

   if (ActiveMQRALogger.LOGGER.isTraceEnabled()) {
      ActiveMQRALogger.LOGGER.trace("Allocated connection: " + c + ", with managed connection: " + mc);
   }

   connections.add(mc);
   return c;
}
 
Example 2
Source File: DefaultConnectionManager.java    From cxf with Apache License 2.0 5 votes vote down vote up
public Object allocateConnection(ManagedConnectionFactory mcf,
        ConnectionRequestInfo cxRequestInfo) throws ResourceException {

    if (LOG.isLoggable(Level.FINEST)) {
        LOG.finest("allocateConnection cxRequestInfo = " + cxRequestInfo);
    }

    ManagedConnection mc = mcf.createManagedConnection(null, cxRequestInfo);
    mc.addConnectionEventListener(this);
    return mc.getConnection(null, cxRequestInfo);
}
 
Example 3
Source File: OutBoundConnectionTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
@org.junit.Ignore
public void testBasicConnection() throws Exception {
    URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl");
    assertNotNull(wsdl);

    SOAPService service = new SOAPService(wsdl, serviceName);
    assertNotNull(service);

    CXFConnectionRequestInfo cri = new CXFConnectionRequestInfo(Greeter.class,
                                       wsdl,
                                       service.getServiceName(),
                                       portName);
    cri.setAddress("http://localhost:" + PORT + "/SoapContext/SoapPort");
    ManagedConnectionFactory managedFactory = new ManagedConnectionFactoryImpl();
    Subject subject = new Subject();
    ManagedConnection mc = managedFactory.createManagedConnection(subject, cri);
    Object o = mc.getConnection(subject, cri);

    // test for the Object hash()
    try {
        o.hashCode();
        o.toString();
    } catch (WebServiceException ex) {
        fail("The connection object should support Object method");
    }

    verifyResult(o);
}
 
Example 4
Source File: OutBoundConnectionTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
@org.junit.Ignore
public void testGetConnectionFromSEI() throws Exception {
    CXFConnectionRequestInfo requestInfo = new CXFConnectionRequestInfo();
    requestInfo.setInterface(Greeter.class);
    requestInfo.setAddress("http://localhost:" + PORT + "/SoapContext/SoapPort");

    ManagedConnectionFactory factory = new ManagedConnectionFactoryImpl();
    ManagedConnection mc = factory.createManagedConnection(null, requestInfo);
    Object client = mc.getConnection(null, requestInfo);

    verifyResult(client);
}