Search in sources :

Example 1 with JaxWsServiceFactoryBean

use of org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean 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 JaxWsServiceFactoryBean

use of org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean in project camel by apache.

the class CxfProducerSessionTest method startServer.

@BeforeClass
public static void startServer() throws Exception {
    // start a simple front service
    JaxWsServiceFactoryBean svrFBean = new JaxWsServiceFactoryBean();
    svrFBean.setServiceClass(EchoService.class);
    JaxWsServerFactoryBean svrBean = new JaxWsServerFactoryBean(svrFBean);
    svrBean.setAddress(SIMPLE_SERVER_ADDRESS);
    svrBean.setServiceClass(EchoService.class);
    svrBean.setServiceBean(new EchoServiceSessionImpl());
    // make the Jetty server support sessions
    Bus bus = BusFactory.newInstance().createBus();
    JettyHTTPServerEngineFactory jettyFactory = bus.getExtension(JettyHTTPServerEngineFactory.class);
    jettyFactory.createJettyHTTPServerEngine(PORT, "http").setSessionSupport(true);
    svrBean.setBus(bus);
    svrBean.create();
}
Also used : Bus(org.apache.cxf.Bus) JaxWsServiceFactoryBean(org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean) JettyHTTPServerEngineFactory(org.apache.cxf.transport.http_jetty.JettyHTTPServerEngineFactory) JaxWsServerFactoryBean(org.apache.cxf.jaxws.JaxWsServerFactoryBean) BeforeClass(org.junit.BeforeClass)

Aggregations

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