Java Code Examples for org.apache.cxf.phase.PhaseManager#getInPhases()

The following examples show how to use org.apache.cxf.phase.PhaseManager#getInPhases() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RedeliveryQueueImpl.java    From cxf with Apache License 2.0 5 votes vote down vote up
private static InterceptorChain getRedeliveryInterceptorChain(Message m, String phase) {
    Exchange exchange = m.getExchange();
    Endpoint ep = exchange.getEndpoint();
    Bus bus = exchange.getBus();

    PhaseManager pm = bus.getExtension(PhaseManager.class);
    SortedSet<Phase> phases = new TreeSet<>(pm.getInPhases());
    for (Iterator<Phase> it = phases.iterator(); it.hasNext();) {
        Phase p = it.next();
        if (phase.equals(p.getName())) {
            break;
        }
        it.remove();
    }
    PhaseInterceptorChain chain = new PhaseInterceptorChain(phases);
    List<Interceptor<? extends Message>> il = ep.getInInterceptors();
    addInterceptors(chain, il);
    il = ep.getService().getInInterceptors();
    addInterceptors(chain, il);
    il = ep.getBinding().getInInterceptors();
    addInterceptors(chain, il);
    il = bus.getInInterceptors();
    addInterceptors(chain, il);
    if (ep.getService().getDataBinding() instanceof InterceptorProvider) {
        il = ((InterceptorProvider)ep.getService().getDataBinding()).getInInterceptors();
        addInterceptors(chain, il);
    }

    return chain;
}
 
Example 2
Source File: ColocOutInterceptor.java    From cxf with Apache License 2.0 5 votes vote down vote up
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<>(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);
}
 
Example 3
Source File: SpringBusFactoryTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testPhases() {
    Bus bus = new SpringBusFactory().createBus();
    PhaseManager cxfPM = bus.getExtension(PhaseManager.class);
    PhaseManager defaultPM = new PhaseManagerImpl();
    SortedSet<Phase> cxfPhases = cxfPM.getInPhases();
    SortedSet<Phase> defaultPhases = defaultPM.getInPhases();
    assertEquals(defaultPhases.size(), cxfPhases.size());
    assertEquals(cxfPhases, defaultPhases);
    cxfPhases = cxfPM.getOutPhases();
    defaultPhases = defaultPM.getOutPhases();
    assertEquals(defaultPhases.size(), cxfPhases.size());
    assertEquals(cxfPhases, defaultPhases);
}