use of org.apache.cxf.phase.PhaseManager in project cxf by apache.
the class RetransmissionQueueImpl method buildRetransmitChain.
/**
* @param endpoint
* @param cache
* @return
*/
protected PhaseInterceptorChain buildRetransmitChain(final Endpoint endpoint, PhaseChainCache cache) {
PhaseInterceptorChain retransmitChain;
Bus bus = getManager().getBus();
List<Interceptor<? extends Message>> i1 = bus.getOutInterceptors();
if (LOG.isLoggable(Level.FINE)) {
LOG.fine("Interceptors contributed by bus: " + i1);
}
List<Interceptor<? extends Message>> i2 = endpoint.getOutInterceptors();
if (LOG.isLoggable(Level.FINE)) {
LOG.fine("Interceptors contributed by endpoint: " + i2);
}
List<Interceptor<? extends Message>> i3 = endpoint.getBinding().getOutInterceptors();
if (LOG.isLoggable(Level.FINE)) {
LOG.fine("Interceptors contributed by binding: " + i3);
}
PhaseManager pm = bus.getExtension(PhaseManager.class);
retransmitChain = cache.get(pm.getOutPhases(), i1, i2, i3);
return retransmitChain;
}
use of org.apache.cxf.phase.PhaseManager in project cxf by apache.
the class CXFBusImplTest method testConstructionWithExtensions.
@Test
public void testConstructionWithExtensions() throws BusException {
IMocksControl control;
BindingFactoryManager bindingFactoryManager;
InstrumentationManager instrumentationManager;
PhaseManager phaseManager;
control = EasyMock.createNiceControl();
Map<Class<?>, Object> extensions = new HashMap<>();
bindingFactoryManager = control.createMock(BindingFactoryManager.class);
instrumentationManager = control.createMock(InstrumentationManager.class);
phaseManager = control.createMock(PhaseManager.class);
extensions.put(BindingFactoryManager.class, bindingFactoryManager);
extensions.put(InstrumentationManager.class, instrumentationManager);
extensions.put(PhaseManager.class, phaseManager);
Bus bus = new ExtensionManagerBus(extensions);
assertSame(bindingFactoryManager, bus.getExtension(BindingFactoryManager.class));
assertSame(instrumentationManager, bus.getExtension(InstrumentationManager.class));
assertSame(phaseManager, bus.getExtension(PhaseManager.class));
}
use of org.apache.cxf.phase.PhaseManager in project cxf by apache.
the class ColocOutInterceptor method invokeInboundChain.
protected void invokeInboundChain(Exchange ex, Endpoint ep) {
Message m = getInBoundMessage(ex);
Message inMsg = ep.getBinding().createMessage();
MessageImpl.copyContent(m, inMsg);
// Copy Response Context to Client inBound Message
// TODO a Context Filter Strategy required.
inMsg.putAll(m);
inMsg.put(Message.REQUESTOR_ROLE, Boolean.TRUE);
inMsg.put(Message.INBOUND_MESSAGE, Boolean.TRUE);
inMsg.setExchange(ex);
Exception exc = inMsg.getContent(Exception.class);
if (exc != null) {
ex.setInFaultMessage(inMsg);
ColocInFaultObserver observer = new ColocInFaultObserver(bus);
observer.onMessage(inMsg);
} else {
// Handle Response
ex.setInMessage(inMsg);
PhaseManager pm = bus.getExtension(PhaseManager.class);
SortedSet<Phase> phases = new TreeSet<Phase>(pm.getInPhases());
ColocUtil.setPhases(phases, Phase.USER_LOGICAL, Phase.PRE_INVOKE);
InterceptorChain chain = ColocUtil.getInInterceptorChain(ex, phases);
inMsg.setInterceptorChain(chain);
chain.doIntercept(inMsg);
}
ex.put(ClientImpl.FINISHED, Boolean.TRUE);
}
use of org.apache.cxf.phase.PhaseManager in project cxf by apache.
the class ColocOutInterceptorTest method testInvokeInboundChain.
@Test
public void testInvokeInboundChain() {
// Reset Exchange on msg
msg.setExchange(null);
Bus bus = setupBus();
colocOut.setBus(bus);
PhaseManager pm = new PhaseManagerImpl();
EasyMock.expect(bus.getExtension(PhaseManager.class)).andReturn(pm).times(2);
Endpoint ep = control.createMock(Endpoint.class);
Binding bd = control.createMock(Binding.class);
Service srv = control.createMock(Service.class);
ex.setInMessage(msg);
ex.put(Bus.class, bus);
ex.put(Endpoint.class, ep);
ex.put(Service.class, srv);
EasyMock.expect(ep.getBinding()).andReturn(bd);
EasyMock.expect(bd.createMessage()).andReturn(new MessageImpl());
EasyMock.expect(ep.getInInterceptors()).andReturn(new ArrayList<Interceptor<? extends Message>>()).atLeastOnce();
EasyMock.expect(ep.getService()).andReturn(srv).atLeastOnce();
EasyMock.expect(srv.getInInterceptors()).andReturn(new ArrayList<Interceptor<? extends Message>>()).atLeastOnce();
EasyMock.expect(bus.getInInterceptors()).andReturn(new ArrayList<Interceptor<? extends Message>>()).atLeastOnce();
control.replay();
colocOut.invokeInboundChain(ex, ep);
Message inMsg = ex.getInMessage();
assertNotSame(msg, inMsg);
assertEquals("Requestor role should be set to true.", Boolean.TRUE, inMsg.get(Message.REQUESTOR_ROLE));
assertEquals("Inbound Message should be set to true.", Boolean.TRUE, inMsg.get(Message.INBOUND_MESSAGE));
assertNotNull("Inbound Message should have interceptor chain set.", inMsg.getInterceptorChain());
assertEquals("Client Invoke state should be FINISHED", Boolean.TRUE, ex.get(ClientImpl.FINISHED));
control.verify();
}
use of org.apache.cxf.phase.PhaseManager in project cxf by apache.
the class AbstractClient method setupOutInterceptorChain.
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;
}
Aggregations