Package org.apache.cxf.phase

Examples of org.apache.cxf.phase.PhaseInterceptorChain


    public void onMessage(Message m) {
        Bus origBus = BusFactory.getThreadDefaultBus(false);
        BusFactory.setThreadDefaultBus(bus);
        try {
            PhaseInterceptorChain phaseChain = null;
           
            if (m.getInterceptorChain() instanceof PhaseInterceptorChain) {
                phaseChain = (PhaseInterceptorChain)m.getInterceptorChain();
                if (phaseChain.getState() == InterceptorChain.State.PAUSED) {
                    phaseChain.resume();
                    return;
                }
            }
           
            Message message = getBinding().createMessage(m);
            Exchange exchange = message.getExchange();
            if (exchange == null) {
                exchange = new ExchangeImpl();
                m.setExchange(exchange);
            }
            exchange.setInMessage(message);
            setExchangeProperties(exchange, message);
   
            InterceptorProvider dbp = null;
            if (endpoint.getService().getDataBinding() instanceof InterceptorProvider) {
                dbp = (InterceptorProvider)endpoint.getService().getDataBinding();
            }
            // setup chain
            if (dbp == null) {
                phaseChain = chainCache.get(bus.getExtension(PhaseManager.class).getInPhases(),
                                                             bus.getInInterceptors(),
                                                             endpoint.getService().getInInterceptors(),
                                                             endpoint.getInInterceptors(),
                                                             getBinding().getInInterceptors());
            } else {
                phaseChain = chainCache.get(bus.getExtension(PhaseManager.class).getInPhases(),
                                            bus.getInInterceptors(),
                                            endpoint.getService().getInInterceptors(),
                                            endpoint.getInInterceptors(),
                                            getBinding().getInInterceptors(),
                                            dbp.getInInterceptors());
            }
       
           
           
            message.setInterceptorChain(phaseChain);
           
            phaseChain.setFaultObserver(endpoint.getOutFaultObserver());
          
            addToChain(phaseChain, message);
           
            phaseChain.doIntercept(message);
        } finally {
            BusFactory.setThreadDefaultBus(origBus);
        }
    }
View Full Code Here


            setOutMessageProperties(message, oi);
            setExchangeProperties(exchange, endpoint, oi);

            // setup chain

            PhaseInterceptorChain chain = setupInterceptorChain(endpoint);
            message.setInterceptorChain(chain);

            chain.setFaultObserver(outFaultObserver);

            // setup conduit selector
            prepareConduitSelector(message);
           
            // add additional interceptors and such
            modifyChain(chain, message, false);

            // execute chain
            chain.doIntercept(message);

        } finally {
            BusFactory.setThreadDefaultBus(origBus);
        }
    }
