use of java.lang.reflect.InvocationHandler in project tomee by apache.
the class MdbProxy method newProxyInstance.
@SuppressWarnings({ "unchecked" })
public static <T> T newProxyInstance(final Class<T> type, final ConnectionFactory connectionFactory, final String requestQueueName) throws JMSException {
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
if (classLoader == null)
classLoader = type.getClassLoader();
if (classLoader == null)
classLoader = ClassLoader.getSystemClassLoader();
final InvocationHandler invocationHandler = new MdbInvocationHandler(connectionFactory, requestQueueName);
final Object proxy = Proxy.newProxyInstance(classLoader, new Class[] { type }, invocationHandler);
return (T) proxy;
}
use of java.lang.reflect.InvocationHandler in project cxf by apache.
the class MultiplexHttpAddressClientServerTest method testWithManualMultiplexEprCreation.
@Test
public void testWithManualMultiplexEprCreation() throws Exception {
Service numService = Service.create(NumberFactoryImpl.NUMBER_SERVICE_QNAME);
Number num = numService.getPort(Number.class);
InvocationHandler handler = Proxy.getInvocationHandler(num);
BindingProvider bp = (BindingProvider) handler;
bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, NUMBER_SERVANT_ADDRESS_ROOT + "103");
IsEvenResponse numResp = num.isEven();
assertTrue("103 is not even", Boolean.FALSE.equals(numResp.isEven()));
}
use of java.lang.reflect.InvocationHandler in project cxf by apache.
the class ClientMtomXopTest method createPort.
private <T> T createPort(QName serviceName, QName portName, Class<T> serviceEndpointInterface, boolean enableMTOM, boolean installInterceptors) throws Exception {
ReflectionServiceFactoryBean serviceFactory = new JaxWsServiceFactoryBean();
Bus bus = getStaticBus();
serviceFactory.setBus(bus);
serviceFactory.setServiceName(serviceName);
serviceFactory.setServiceClass(serviceEndpointInterface);
serviceFactory.setWsdlURL(ClientMtomXopTest.class.getResource("/wsdl/mtom_xop.wsdl"));
Service service = serviceFactory.create();
EndpointInfo ei = service.getEndpointInfo(portName);
JaxWsEndpointImpl jaxwsEndpoint = new JaxWsEndpointImpl(bus, service, ei);
SOAPBinding jaxWsSoapBinding = new SOAPBindingImpl(ei.getBinding(), jaxwsEndpoint);
jaxWsSoapBinding.setMTOMEnabled(enableMTOM);
if (installInterceptors) {
// jaxwsEndpoint.getBinding().getInInterceptors().add(new TestMultipartMessageInterceptor());
jaxwsEndpoint.getBinding().getOutInterceptors().add(new TestAttachmentOutInterceptor());
}
jaxwsEndpoint.getBinding().getInInterceptors().add(new LoggingInInterceptor());
jaxwsEndpoint.getBinding().getOutInterceptors().add(new LoggingOutInterceptor());
Client client = new ClientImpl(bus, jaxwsEndpoint);
InvocationHandler ih = new JaxWsClientProxy(client, jaxwsEndpoint.getJaxwsBinding());
Object obj = Proxy.newProxyInstance(serviceEndpointInterface.getClassLoader(), new Class[] { serviceEndpointInterface, BindingProvider.class }, ih);
updateAddressPort(obj, PORT);
return serviceEndpointInterface.cast(obj);
}
use of java.lang.reflect.InvocationHandler in project cxf by apache.
the class OOBHeaderTest method addOutOfBoundHeader.
private void addOutOfBoundHeader(PutLastTradedPricePortType portType, boolean invalid, boolean mu) {
InvocationHandler handler = Proxy.getInvocationHandler(portType);
BindingProvider bp = null;
try {
if (handler instanceof BindingProvider) {
bp = (BindingProvider) handler;
Map<String, Object> requestContext = bp.getRequestContext();
OutofBandHeader ob = new OutofBandHeader();
ob.setName("testOobHeader");
ob.setValue("testOobHeaderValue");
ob.setHdrAttribute(invalid ? "dontProcess" : "testHdrAttribute");
SoapHeader hdr = new SoapHeader(new QName(TEST_HDR_NS, TEST_HDR_REQUEST_ELEM), ob, new JAXBDataBinding(ob.getClass()));
hdr.setMustUnderstand(mu);
List<Header> holder = new ArrayList<>();
holder.add(hdr);
// Add List of headerHolders to requestContext.
requestContext.put(Header.HEADER_LIST, holder);
}
} catch (JAXBException ex) {
// System.out.println("failed to insert header into request context :" + ex);
}
}
use of java.lang.reflect.InvocationHandler in project cxf by apache.
the class SOAPJMSTestSuiteTest method oneWayTest.
private void oneWayTest(TestCaseType testcase, JMSSimplePortType port) throws Exception {
closeable = (java.io.Closeable) port;
InvocationHandler handler = Proxy.getInvocationHandler(port);
BindingProvider bp = (BindingProvider) handler;
Map<String, Object> requestContext = bp.getRequestContext();
JMSMessageHeadersType requestHeader = new JMSMessageHeadersType();
requestContext.put(JMSConstants.JMS_CLIENT_REQUEST_HEADERS, requestHeader);
Exception e = null;
try {
port.ping("test");
} catch (Exception e1) {
e = e1;
}
checkJMSProperties(testcase, requestHeader);
if (e != null) {
throw e;
}
}
Aggregations