Search in sources :

Example 1 with CXFInvocationHandlerData

use of org.apache.cxf.jca.cxf.CXFInvocationHandlerData in project cxf by apache.

the class InvocationHandlerFactory method createHandlers.

public CXFInvocationHandler createHandlers(Object target, Subject subject) throws ResourceAdapterInternalException {
    CXFInvocationHandler first = null;
    CXFInvocationHandler last = null;
    // Create data member
    CXFInvocationHandlerData data = new CXFInvocationHandlerDataImpl();
    data.setBus(bus);
    data.setManagedConnection(managedConnection);
    data.setSubject(subject);
    data.setTarget(target);
    for (int i = 0; i < handlerChainTypes.length; i++) {
        CXFInvocationHandler newHandler;
        try {
            Constructor<?> newHandlerConstructor = handlerChainTypes[i].getDeclaredConstructor(new Class[] { CXFInvocationHandlerData.class });
            newHandler = (CXFInvocationHandler) newHandlerConstructor.newInstance(new Object[] { data });
        } catch (Exception ex) {
            ResourceAdapterInternalException raie = new ResourceAdapterInternalException("error creating InvocationHandler: " + handlerChainTypes[i], ex);
            LOG.warning(raie.getMessage());
            throw raie;
        }
        if (last != null) {
            last.setNext(newHandler);
            last = newHandler;
        } else {
            first = newHandler;
            last = newHandler;
        }
    }
    return first;
}
Also used : CXFInvocationHandler(org.apache.cxf.jca.cxf.CXFInvocationHandler) CXFInvocationHandlerData(org.apache.cxf.jca.cxf.CXFInvocationHandlerData) ResourceAdapterInternalException(org.apache.cxf.jca.core.resourceadapter.ResourceAdapterInternalException) ResourceAdapterInternalException(org.apache.cxf.jca.core.resourceadapter.ResourceAdapterInternalException) IOException(java.io.IOException)

Example 2 with CXFInvocationHandlerData

use of org.apache.cxf.jca.cxf.CXFInvocationHandlerData in project cxf by apache.

the class ObjectMethodInvocationHandlerTest method testEqualsThroughProxies.

@Test
public void testEqualsThroughProxies() {
    Class<?>[] interfaces = { TestInterface.class };
    CXFInvocationHandlerData data1 = new CXFInvocationHandlerDataImpl();
    CXFInvocationHandlerData data2 = new CXFInvocationHandlerDataImpl();
    data1.setTarget(new TestTarget());
    data2.setTarget(new TestTarget());
    ObjectMethodInvocationHandler handler1 = new ObjectMethodInvocationHandler(data1);
    handler1.setNext(mockHandler);
    ObjectMethodInvocationHandler handler2 = new ObjectMethodInvocationHandler(data2);
    handler2.setNext(mockHandler);
    TestInterface proxy1 = (TestInterface) Proxy.newProxyInstance(TestInterface.class.getClassLoader(), interfaces, handler1);
    TestInterface proxy2 = (TestInterface) Proxy.newProxyInstance(TestInterface.class.getClassLoader(), interfaces, handler2);
    assertEquals(proxy1, proxy1);
    assertTrue(!proxy1.equals(proxy2));
}
Also used : CXFInvocationHandlerData(org.apache.cxf.jca.cxf.CXFInvocationHandlerData) Test(org.junit.Test)

Example 3 with CXFInvocationHandlerData

use of org.apache.cxf.jca.cxf.CXFInvocationHandlerData in project cxf by apache.

the class InvokingInvocationHandlerTest method setUp.

@Before
public void setUp() {
    super.setUp();
    target = new TestTarget();
    data = new CXFInvocationHandlerDataImpl();
    data.setTarget(target);
    handler = new InvokingInvocationHandler(data);
    Class<?>[] interfaces = { TestInterface.class };
    test = (TestInterface) Proxy.newProxyInstance(TestInterface.class.getClassLoader(), interfaces, handler);
    handler.getData().setTarget(target);
    CXFInvocationHandlerData data2 = new CXFInvocationHandlerDataImpl();
    CXFInvocationHandler handler2 = new InvokingInvocationHandler(data2);
    test2 = (TestInterface) Proxy.newProxyInstance(TestInterface.class.getClassLoader(), interfaces, handler2);
    handler2.getData().setTarget(target);
}
Also used : CXFInvocationHandler(org.apache.cxf.jca.cxf.CXFInvocationHandler) CXFInvocationHandlerData(org.apache.cxf.jca.cxf.CXFInvocationHandlerData) Before(org.junit.Before)

Aggregations

CXFInvocationHandlerData (org.apache.cxf.jca.cxf.CXFInvocationHandlerData)3 CXFInvocationHandler (org.apache.cxf.jca.cxf.CXFInvocationHandler)2 IOException (java.io.IOException)1 ResourceAdapterInternalException (org.apache.cxf.jca.core.resourceadapter.ResourceAdapterInternalException)1 Before (org.junit.Before)1 Test (org.junit.Test)1