use of org.apache.cxf.jca.cxf.CXFInvocationHandler 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;
}
use of org.apache.cxf.jca.cxf.CXFInvocationHandler in project cxf by apache.
the class AbstractInvocationHandlerTest method testBusAttribute.
@Test
public void testBusAttribute() {
CXFInvocationHandler handler = getHandler();
handler.getData().setBus(mockBus);
assertSame("bus must be retrievable after set", mockBus, handler.getData().getBus());
}
use of org.apache.cxf.jca.cxf.CXFInvocationHandler in project cxf by apache.
the class AbstractInvocationHandlerTest method testManagedConnectionAttribute.
@Test
public void testManagedConnectionAttribute() {
CXFInvocationHandler handler = getHandler();
handler.getData().setManagedConnection(mockManagedConnection);
assertSame("bus must be retrievable after set", mockManagedConnection, handler.getData().getManagedConnection());
}
use of org.apache.cxf.jca.cxf.CXFInvocationHandler in project cxf by apache.
the class InvocationHandlerFactoryTest method testCreateHandlerChain.
@Test
public void testCreateHandlerChain() throws ResourceAdapterInternalException {
CXFInvocationHandler first = handler;
CXFInvocationHandler last = null;
assertNotNull("handler must not be null", handler);
int count = 0;
Set<Class<?>> allHandlerTypes = new HashSet<>();
while (handler != null) {
assertSame("managed connection must be set", mci, handler.getData().getManagedConnection());
assertSame("bus must be set", mockBus, handler.getData().getBus());
assertSame("subject must be set", testSubject, handler.getData().getSubject());
assertSame("target must be set", target, handler.getData().getTarget());
allHandlerTypes.add(handler.getClass());
last = handler;
handler = handler.getNext();
count++;
}
assertNotNull(last);
assertEquals("must create correct number of handlers", count, 4);
assertTrue("first handler must a ProxyInvocationHandler", first instanceof ProxyInvocationHandler);
assertTrue("last handler must be an InvokingInvocationHandler", last instanceof InvokingInvocationHandler);
Class<?>[] types = { ProxyInvocationHandler.class, ObjectMethodInvocationHandler.class, InvokingInvocationHandler.class, SecurityTestHandler.class };
for (int i = 0; i < types.length; i++) {
assertTrue("handler chain must contain type: " + types[i], allHandlerTypes.contains(types[i]));
}
}
use of org.apache.cxf.jca.cxf.CXFInvocationHandler in project cxf by apache.
the class AbstractInvocationHandlerTest method testTargetAttribute.
@Test
public void testTargetAttribute() {
CXFInvocationHandler handler = getHandler();
handler.getData().setTarget(target);
assertSame("target must be retrievable after set", target, handler.getData().getTarget());
}
Aggregations