Search in sources :

Example 1 with AnnotationHandlerChainBuilder

use of org.apache.cxf.jaxws.handler.AnnotationHandlerChainBuilder in project camel by apache.

the class CxfEndpoint method setupHandlers.

protected void setupHandlers(ClientFactoryBean factoryBean, Client client) throws Exception {
    if (factoryBean instanceof JaxWsClientFactoryBean && handlers != null) {
        AnnotationHandlerChainBuilder builder = new AnnotationHandlerChainBuilder();
        Method m = factoryBean.getClass().getMethod("getServiceFactory");
        JaxWsServiceFactoryBean sf = (JaxWsServiceFactoryBean) m.invoke(factoryBean);
        @SuppressWarnings("rawtypes") List<Handler> chain = new ArrayList<Handler>(handlers);
        chain.addAll(builder.buildHandlerChainFromClass(sf.getServiceClass(), sf.getEndpointInfo().getName(), sf.getServiceQName(), factoryBean.getBindingId()));
        if (!chain.isEmpty()) {
            ResourceManager resourceManager = getBus().getExtension(ResourceManager.class);
            List<ResourceResolver> resolvers = resourceManager.getResourceResolvers();
            resourceManager = new DefaultResourceManager(resolvers);
            resourceManager.addResourceResolver(new WebServiceContextResourceResolver());
            ResourceInjector injector = new ResourceInjector(resourceManager);
            for (Handler<?> h : chain) {
                if (Proxy.isProxyClass(h.getClass()) && getServiceClass() != null) {
                    injector.inject(h, getServiceClass());
                    injector.construct(h, getServiceClass());
                } else {
                    injector.inject(h);
                    injector.construct(h);
                }
            }
        }
        ((JaxWsEndpointImpl) client.getEndpoint()).getJaxwsBinding().setHandlerChain(chain);
    }
}
Also used : JaxWsClientFactoryBean(org.apache.cxf.jaxws.JaxWsClientFactoryBean) JaxWsServiceFactoryBean(org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean) AnnotationHandlerChainBuilder(org.apache.cxf.jaxws.handler.AnnotationHandlerChainBuilder) ModCountCopyOnWriteArrayList(org.apache.cxf.common.util.ModCountCopyOnWriteArrayList) ArrayList(java.util.ArrayList) CookieHandler(org.apache.camel.http.common.cookie.CookieHandler) Handler(javax.xml.ws.handler.Handler) Method(java.lang.reflect.Method) ResourceManager(org.apache.cxf.resource.ResourceManager) DefaultResourceManager(org.apache.cxf.resource.DefaultResourceManager) ResourceInjector(org.apache.cxf.common.injection.ResourceInjector) DefaultResourceManager(org.apache.cxf.resource.DefaultResourceManager) ResourceResolver(org.apache.cxf.resource.ResourceResolver) WebServiceContextResourceResolver(org.apache.cxf.jaxws.context.WebServiceContextResourceResolver) WebServiceContextResourceResolver(org.apache.cxf.jaxws.context.WebServiceContextResourceResolver)

Example 2 with AnnotationHandlerChainBuilder

use of org.apache.cxf.jaxws.handler.AnnotationHandlerChainBuilder in project cxf by apache.

the class JaxWsServerFactoryBean method buildHandlerChain.

/**
 * Obtain handler chain from annotations.
 * @param server
 */
private void buildHandlerChain(Server server) {
    AnnotationHandlerChainBuilder builder = new AnnotationHandlerChainBuilder();
    @SuppressWarnings("rawtypes") List<Handler> chain = new ArrayList<>(handlers);
    chain.addAll(builder.buildHandlerChainFromClass(getServiceBeanClass(), server.getEndpoint().getEndpointInfo().getName(), server.getEndpoint().getService().getName(), this.getBindingId()));
    for (Handler<?> h : chain) {
        injectResources(h);
    }
    ((JaxWsEndpointImpl) server.getEndpoint()).getJaxwsBinding().setHandlerChain(chain);
}
Also used : AnnotationHandlerChainBuilder(org.apache.cxf.jaxws.handler.AnnotationHandlerChainBuilder) ArrayList(java.util.ArrayList) Handler(javax.xml.ws.handler.Handler)

