Search in sources :

Example 21 with Handler

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;
}
Also used : LogicalHandler(javax.xml.ws.handler.LogicalHandler) ArrayList(java.util.ArrayList) LogicalHandler(javax.xml.ws.handler.LogicalHandler) Handler(javax.xml.ws.handler.Handler)

Example 22 with Handler

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)));
            }
        }
    }
}
Also used : Exchange(org.apache.cxf.message.Exchange) HandlerChainInvoker(org.apache.cxf.jaxws.handler.HandlerChainInvoker) Handler(javax.xml.ws.handler.Handler)

Example 23 with Handler

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();
                }
            }
        }
    }
}
Also used : ConfigDelegateHandler(org.jboss.ws.common.configuration.ConfigDelegateHandler) Reference(org.jboss.wsf.spi.deployment.Reference) ConfigDelegateHandler(org.jboss.ws.common.configuration.ConfigDelegateHandler) Handler(javax.xml.ws.handler.Handler) RequestHandler(org.jboss.wsf.spi.invocation.RequestHandler)

Example 24 with Handler

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);
            }
        }
    }
}
Also used : Exchange(org.apache.cxf.message.Exchange) HandlerChainInvoker(org.apache.cxf.jaxws.handler.HandlerChainInvoker) JaxWsEndpointImpl(org.apache.cxf.jaxws.support.JaxWsEndpointImpl) Handler(javax.xml.ws.handler.Handler)

Example 25 with Handler

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;
}
Also used : WebServiceException(javax.xml.ws.WebServiceException) ArrayList(java.util.ArrayList) Handler(javax.xml.ws.handler.Handler) LogicalHandler(javax.xml.ws.handler.LogicalHandler) WebServiceException(javax.xml.ws.WebServiceException)

Aggregations

Handler (javax.xml.ws.handler.Handler)100 QName (javax.xml.namespace.QName)47 ArrayList (java.util.ArrayList)46 BindingProvider (javax.xml.ws.BindingProvider)36 URL (java.net.URL)32 Service (javax.xml.ws.Service)29 Test (org.junit.Test)29 LogicalHandler (javax.xml.ws.handler.LogicalHandler)24 Binding (javax.xml.ws.Binding)11 WebServiceException (javax.xml.ws.WebServiceException)11 MessageContext (javax.xml.ws.handler.MessageContext)9 SOAPHandler (javax.xml.ws.handler.soap.SOAPHandler)9 Exchange (org.apache.cxf.message.Exchange)9 IOException (java.io.IOException)8 SOAPMessageContext (javax.xml.ws.handler.soap.SOAPMessageContext)7 HandlerChainInvoker (org.apache.cxf.jaxws.handler.HandlerChainInvoker)7 DataHandler (javax.activation.DataHandler)6 InitialContext (javax.naming.InitialContext)6 Source (javax.xml.transform.Source)6 DOMSource (javax.xml.transform.dom.DOMSource)6