use of org.apache.cxf.phase.Phase 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<>(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.Phase in project cxf by apache.
the class ColocInInterceptor method handleMessage.
public void handleMessage(Message msg) throws Fault {
Exchange ex = msg.getExchange();
if (ex.isOneWay()) {
return;
}
Bus bus = ex.getBus();
SortedSet<Phase> phases = new TreeSet<>(bus.getExtension(PhaseManager.class).getOutPhases());
// TODO Set Coloc FaultObserver chain
ColocUtil.setPhases(phases, Phase.SETUP, Phase.USER_LOGICAL);
InterceptorChain chain = ColocUtil.getOutInterceptorChain(ex, phases);
if (LOG.isLoggable(Level.FINER)) {
LOG.finer("Processing Message at collocated endpoint. Response message: " + msg);
}
// Initiate OutBound Processing
BindingOperationInfo boi = ex.getBindingOperationInfo();
Message outBound = ex.getOutMessage();
if (boi != null) {
outBound.put(MessageInfo.class, boi.getOperationInfo().getOutput());
}
outBound.put(Message.INBOUND_MESSAGE, Boolean.FALSE);
outBound.setInterceptorChain(chain);
chain.doIntercept(outBound);
}
use of org.apache.cxf.phase.Phase in project cxf by apache.
the class ColocUtil method setPhases.
public static void setPhases(SortedSet<Phase> list, String start, String end) {
Phase startPhase = new Phase(start, 1);
Phase endPhase = new Phase(end, 2);
Iterator<Phase> iter = list.iterator();
boolean remove = true;
while (iter.hasNext()) {
Phase p = iter.next();
if (remove && p.getName().equals(startPhase.getName())) {
remove = false;
} else if (p.getName().equals(endPhase.getName())) {
remove = true;
} else if (remove) {
iter.remove();
}
}
}
use of org.apache.cxf.phase.Phase in project cxf by apache.
the class ColocUtilTest method testSetColocInPhases.
@Test
public void testSetColocInPhases() throws Exception {
PhaseManagerImpl phaseMgr = new PhaseManagerImpl();
SortedSet<Phase> list = phaseMgr.getInPhases();
int size1 = list.size();
ColocUtil.setPhases(list, Phase.USER_LOGICAL, Phase.INVOKE);
assertNotSame("The list size should not be same", size1, list.size());
assertEquals("Expecting Phase.USER_LOGICAL", list.first().getName(), Phase.USER_LOGICAL);
assertEquals("Expecting Phase.POST_INVOKE", list.last().getName(), Phase.INVOKE);
}
use of org.apache.cxf.phase.Phase in project cxf by apache.
the class WSS4JInOutTest method testOrder.
@Test
public void testOrder() throws Exception {
// make sure the interceptors get ordered correctly
SortedSet<Phase> phases = new TreeSet<>();
phases.add(new Phase(Phase.PRE_PROTOCOL, 1));
List<Interceptor<? extends Message>> lst = new ArrayList<>();
lst.add(new MustUnderstandInterceptor());
lst.add(new WSS4JInInterceptor());
lst.add(new SAAJInInterceptor());
PhaseInterceptorChain chain = new PhaseInterceptorChain(phases);
chain.add(lst);
String output = chain.toString();
assertTrue(output.contains("MustUnderstandInterceptor, SAAJInInterceptor, WSS4JInInterceptor"));
}
Aggregations