Search in sources :

Example 6 with InterceptorProvider

use of org.apache.cxf.interceptor.InterceptorProvider in project cxf by apache.

the class ClientImpl method setupInterceptorChain.

protected PhaseInterceptorChain setupInterceptorChain(Endpoint endpoint) {
    PhaseManager pm = bus.getExtension(PhaseManager.class);
    List<Interceptor<? extends Message>> i1 = bus.getOutInterceptors();
    if (LOG.isLoggable(Level.FINE)) {
        LOG.fine("Interceptors contributed by bus: " + i1);
    }
    List<Interceptor<? extends Message>> i2 = getOutInterceptors();
    if (LOG.isLoggable(Level.FINE)) {
        LOG.fine("Interceptors contributed by client: " + i2);
    }
    List<Interceptor<? extends Message>> i3 = endpoint.getOutInterceptors();
    if (LOG.isLoggable(Level.FINE)) {
        LOG.fine("Interceptors contributed by endpoint: " + i3);
    }
    List<Interceptor<? extends Message>> i4 = endpoint.getBinding().getOutInterceptors();
    if (LOG.isLoggable(Level.FINE)) {
        LOG.fine("Interceptors contributed by binding: " + i4);
    }
    List<Interceptor<? extends Message>> i5 = null;
    if (endpoint.getService().getDataBinding() instanceof InterceptorProvider) {
        i5 = ((InterceptorProvider) endpoint.getService().getDataBinding()).getOutInterceptors();
        if (LOG.isLoggable(Level.FINE)) {
            LOG.fine("Interceptors contributed by databinding: " + i5);
        }
    }
    if (i5 != null) {
        return outboundChainCache.get(pm.getOutPhases(), i1, i2, i3, i4, i5);
    }
    return outboundChainCache.get(pm.getOutPhases(), i1, i2, i3, i4);
}
Also used : PhaseManager(org.apache.cxf.phase.PhaseManager) Message(org.apache.cxf.message.Message) InterceptorProvider(org.apache.cxf.interceptor.InterceptorProvider) AbstractBasicInterceptorProvider(org.apache.cxf.interceptor.AbstractBasicInterceptorProvider) Interceptor(org.apache.cxf.interceptor.Interceptor)

Example 7 with InterceptorProvider

use of org.apache.cxf.interceptor.InterceptorProvider in project cxf by apache.

the class ClientImpl method modifyChain.

protected void modifyChain(InterceptorChain chain, Message ctx, boolean in) {
    if (ctx == null) {
        return;
    }
    Collection<InterceptorProvider> providers = CastUtils.cast((Collection<?>) ctx.get(Message.INTERCEPTOR_PROVIDERS));
    if (providers != null) {
        for (InterceptorProvider p : providers) {
            if (in) {
                chain.add(p.getInInterceptors());
            } else {
                chain.add(p.getOutInterceptors());
            }
        }
    }
    String key = in ? Message.IN_INTERCEPTORS : Message.OUT_INTERCEPTORS;
    Collection<Interceptor<? extends Message>> is = CastUtils.cast((Collection<?>) ctx.get(key));
    if (is != null) {
        chain.add(is);
    }
}
Also used : Message(org.apache.cxf.message.Message) InterceptorProvider(org.apache.cxf.interceptor.InterceptorProvider) AbstractBasicInterceptorProvider(org.apache.cxf.interceptor.AbstractBasicInterceptorProvider) Interceptor(org.apache.cxf.interceptor.Interceptor)

Example 8 with InterceptorProvider

use of org.apache.cxf.interceptor.InterceptorProvider in project cxf by apache.

the class ProxyTest method testRMClientConstruction.

