Examples of InterceptorChain


Examples of org.apache.cxf.interceptor.InterceptorChain

            }
   
            //Add all interceptors between USER_LOGICAL and INVOKE.
            SortedSet<Phase> phases = new TreeSet<Phase>(bus.getExtension(PhaseManager.class).getInPhases());
            ColocUtil.setPhases(phases, Phase.USER_LOGICAL, Phase.INVOKE);
            InterceptorChain chain = ColocUtil.getInInterceptorChain(ex, phases);
            chain.add(addColocInterceptors());
            inMsg.setInterceptorChain(chain);
   
            chain.doIntercept(inMsg);
   
            //Set Server OutBound Message onto InBound Exchange.
            setOutBoundMessage(ex, m.getExchange());
        } finally {
            BusFactory.setThreadDefaultBus(origBus);
View Full Code Here

Examples of org.apache.cxf.interceptor.InterceptorChain

                    message.getExchange().setOutMessage(responseMsg);
                    SOAPMessage soapMessage = ((SOAPMessageContext)context).getMessage();

                    responseMsg.setContent(SOAPMessage.class, soapMessage);

                    InterceptorChain chain = OutgoingChainInterceptor.getOutInterceptorChain(message
                        .getExchange());
                    responseMsg.setInterceptorChain(chain);
                    // so the idea of starting interceptor chain from any
                    // specified point does not work
                    // well for outbound case, as many outbound interceptors
                    // have their ending interceptors.
                    // For example, we can not skip MessageSenderInterceptor.
                    chain.doInterceptStartingAfter(responseMsg,
                                                   SoapPreProtocolOutInterceptor.class.getName());
                }

            } else {
                // server side outbound - Normal handler message processing
View Full Code Here

Examples of org.apache.cxf.interceptor.InterceptorChain

        // This is to set direction to outbound
        expect(exchange.getOutMessage()).andReturn(message).anyTimes();
        CachedStream originalEmptyOs = new CachedStream();
        message.setContent(OutputStream.class, originalEmptyOs);

        InterceptorChain chain = new PhaseInterceptorChain((new PhaseManagerImpl()).getOutPhases());
        //Interceptors after SOAPHandlerInterceptor DOMXMLStreamWriter to write
        chain.add(new AbstractProtocolHandlerInterceptor<SoapMessage>(binding, Phase.MARSHAL) {

            public void handleMessage(SoapMessage message) throws Fault {
                try {
                    XMLStreamWriter writer = message.getContent(XMLStreamWriter.class);
                    SoapVersion soapVersion = Soap11.getInstance();
                    writer.setPrefix(soapVersion.getPrefix(), soapVersion.getNamespace());
                    writer.writeStartElement(soapVersion.getPrefix(),
                                          soapVersion.getEnvelope().getLocalPart(),
                                          soapVersion.getNamespace());
                    writer.writeNamespace(soapVersion.getPrefix(), soapVersion.getNamespace());
                    writer.writeEndElement();
                   
                    writer.flush();
                } catch (Exception e) {
                    // do nothing
                }
            }

        });
        chain.add(new SOAPHandlerInterceptor(binding));
        message.setInterceptorChain(chain);
        control.replay();

        chain.doIntercept(message);
       
        control.verify();

        // Verify outputStream
        CachedStream expectedOs = prepareOutputStreamFromResource("resources/greetMeRpcLitRespChanged.xml");
View Full Code Here

Examples of org.apache.cxf.interceptor.InterceptorChain

        // This is to set direction to outbound
        expect(exchange.getOutMessage()).andReturn(message).anyTimes();
        CachedStream originalEmptyOs = new CachedStream();
        message.setContent(OutputStream.class, originalEmptyOs);

        InterceptorChain chain = new PhaseInterceptorChain((new PhaseManagerImpl()).getOutPhases());
        //Interceptors after SOAPHandlerInterceptor DOMXMLStreamWriter to write
        chain.add(new AbstractProtocolHandlerInterceptor<SoapMessage>(binding, Phase.MARSHAL) {

            public void handleMessage(SoapMessage message) throws Fault {
                try {
                    XMLStreamWriter writer = message.getContent(XMLStreamWriter.class);
                    SoapVersion soapVersion = Soap11.getInstance();
                    writer.setPrefix(soapVersion.getPrefix(), soapVersion.getNamespace());
                    writer.writeStartElement(soapVersion.getPrefix(),
                                          soapVersion.getEnvelope().getLocalPart(),
                                          soapVersion.getNamespace());
                    writer.writeNamespace(soapVersion.getPrefix(), soapVersion.getNamespace());
                   
                    Object[] headerInfo = prepareSOAPHeader();
                    StaxUtils.writeElement((Element) headerInfo[1], writer, true, false);
                   
                    writer.writeEndElement();
                   
                    writer.flush();
                } catch (Exception e) {
                    // do nothing
                }
            }

        });
        chain.add(new SOAPHandlerInterceptor(binding));
        message.setInterceptorChain(chain);
        control.replay();

        chain.doIntercept(message);
       
        control.verify();

        // Verify SOAPMessage header
        SOAPMessage soapMessageNew = message.getContent(SOAPMessage.class);
View Full Code Here

Examples of org.apache.cxf.interceptor.InterceptorChain

                    message.getExchange().setOutMessage(responseMsg);
                    SOAPMessage soapMessage = ((SOAPMessageContext)context).getMessage();

                    responseMsg.setContent(SOAPMessage.class, soapMessage);

                    InterceptorChain chain = OutgoingChainInterceptor.getOutInterceptorChain(message
                        .getExchange());
                    responseMsg.setInterceptorChain(chain);
                    // so the idea of starting interceptor chain from any
                    // specified point does not work
                    // well for outbound case, as many outbound interceptors
                    // have their ending interceptors.
                    // For example, we can not skip MessageSenderInterceptor.
                    chain.doInterceptStartingAfter(responseMsg,
                                                   SoapPreProtocolOutInterceptor.class.getName());
                }

            } else {
                // server side outbound - Normal handler message processing
View Full Code Here

Examples of org.apache.cxf.interceptor.InterceptorChain

                                                            partialResponse,
                                                            reference);

                if (backChannel != null) {
                    // set up interceptor chains and send message
                    InterceptorChain chain =
                        fullResponse != null
                        ? fullResponse.getInterceptorChain()
                        : OutgoingChainInterceptor.getOutInterceptorChain(exchange);
                    partialResponse.setInterceptorChain(chain);
                    exchange.put(ConduitSelector.class,
                                 new PreexistingConduitSelector(backChannel,
                                                                exchange.get(Endpoint.class)));

                    if (chain != null && !chain.doIntercept(partialResponse)
                        && partialResponse.getContent(Exception.class) != null) {
                        if (partialResponse.getContent(Exception.class) instanceof Fault) {
                            throw (Fault)partialResponse.getContent(Exception.class);
                        } else {
                            throw new Fault(partialResponse.getContent(Exception.class));
                        }
                    }
                    if (chain != null) {
                        chain.reset();                       
                    }
                    exchange.put(ConduitSelector.class, new NullConduitSelector());
                    if (fullResponse != null) {
                        exchange.setOutMessage(fullResponse);
                    } else {
View Full Code Here

Examples of org.apache.cxf.interceptor.InterceptorChain

        // TODO check if the message is one-way message
        // Get the method name from the soap endpoint
        org.apache.cxf.message.Message outMessage = CxfSoapBinding.getCxfOutMessage(
                endpoint.getHeaderFilterStrategy(), exchange, false);
        org.apache.cxf.message.Exchange cxfExchange = outMessage.getExchange();
        InterceptorChain chain = OutgoingChainInterceptor.getOutInterceptorChain(cxfExchange);
        outMessage.setInterceptorChain(chain);
        chain.doIntercept(outMessage);
        CachedOutputStream outputStream = (CachedOutputStream)outMessage.getContent(OutputStream.class);
        exchange.getOut().setBody(outputStream.getInputStream());
    }
View Full Code Here

Examples of org.apache.cxf.interceptor.InterceptorChain

        exchange.setProperty(CxfConstants.CXF_EXCHANGE, cxfExchange);
        org.apache.cxf.message.Message outMessage = CxfSoapBinding.getCxfOutMessage(
                endpoint.getHeaderFilterStrategy(), exchange, true);
        outMessage.put(Message.REQUESTOR_ROLE, Boolean.TRUE);
        outMessage.put(Message.INBOUND_MESSAGE, Boolean.FALSE);
        InterceptorChain chain = OutgoingChainInterceptor.getOutInterceptorChain(cxfExchange);
        outMessage.setInterceptorChain(chain);

        chain.doIntercept(outMessage);
        CachedOutputStream outputStream = (CachedOutputStream)outMessage.getContent(OutputStream.class);
        exchange.getOut().setBody(outputStream.getInputStream());
        exchange.getIn().setBody(outputStream.getInputStream());
    }
