use of javax.xml.ws.handler.Handler in project jbossws-cxf by jbossws.
the class CXFHandlerResolverImpl method sortHandlers.
@SuppressWarnings("rawtypes")
public List<Handler> sortHandlers(List<Handler> handlers) {
final int size = handlers.size();
List<Handler> logicalHandlers = new ArrayList<Handler>(size);
List<Handler> protocolHandlers = new ArrayList<Handler>(Math.min(10, size));
for (Handler handler : handlers) {
if (handler instanceof LogicalHandler) {
logicalHandlers.add(handler);
} else {
protocolHandlers.add(handler);
}
}
if (!protocolHandlers.isEmpty()) {
logicalHandlers.addAll(protocolHandlers);
}
return logicalHandlers;
}
use of javax.xml.ws.handler.Handler in project jbossws-cxf by jbossws.
the class HandlerChainSortInterceptor method handleMessage.
@Override
@SuppressWarnings("rawtypes")
public void handleMessage(Message message) throws Fault {
if (binding != null) {
Exchange ex = message.getExchange();
if (ex.get(HandlerChainInvoker.class) == null) {
List<Handler> hc = binding.getHandlerChain();
if (hc.size() > 1) {
// no need to sort etc if the chain is empty or has one handler only
Collections.sort(hc, comparator);
// install a new HandlerChainInvoker using the sorted handler chain;
// the AbstractJAXWSHandlerInterceptor will be using this invoker
// instead of creating a new one
ex.put(HandlerChainInvoker.class, new HandlerChainInvoker(hc, isOutbound(message, ex)));
}
}
}
}
use of javax.xml.ws.handler.Handler in project jbossws-cxf by jbossws.
the class ServletHelper method injectServiceAndHandlerResources.
private static void injectServiceAndHandlerResources(Endpoint endpoint) {
org.apache.cxf.endpoint.Endpoint ep = endpoint.getAttachment(org.apache.cxf.endpoint.Endpoint.class);
if (ep != null) {
@SuppressWarnings("rawtypes") List<Handler> chain = ((JaxWsEndpointImpl) ep).getJaxwsBinding().getHandlerChain();
if (chain != null) {
for (Handler<?> handler : chain) {
if (handler instanceof ConfigDelegateHandler) {
handler = ((ConfigDelegateHandler<?>) handler).getDelegate();
}
final Reference handlerReference = endpoint.getInstanceProvider().getInstance(handler.getClass().getName());
if (!handlerReference.isInitialized()) {
final Object handlerInstance = handlerReference.getValue();
InjectionHelper.callPostConstructMethod(handlerInstance);
handlerReference.setInitialized();
}
}
}
}
}
use of javax.xml.ws.handler.Handler 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 javax.xml.ws.handler.Handler in project tomee by apache.
the class ClientHandlerResolverImpl method buildHandlers.
private List<Handler> buildHandlers(final javax.xml.ws.handler.PortInfo portInfo, final HandlerChainMetaData handlerChain) {
if (!matchServiceName(portInfo, handlerChain.getServiceNamePattern()) || !matchPortName(portInfo, handlerChain.getPortNamePattern()) || !matchBinding(portInfo, handlerChain.getProtocolBindings())) {
return Collections.emptyList();
}
final List<Handler> handlers = new ArrayList<Handler>(handlerChain.getHandlers().size());
for (final HandlerMetaData handler : handlerChain.getHandlers()) {
try {
final Class<? extends Handler> handlerClass = loadClass(handler.getHandlerClass()).asSubclass(Handler.class);
final ClientInjectionProcessor<Handler> processor = new ClientInjectionProcessor<Handler>(handlerClass, injections, handler.getPostConstruct(), handler.getPreDestroy(), context);
processor.createInstance();
processor.postConstruct();
final Handler handlerInstance = processor.getInstance();
handlers.add(handlerInstance);
handlerInstances.add(processor);
} catch (Exception e) {
throw new WebServiceException("Failed to instantiate handler", e);
}
}
return handlers;
}
Aggregations