View Full Code Here

            setOutMessageProperties(message, oi);
            setExchangeProperties(exchange, endpoint, oi);

            // setup chain

            PhaseInterceptorChain chain = setupInterceptorChain(endpoint);
            message.setInterceptorChain(chain);

            chain.setFaultObserver(outFaultObserver);

            // setup conduit selector
            prepareConduitSelector(message);

            // add additional interceptors and such
            modifyChain(chain, message, false);
            try {
                // execute chain
                chain.doIntercept(message);
            } catch (Fault fault) {
                if (fault.getCause().getCause() instanceof IOException
                        || fault.getCause() instanceof IOException) {
                    String soap11NS = "http://schemas.xmlsoap.org/soap/envelope/";
                    String soap12NS = "http://www.w3.org/2003/05/soap-envelope";
View Full Code Here

        List<Interceptor> i4 = endpoint.getBinding().getInInterceptors();
        if (LOG.isLoggable(Level.FINE)) {
            LOG.fine("Interceptors contributed by binding: " + i4);
        }

        PhaseInterceptorChain chain;
        if (endpoint.getService().getDataBinding() instanceof InterceptorProvider) {
            InterceptorProvider p = (InterceptorProvider)endpoint.getService().getDataBinding();
            if (LOG.isLoggable(Level.FINE)) {
                LOG.fine("Interceptors contributed by databinging: " + p.getInInterceptors());
            }
            chain = inboundChainCache.get(pm.getInPhases(), i1, i2, i3, i4,
                                          p.getInInterceptors());
        } else {
            chain = inboundChainCache.get(pm.getInPhases(), i1, i2, i3, i4);
        }
        message.setInterceptorChain(chain);

        chain.setFaultObserver(outFaultObserver);
        modifyChain(chain, message, true);
        modifyChain(chain, message.getExchange().getOutMessage(), true);
       
        Bus origBus = BusFactory.getThreadDefaultBus(false);
        BusFactory.setThreadDefaultBus(bus);
        // execute chain
        ClientCallback callback = message.getExchange().get(ClientCallback.class);
        try {
            if (callback != null) {
                if (callback.isCancelled()) {
                    getConduitSelector().complete(message.getExchange());
                    return;
                }
                callback.start(message);
            }

            String startingAfterInterceptorID = (String) message.get(
                PhaseInterceptorChain.STARTING_AFTER_INTERCEPTOR_ID);
            String startingInterceptorID = (String) message.get(
                PhaseInterceptorChain.STARTING_AT_INTERCEPTOR_ID);
            if (startingAfterInterceptorID != null) {
                chain.doInterceptStartingAfter(message, startingAfterInterceptorID);
            } else if (startingInterceptorID != null) {
                chain.doInterceptStartingAt(message, startingInterceptorID);
            } else if (message.getContent(Exception.class) != null) {
                outFaultObserver.onMessage(message);
            } else {
                chain.doIntercept(message);
            }

            callback = message.getExchange().get(ClientCallback.class);

            if (callback != null && !isPartialResponse(message)) {
View Full Code Here

        exchange.put(MessageObserver.class, new ClientMessageObserver(cfg));
        exchange.put(Endpoint.class, cfg.getConduitSelector().getEndpoint());
        exchange.setOneWay("true".equals(headers.getFirst(Message.ONE_WAY_REQUEST)));
        m.setExchange(exchange);
       
        PhaseInterceptorChain chain = setupOutInterceptorChain(cfg);
        m.setInterceptorChain(chain);
       
        // context
        if (cfg.getRequestContext().size() > 0 || cfg.getResponseContext().size() > 0) {
            Map<String, Object> context = new HashMap<String, Object>();
View Full Code Here

        NullableProviderService serviceObject = new NullableProviderService();
        Method serviceMethod = NullableProviderService.class.getMethod("invoke", new Class[]{Source.class});
       
        Exchange ex = new ExchangeImpl();
        Message inMessage = new MessageImpl();
        inMessage.setInterceptorChain(new PhaseInterceptorChain(new TreeSet<Phase>()));
        ex.setInMessage(inMessage);
        inMessage.setExchange(ex);
        inMessage.put(Message.REQUESTOR_ROLE, Boolean.TRUE);
       
        JAXWSMethodInvoker jaxwsMethodInvoker = prepareJAXWSMethodInvoker(ex, serviceObject, serviceMethod);
View Full Code Here

    protected static PhaseInterceptorChain setupOutInterceptorChain(ClientConfiguration cfg) {
        PhaseManager pm = cfg.getBus().getExtension(PhaseManager.class);
        List<Interceptor<? extends Message>> i1 = cfg.getBus().getOutInterceptors();
        List<Interceptor<? extends Message>> i2 = cfg.getOutInterceptors();
        List<Interceptor<? extends Message>> i3 = cfg.getConduitSelector().getEndpoint().getOutInterceptors();
        PhaseInterceptorChain chain = new PhaseChainCache().get(pm.getOutPhases(), i1, i2, i3);
        chain.add(new ClientRequestFilterInterceptor());
        return chain;
    }
View Full Code Here

    protected static PhaseInterceptorChain setupInInterceptorChain(ClientConfiguration cfg) {
        PhaseManager pm = cfg.getBus().getExtension(PhaseManager.class);
        List<Interceptor<? extends Message>> i1 = cfg.getBus().getInInterceptors();
        List<Interceptor<? extends Message>> i2 = cfg.getInInterceptors();
        List<Interceptor<? extends Message>> i3 = cfg.getConduitSelector().getEndpoint().getInInterceptors();
        PhaseInterceptorChain chain = new PhaseChainCache().get(pm.getInPhases(), i1, i2, i3);
        chain.add(new ClientResponseFilterInterceptor());
        return chain;
    }
View Full Code Here

            setEmptyRequestProperty(m, httpMethod);
        }
       
        m.put(URITemplate.TEMPLATE_PARAMETERS, getState().getTemplates());
       
        PhaseInterceptorChain chain = setupOutInterceptorChain(cfg);
        m.setInterceptorChain(chain);
       
        exchange = createExchange(m, exchange);
        exchange.setOneWay("true".equals(headers.getFirst(Message.ONE_WAY_REQUEST)));
        exchange.put(Retryable.class, this);
View Full Code Here

            // have handlers so have to run handlers now and redo data binding
            // as handlers can change the soap message
            log.debug("Handlers found.");

            Message inMessage = exchange.getInMessage();
            PhaseInterceptorChain chain = new PhaseInterceptorChain(bus.getExtension(PhaseManager.class).getInPhases());

            chain.setFaultObserver(endpoint.getOutFaultObserver());

            /*
             * Since we have to re-do data binding and the XMLStreamReader
             * contents are already consumed by prior data binding step
             * we have to reinitialize the XMLStreamReader from the SOAPMessage
             * created by SAAJInInterceptor.
             */
            if (inMessage instanceof SoapMessage) {
                try {
                    reserialize((SoapMessage) inMessage);
                } catch (Exception e) {
                    throw new RuntimeException("Failed to reserialize soap message", e);
                }
            } else {
                // TODO: how to handle XML/HTTP binding?
            }

            this.exchange.setOutMessage(null);

            // install default interceptors
            chain.add(new ServiceInvokerInterceptor());
            chain.add(new OutgoingChainInterceptor());

            // See http://cwiki.apache.org/CXF20DOC/interceptors.html
            // install Holder and Wrapper interceptors
            chain.add(new WrapperClassInInterceptor());
            chain.add(new HolderInInterceptor());

            // install interceptors for handler processing
            chain.add(new MustUnderstandInterceptor());
            chain.add(new LogicalHandlerInInterceptor(binding));
            chain.add(new SOAPHandlerInterceptor(binding));

            // install data binding interceptors
            copyDataBindingInterceptors(chain, inMessage.getInterceptorChain());

            InterceptorChain oldChain = inMessage.getInterceptorChain();
            inMessage.setInterceptorChain(chain);
            try {
                chain.doIntercept(inMessage);
            } finally {
                inMessage.setInterceptorChain(oldChain);
            }

            // TODO: the result should be deserialized from SOAPMessage
View Full Code Here

TOP

Related Classes of org.apache.cxf.phase.PhaseInterceptorChain

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.