Example 3 with AnnotationHandlerChainBuilder

use of org.apache.cxf.jaxws.handler.AnnotationHandlerChainBuilder in project cxf by apache.

the class JaxWsProxyFactoryBean method buildHandlerChain.

private void buildHandlerChain(JaxWsClientProxy cp) {
    AnnotationHandlerChainBuilder builder = new AnnotationHandlerChainBuilder();
    JaxWsServiceFactoryBean sf = (JaxWsServiceFactoryBean) getServiceFactory();
    @SuppressWarnings("rawtypes") List<Handler> chain = new ArrayList<>(handlers);
    if (loadHandlers) {
        chain.addAll(builder.buildHandlerChainFromClass(sf.getServiceClass(), sf.getEndpointInfo().getName(), sf.getServiceQName(), this.getBindingId()));
    }
    if (!chain.isEmpty()) {
        ResourceManager resourceManager = getBus().getExtension(ResourceManager.class);
        List<ResourceResolver> resolvers = resourceManager.getResourceResolvers();
        resourceManager = new DefaultResourceManager(resolvers);
        resourceManager.addResourceResolver(new WebServiceContextResourceResolver());
        ResourceInjector injector = new ResourceInjector(resourceManager);
        for (Handler<?> h : chain) {
            if (Proxy.isProxyClass(h.getClass()) && getServiceClass() != null) {
                injector.inject(h, getServiceClass());
                injector.construct(h, getServiceClass());
            } else {
                injector.inject(h);
                injector.construct(h);
            }
        }
    }
    cp.getBinding().setHandlerChain(chain);
}
Also used : JaxWsServiceFactoryBean(org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean) AnnotationHandlerChainBuilder(org.apache.cxf.jaxws.handler.AnnotationHandlerChainBuilder) ArrayList(java.util.ArrayList) Handler(javax.xml.ws.handler.Handler) DefaultResourceManager(org.apache.cxf.resource.DefaultResourceManager) ResourceManager(org.apache.cxf.resource.ResourceManager) ResourceInjector(org.apache.cxf.common.injection.ResourceInjector) DefaultResourceManager(org.apache.cxf.resource.DefaultResourceManager) ResourceResolver(org.apache.cxf.resource.ResourceResolver) WebServiceContextResourceResolver(org.apache.cxf.jaxws.context.WebServiceContextResourceResolver) WebServiceContextResourceResolver(org.apache.cxf.jaxws.context.WebServiceContextResourceResolver)

Aggregations

ArrayList (java.util.ArrayList)3 Handler (javax.xml.ws.handler.Handler)3 AnnotationHandlerChainBuilder (org.apache.cxf.jaxws.handler.AnnotationHandlerChainBuilder)3 ResourceInjector (org.apache.cxf.common.injection.ResourceInjector)2 WebServiceContextResourceResolver (org.apache.cxf.jaxws.context.WebServiceContextResourceResolver)2 JaxWsServiceFactoryBean (org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean)2 DefaultResourceManager (org.apache.cxf.resource.DefaultResourceManager)2 ResourceManager (org.apache.cxf.resource.ResourceManager)2 ResourceResolver (org.apache.cxf.resource.ResourceResolver)2 Method (java.lang.reflect.Method)1 CookieHandler (org.apache.camel.http.common.cookie.CookieHandler)1 ModCountCopyOnWriteArrayList (org.apache.cxf.common.util.ModCountCopyOnWriteArrayList)1 JaxWsClientFactoryBean (org.apache.cxf.jaxws.JaxWsClientFactoryBean)1