@Test
public void testRMClientConstruction() {
    Proxy proxy = new Proxy(rme);
    Bus bus = control.createMock(Bus.class);
    EasyMock.expect(bus.getExtension(WSAddressingFeatureApplier.class)).andReturn(new WSAddressingFeatureApplier() {

        @Override
        public void initializeProvider(WSAddressingFeature feature, InterceptorProvider provider, Bus bus) {
        }
    }).anyTimes();
    Endpoint endpoint = control.createMock(Endpoint.class);
    Conduit conduit = control.createMock(Conduit.class);
    org.apache.cxf.ws.addressing.EndpointReferenceType address = control.createMock(org.apache.cxf.ws.addressing.EndpointReferenceType.class);
    control.replay();
    assertNotNull(proxy.createClient(bus, endpoint, ProtocolVariation.RM10WSA200408, conduit, address));
}
Also used : Bus(org.apache.cxf.Bus) WSAddressingFeature(org.apache.cxf.ws.addressing.WSAddressingFeature) Endpoint(org.apache.cxf.endpoint.Endpoint) EndpointReferenceType(org.apache.cxf.ws.addressing.EndpointReferenceType) WSAddressingFeatureApplier(org.apache.cxf.ws.addressing.WSAddressingFeature.WSAddressingFeatureApplier) Conduit(org.apache.cxf.transport.Conduit) InterceptorProvider(org.apache.cxf.interceptor.InterceptorProvider) Test(org.junit.Test)

Example 9 with InterceptorProvider

use of org.apache.cxf.interceptor.InterceptorProvider in project cxf by apache.

the class ChainInitiationObserver method onMessage.

public void onMessage(Message m) {
    Bus origBus = BusFactory.getAndSetThreadDefaultBus(bus);
    ClassLoaderHolder origLoader = null;
    try {
        if (loader != null) {
            origLoader = ClassLoaderUtils.setThreadContextClassloader(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 {
        if (origBus != bus) {
            BusFactory.setThreadDefaultBus(origBus);
        }
        if (origLoader != null) {
            origLoader.reset();
        }
    }
}
Also used : Exchange(org.apache.cxf.message.Exchange) Bus(org.apache.cxf.Bus) InterceptorChain(org.apache.cxf.interceptor.InterceptorChain) Message(org.apache.cxf.message.Message) PhaseManager(org.apache.cxf.phase.PhaseManager) ClassLoaderHolder(org.apache.cxf.common.classloader.ClassLoaderUtils.ClassLoaderHolder) InterceptorProvider(org.apache.cxf.interceptor.InterceptorProvider) ExchangeImpl(org.apache.cxf.message.ExchangeImpl)

Example 10 with InterceptorProvider

use of org.apache.cxf.interceptor.InterceptorProvider in project cxf by apache.

the class ChainInitiationObserver method addToChain.

private void addToChain(InterceptorChain chain, Message m) {
    Collection<InterceptorProvider> providers = CastUtils.cast((Collection<?>) m.get(Message.INTERCEPTOR_PROVIDERS));
    if (providers != null) {
        for (InterceptorProvider p : providers) {
            chain.add(p.getInInterceptors());
        }
    }
    Collection<Interceptor<? extends Message>> is = CastUtils.cast((Collection<?>) m.get(Message.IN_INTERCEPTORS));
    if (is != null) {
        chain.add(is);
    }
    if (m.getDestination() instanceof InterceptorProvider) {
        chain.add(((InterceptorProvider) m.getDestination()).getInInterceptors());
    }
}
Also used : Message(org.apache.cxf.message.Message) InterceptorProvider(org.apache.cxf.interceptor.InterceptorProvider) Interceptor(org.apache.cxf.interceptor.Interceptor)

Aggregations

InterceptorProvider (org.apache.cxf.interceptor.InterceptorProvider)10 Message (org.apache.cxf.message.Message)9 Interceptor (org.apache.cxf.interceptor.Interceptor)8 Bus (org.apache.cxf.Bus)6 Endpoint (org.apache.cxf.endpoint.Endpoint)4 PhaseInterceptorChain (org.apache.cxf.phase.PhaseInterceptorChain)4 PhaseManager (org.apache.cxf.phase.PhaseManager)4 AbstractBasicInterceptorProvider (org.apache.cxf.interceptor.AbstractBasicInterceptorProvider)3 Exchange (org.apache.cxf.message.Exchange)2 IOException (java.io.IOException)1 URISyntaxException (java.net.URISyntaxException)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 TreeSet (java.util.TreeSet)1 WeakHashMap (java.util.WeakHashMap)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 SoapMessage (org.apache.cxf.binding.soap.SoapMessage)1 ClassLoaderHolder (org.apache.cxf.common.classloader.ClassLoaderUtils.ClassLoaderHolder)1 UncheckedException (org.apache.cxf.common.i18n.UncheckedException)1 InterceptorChain (org.apache.cxf.interceptor.InterceptorChain)1