Package org.apache.cxf.interceptor

Examples of org.apache.cxf.interceptor.InterceptorChain


        EndpointPolicy endpointPolicy = control.createMock(EndpointPolicyImpl.class);
        EasyMock.expect(pe.getServerEndpointPolicy(ei, destination)).andReturn(endpointPolicy);
        List<Interceptor<? extends Message>> li = createMockInterceptorList();
        EasyMock.expect(endpointPolicy.getInterceptors())
            .andReturn(li);
        InterceptorChain ic = control.createMock(InterceptorChain.class);
        EasyMock.expect(message.getInterceptorChain()).andReturn(ic);
        ic.add(li.get(0));
        EasyMock.expectLastCall();
        Collection<Assertion> assertions =
            CastUtils.cast(Collections.EMPTY_LIST, Assertion.class);
        EasyMock.expect(endpointPolicy.getVocabulary()).andReturn(assertions);
        control.replay();
View Full Code Here


        EasyMock.expect(pe.getEffectiveServerResponsePolicy(ei, boi, destination))
            .andReturn(effectivePolicy);
        List<Interceptor<? extends Message>> li = createMockInterceptorList();
        EasyMock.expect(effectivePolicy.getInterceptors())
            .andReturn(li);
        InterceptorChain ic = control.createMock(InterceptorChain.class);
        EasyMock.expect(message.getInterceptorChain()).andReturn(ic);
        ic.add(li.get(0));
        EasyMock.expectLastCall();
        Collection<Assertion> assertions =
            CastUtils.cast(Collections.EMPTY_LIST, Assertion.class);
        EasyMock.expect(effectivePolicy.getChosenAlternative()).andReturn(assertions);
        control.replay();
View Full Code Here

        EasyMock.expect(pe.getEffectiveServerFaultPolicy(ei, boi, bfi, destination))
            .andReturn(effectivePolicy);
        List<Interceptor<? extends Message>> li = createMockInterceptorList();
        EasyMock.expect(effectivePolicy.getInterceptors())
            .andReturn(li);
        InterceptorChain ic = control.createMock(InterceptorChain.class);
        EasyMock.expect(message.getInterceptorChain()).andReturn(ic);
        ic.add(li.get(0));
        EasyMock.expectLastCall();
        Collection<Assertion> assertions =
            CastUtils.cast(Collections.EMPTY_LIST, Assertion.class);
        EasyMock.expect(effectivePolicy.getChosenAlternative()).andReturn(assertions);
        control.replay();
View Full Code Here

        ClassLoader origLoader = Thread.currentThread().getContextClassLoader();
        try {
            if (loader != null) {
                Thread.currentThread().setContextClassLoader(loader);
            }
            InterceptorChain phaseChain = null;
           
            if (m.getInterceptorChain() != null) {
                phaseChain = m.getInterceptorChain();
                // To make sure the phase chain is run by one thread once
                synchronized (phaseChain) {
                    if (phaseChain.getState() == InterceptorChain.State.PAUSED
                        || phaseChain.getState() == InterceptorChain.State.SUSPENDED) {
                        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);
            Thread.currentThread().setContextClassLoader(origLoader);
        }
View Full Code Here

        EasyMock.expect(message.get(JAXWSAConstants.ADDRESSING_PROPERTIES_OUTBOUND))
            .andReturn(maps).anyTimes();
        RMProperties rmpsOut = new RMProperties();
        EasyMock.expect(message.get(RMMessageConstants.RM_PROPERTIES_OUTBOUND)).
            andReturn(rmpsOut).anyTimes();
        InterceptorChain chain = control.createMock(InterceptorChain.class);
        EasyMock.expect(message.getInterceptorChain()).andReturn(chain).anyTimes();
        EasyMock.expect(manager.getRMNamespace(EasyMock.same(message)))
            .andReturn(RM10Constants.NAMESPACE_URI);
        EasyMock.expect(manager.getAddressingNamespace(EasyMock.same(message)))
            .andReturn(Names200408.WSA_NAMESPACE_NAME);
        chain.add(EasyMock.isA(RetransmissionInterceptor.class));
        EasyMock.expectLastCall();
        RetransmissionQueue queue = control.createMock(RetransmissionQueue.class);
        EasyMock.expect(manager.getRetransmissionQueue()).andReturn(queue).anyTimes();
        queue.start();
        EasyMock.expectLastCall();
View Full Code Here

            if (0 != (appMessageCount % 2)) {
                return;
            }
        }
       
        InterceptorChain chain = message.getInterceptorChain();
        ListIterator<Interceptor<? extends Message>> it = chain.getIterator();
        while (it.hasNext()) {
            PhaseInterceptor<?> pi = (PhaseInterceptor)it.next();
            if (MessageSenderInterceptor.class.getName().equals(pi.getId())) {
                chain.remove(pi);
                LOG.fine("Removed MessageSenderInterceptor from interceptor chain.");
                break;
            }
        }
       
View Full Code Here

                                                            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

                                                            ? ContextUtils.getNoneEndpointReference()
                                                            : 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) {
                        fullResponse = createMessage(exchange);
View Full Code Here

        expect(binding1.getHandlerChain()).andReturn(hList).anyTimes();
        Exchange exchange1 = control1.createMock(Exchange.class);
        expect(exchange1.get(HandlerChainInvoker.class)).andReturn(invoker1).anyTimes();
        Message outMessage = new MessageImpl();
        outMessage.setExchange(exchange1);
        InterceptorChain chain = control1.createMock(InterceptorChain.class);
        outMessage.setInterceptorChain(chain);
        chain.abort();
        EasyMock.expectLastCall();
        MessageObserver observer = control1.createMock(MessageObserver.class);
        expect(exchange1.get(MessageObserver.class)).andReturn(observer).anyTimes();
        observer.onMessage(isA(Message.class));
        EasyMock.expectLastCall();
View Full Code Here

        CachedStream originalEmptyOs = new CachedStream();
       
        XMLStreamWriter writer = StaxUtils.createXMLStreamWriter(originalEmptyOs);
        message.setContent(XMLStreamWriter.class, writer);

        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("soap", soapVersion.getNamespace());
                    writer.writeStartElement("soap",
                                          soapVersion.getEnvelope().getLocalPart(),
                                          soapVersion.getNamespace());
                    writer.writeNamespace("soap", 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();

        writer.flush();
       
View Full Code Here

TOP

Related Classes of org.apache.cxf.interceptor.InterceptorChain

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.