View Full Code Here

Examples of org.apache.cxf.interceptor.InterceptorChain

                        exchange.put(BindingOperationInfo.class, boi);
                    }
                   
                   
                    // set up interceptor chains and send message
                    InterceptorChain chain =
                        fullResponse != null
                        ? fullResponse.getInterceptorChain()
                        : OutgoingChainInterceptor.getOutInterceptorChain(exchange);
                    exchange.setOutMessage(partialResponse);
                    partialResponse.setInterceptorChain(chain);
                    exchange.put(ConduitSelector.class,
                                 new PreexistingConduitSelector(backChannel,
                                                                exchange.get(Endpoint.class)));

                    if (chain != null && !chain.doIntercept(partialResponse)
                        && partialResponse.getContent(Exception.class) != null) {
                        if (partialResponse.getContent(Exception.class) instanceof Fault) {
                            throw (Fault)partialResponse.getContent(Exception.class);
                        } else {
                            throw new Fault(partialResponse.getContent(Exception.class));
                        }
                    }
                    if (chain != null) {
                        chain.reset();                       
                    }
                    exchange.put(ConduitSelector.class, new NullConduitSelector());
                   
                    if (fullResponse == null) {
                        fullResponse = ContextUtils.createMessage(exchange);
View Full Code Here

Examples of org.apache.cxf.interceptor.InterceptorChain

    public void onMessage(Message m) {
        Bus origBus = BusFactory.getThreadDefaultBus(false);
        BusFactory.setThreadDefaultBus(bus);
        try {
            InterceptorChain phaseChain = null;
           
            if (m.getInterceptorChain() != null) {
                phaseChain = m.getInterceptorChain();
                synchronized (phaseChain) {
                    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
TOP
Copyright © 2018 www.massapi.com. 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.