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);
}
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);
}
}
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));
}
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();
}
}
}
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());
}
}
Aggregations