use of org.apache.cxf.message.Exchange in project jbossws-cxf by jbossws.
the class JBossWSInvokerTest method testMessageContextThreadLocal.
/**
* The JBossWSInvoker internals rely on the Apache CXF side of the Invoker abstraction to properly
* set the generated WrappedMessageContext into the WebServiceContextImpl's threadlocal. As a consequence,
* the JBossWSInvoker::performInvocation method can build up the JBoss integration WebServiceContext without
* needing to pass in a MessageContext, as the properly created one is automatically retrieved internally
* using the Apache CXF thread local. This all however assumes the Invoker inheritance tree is not erroneously
* changed or the integration is not inadvertently broken in some way.
* This test hence verifies the MessageContext instance is available inside the performInvocation method.
*/
@Test
public void testMessageContextThreadLocal() {
TestInvoker invoker = new TestInvoker();
// just to avoid internal NPE
invoker.setTargetBean(this);
Exchange exchange = getTestExchange();
Object obj = invoker.invoke(exchange, null);
String res = obj instanceof List<?> ? ((List<?>) obj).get(0).toString() : obj.toString();
assertEquals("OK", res);
}
use of org.apache.cxf.message.Exchange in project jbossws-cxf by jbossws.
the class EndpointAssociationInterceptor method handleMessage.
@Override
public void handleMessage(Message message) throws Fault {
Endpoint endpoint = EndpointAssociation.getEndpoint();
Exchange exchange = message.getExchange();
exchange.put(Endpoint.class, endpoint);
}
use of org.apache.cxf.message.Exchange in project jbossws-cxf by jbossws.
the class HandlerAuthInterceptor method handleMessage.
@Override
public void handleMessage(Message message) throws Fault {
final Exchange ex = message.getExchange();
HandlerChainInvoker invoker = ex.get(HandlerChainInvoker.class);
if (null == invoker) {
final org.apache.cxf.endpoint.Endpoint endpoint = ex.getEndpoint();
if (endpoint instanceof JaxWsEndpointImpl) {
// JAXWS handlers are not assigned to different endpoint types
final JaxWsEndpointImpl ep = (JaxWsEndpointImpl) endpoint;
@SuppressWarnings("rawtypes") final List<Handler> handlerChain = ep.getJaxwsBinding().getHandlerChain();
if (handlerChain != null && !handlerChain.isEmpty()) {
// save
invoker = new JBossWSHandlerChainInvoker(handlerChain, isOutbound(message, ex));
ex.put(HandlerChainInvoker.class, invoker);
}
}
}
}
use of org.apache.cxf.message.Exchange in project tomee by apache.
the class PhaseInterceptorChain method getServiceInfo.
private String getServiceInfo(Message message) {
StringBuilder description = new StringBuilder();
if (message.getExchange() != null) {
Exchange exchange = message.getExchange();
Service service = exchange.getService();
if (service != null) {
description.append('\'');
description.append(service.getName());
BindingOperationInfo boi = exchange.getBindingOperationInfo();
OperationInfo opInfo = boi != null ? boi.getOperationInfo() : null;
if (opInfo != null) {
description.append('#').append(opInfo.getName());
}
description.append("\' ");
}
}
return description.toString();
}
use of org.apache.cxf.message.Exchange in project tomee by apache.
the class JAXRSOutInterceptor method processResponse.
// Response shouldn't be closed here
@SuppressWarnings("resource")
private void processResponse(ServerProviderFactory providerFactory, Message message) {
if (isResponseAlreadyHandled(message)) {
return;
}
MessageContentsList objs = MessageContentsList.getContentsList(message);
if (objs == null || objs.isEmpty()) {
return;
}
Object responseObj = objs.get(0);
final Response response;
if (responseObj instanceof Response) {
response = (Response) responseObj;
if (response.getStatus() == 500 && message.getExchange().get(JAXRSUtils.EXCEPTION_FROM_MAPPER) != null) {
message.put(Message.RESPONSE_CODE, 500);
return;
}
} else {
int status = getStatus(message, responseObj != null ? 200 : 204);
response = JAXRSUtils.toResponseBuilder(status).entity(responseObj).build();
}
Exchange exchange = message.getExchange();
OperationResourceInfo ori = (OperationResourceInfo) exchange.get(OperationResourceInfo.class.getName());
serializeMessage(providerFactory, message, response, ori, true);
}
Aggregations