Search in sources :

Example 6 with PhaseManager

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;
}
Also used : Bus(org.apache.cxf.Bus) PhaseInterceptorChain(org.apache.cxf.phase.PhaseInterceptorChain) SoapMessage(org.apache.cxf.binding.soap.SoapMessage) Message(org.apache.cxf.message.Message) PhaseManager(org.apache.cxf.phase.PhaseManager) RMCaptureOutInterceptor(org.apache.cxf.ws.rm.RMCaptureOutInterceptor) AbstractOutDatabindingInterceptor(org.apache.cxf.interceptor.AbstractOutDatabindingInterceptor) Interceptor(org.apache.cxf.interceptor.Interceptor) PhaseInterceptor(org.apache.cxf.phase.PhaseInterceptor) SoapOutInterceptor(org.apache.cxf.binding.soap.interceptor.SoapOutInterceptor)

Example 7 with PhaseManager

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));
}
Also used : IMocksControl(org.easymock.IMocksControl) Bus(org.apache.cxf.Bus) ExtensionManagerBus(org.apache.cxf.bus.extension.ExtensionManagerBus) PhaseManager(org.apache.cxf.phase.PhaseManager) HashMap(java.util.HashMap) BindingFactoryManager(org.apache.cxf.binding.BindingFactoryManager) InstrumentationManager(org.apache.cxf.management.InstrumentationManager) ExtensionManagerBus(org.apache.cxf.bus.extension.ExtensionManagerBus) Test(org.junit.Test)

Example 8 with PhaseManager

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);
}
Also used : InterceptorChain(org.apache.cxf.interceptor.InterceptorChain) Phase(org.apache.cxf.phase.Phase) Message(org.apache.cxf.message.Message) PhaseManager(org.apache.cxf.phase.PhaseManager) TreeSet(java.util.TreeSet)

Example 9 with PhaseManager

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();
}
Also used : Binding(org.apache.cxf.binding.Binding) Bus(org.apache.cxf.Bus) PhaseManager(org.apache.cxf.phase.PhaseManager) Endpoint(org.apache.cxf.endpoint.Endpoint) Message(org.apache.cxf.message.Message) ArrayList(java.util.ArrayList) Service(org.apache.cxf.service.Service) PhaseManagerImpl(org.apache.cxf.bus.managers.PhaseManagerImpl) MessageImpl(org.apache.cxf.message.MessageImpl) Test(org.junit.Test)

Example 10 with PhaseManager

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;
}
Also used : PhaseInterceptorChain(org.apache.cxf.phase.PhaseInterceptorChain) PhaseManager(org.apache.cxf.phase.PhaseManager) Message(org.apache.cxf.message.Message) ClientRequestFilterInterceptor(org.apache.cxf.jaxrs.client.spec.ClientRequestFilterInterceptor) StaxInEndingInterceptor(org.apache.cxf.interceptor.StaxInEndingInterceptor) ClientRequestFilterInterceptor(org.apache.cxf.jaxrs.client.spec.ClientRequestFilterInterceptor) AbstractPhaseInterceptor(org.apache.cxf.phase.AbstractPhaseInterceptor) WriterInterceptor(javax.ws.rs.ext.WriterInterceptor) ClientResponseFilterInterceptor(org.apache.cxf.jaxrs.client.spec.ClientResponseFilterInterceptor) AbstractOutDatabindingInterceptor(org.apache.cxf.interceptor.AbstractOutDatabindingInterceptor) Interceptor(org.apache.cxf.interceptor.Interceptor) PhaseChainCache(org.apache.cxf.phase.PhaseChainCache)

Aggregations

PhaseManager (org.apache.cxf.phase.PhaseManager)12 Message (org.apache.cxf.message.Message)10 Bus (org.apache.cxf.Bus)8 Interceptor (org.apache.cxf.interceptor.Interceptor)6 PhaseInterceptorChain (org.apache.cxf.phase.PhaseInterceptorChain)6 Endpoint (org.apache.cxf.endpoint.Endpoint)4 Phase (org.apache.cxf.phase.Phase)4 Binding (org.apache.cxf.binding.Binding)3 PhaseManagerImpl (org.apache.cxf.bus.managers.PhaseManagerImpl)3 AbstractOutDatabindingInterceptor (org.apache.cxf.interceptor.AbstractOutDatabindingInterceptor)3 InterceptorProvider (org.apache.cxf.interceptor.InterceptorProvider)3 AbstractPhaseInterceptor (org.apache.cxf.phase.AbstractPhaseInterceptor)3 Test (org.junit.Test)3 HashMap (java.util.HashMap)2 TreeSet (java.util.TreeSet)2 WriterInterceptor (javax.ws.rs.ext.WriterInterceptor)2 SoapMessage (org.apache.cxf.binding.soap.SoapMessage)2 AbstractBasicInterceptorProvider (org.apache.cxf.interceptor.AbstractBasicInterceptorProvider)2 StaxInEndingInterceptor (org.apache.cxf.interceptor.StaxInEndingInterceptor)2 ClientRequestFilterInterceptor (org.apache.cxf.jaxrs.client.spec.ClientRequestFilterInterceptor)2