org.apache.cxf.interceptor.InterceptorChain Java Examples
The following examples show how to use
org.apache.cxf.interceptor.InterceptorChain.
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: AbstractEndpointSelectionInterceptor.java From cxf with Apache License 2.0 | 6 votes |
public void handleMessage(Message message) { Exchange ex = message.getExchange(); Set<Endpoint> endpoints = CastUtils.cast((Set<?>)ex.get(MultipleEndpointObserver.ENDPOINTS)); Endpoint ep = selectEndpoint(message, endpoints); if (ep == null) { return; } ex.put(Endpoint.class, ep); ex.put(Binding.class, ep.getBinding()); ex.put(Service.class, ep.getService()); InterceptorChain chain = message.getInterceptorChain(); chain.add(ep.getInInterceptors()); chain.add(ep.getBinding().getInInterceptors()); chain.add(ep.getService().getInInterceptors()); chain.setFaultObserver(ep.getOutFaultObserver()); }
Example #2
Source File: ClientImpl.java From cxf with Apache License 2.0 | 6 votes |
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); } }
Example #3
Source File: PhaseInterceptorChainTest.java From cxf with Apache License 2.0 | 6 votes |
@Test public void testState() throws Exception { AbstractPhaseInterceptor<? extends Message> p = setUpPhaseInterceptor("phase1", "p1"); control.replay(); chain.add(p); assertSame("Initial state is State.EXECUTING", InterceptorChain.State.EXECUTING, chain.getState()); chain.pause(); assertSame("Pausing chain should lead to State.PAUSED", InterceptorChain.State.PAUSED, chain.getState()); chain.resume(); assertSame("Resuming chain should lead to State.COMPLETE", InterceptorChain.State.COMPLETE, chain.getState()); chain.abort(); assertSame("Aborting chain should lead to State.ABORTED", InterceptorChain.State.ABORTED, chain.getState()); }
Example #4
Source File: DestinationTest.java From cxf with Apache License 2.0 | 6 votes |
@Test public void testAcknowledgeAlreadyAcknowledgedMessage() throws SequenceFault, RMException, NoSuchMethodException, IOException { Method m1 = Destination.class.getDeclaredMethod("getSequence", new Class[] {Identifier.class}); destination = EasyMock.createMockBuilder(Destination.class) .addMockedMethod(m1).createMock(control); Message message = setupMessage(); RMProperties rmps = control.createMock(RMProperties.class); EasyMock.expect(message.get(RMMessageConstants.RM_PROPERTIES_INBOUND)).andReturn(rmps); SequenceType st = control.createMock(SequenceType.class); EasyMock.expect(rmps.getSequence()).andReturn(st); Identifier id = control.createMock(Identifier.class); EasyMock.expect(st.getIdentifier()).andReturn(id); DestinationSequence ds = control.createMock(DestinationSequence.class); EasyMock.expect(destination.getSequence(id)).andReturn(ds); long nr = 10; EasyMock.expect(st.getMessageNumber()).andReturn(nr); ds.applyDeliveryAssurance(nr, message); EasyMock.expectLastCall().andReturn(false); InterceptorChain ic = control.createMock(InterceptorChain.class); EasyMock.expect(message.getInterceptorChain()).andReturn(ic); control.replay(); destination.acknowledge(message); }
Example #5
Source File: ChainInitiationObserver.java From cxf with Apache License 2.0 | 6 votes |
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()); } }
Example #6
Source File: PhaseInterceptorChainTest.java From cxf with Apache License 2.0 | 6 votes |
@Test public void testSuspendedException() throws Exception { CountingPhaseInterceptor p1 = new CountingPhaseInterceptor("phase1", "p1"); SuspendedInvocationInterceptor p2 = new SuspendedInvocationInterceptor("phase2", "p2"); message.getInterceptorChain(); EasyMock.expectLastCall().andReturn(chain).anyTimes(); control.replay(); chain.add(p1); chain.add(p2); try { chain.doIntercept(message); fail("Suspended invocation swallowed"); } catch (SuspendedInvocationException ex) { // ignore } assertSame("No previous interceptor selected", p1, chain.iterator().next()); assertSame("Suspended invocation should lead to State.PAUSED", InterceptorChain.State.PAUSED, chain.getState()); }
Example #7
Source File: PolicyInterceptorsTest.java From cxf with Apache License 2.0 | 6 votes |
@Test public void testServerPolicyOutInterceptor() { PolicyOutInterceptor interceptor = new PolicyOutInterceptor(); doTestBasics(interceptor, false, true); control.reset(); setupMessage(false, false, true, true, true, true); EffectivePolicy effectivePolicy = control.createMock(EffectivePolicy.class); EasyMock.expect(pe.getEffectiveServerResponsePolicy(ei, boi, destination, null, message)) .andReturn(effectivePolicy); List<Interceptor<? extends Message>> li = createMockInterceptorList(); EasyMock.expect(effectivePolicy.getInterceptors()) .andReturn(li); InterceptorChain ic = control.createMock(InterceptorChain.class); EasyMock.expect(message.getInterceptorChain()).andReturn(ic); ic.add(li.get(0)); EasyMock.expectLastCall(); Collection<Assertion> assertions = CastUtils.cast(Collections.EMPTY_LIST, Assertion.class); EasyMock.expect(effectivePolicy.getChosenAlternative()).andReturn(assertions); control.replay(); interceptor.handleMessage(message); control.verify(); }
Example #8
Source File: PolicyInterceptorsTest.java From cxf with Apache License 2.0 | 6 votes |
@Test public void testServerPolicyInInterceptor() { PolicyInInterceptor interceptor = new PolicyInInterceptor(); doTestBasics(interceptor, false, false); control.reset(); setupMessage(false, false, false, false, true, true); EndpointPolicy endpointPolicy = control.createMock(EndpointPolicyImpl.class); EasyMock.expect(pe.getServerEndpointPolicy(ei, destination, message)).andReturn(endpointPolicy); List<Interceptor<? extends Message>> li = createMockInterceptorList(); EasyMock.expect(endpointPolicy.getInterceptors(message)) .andReturn(li); InterceptorChain ic = control.createMock(InterceptorChain.class); EasyMock.expect(message.getInterceptorChain()).andReturn(ic); ic.add(li.get(0)); EasyMock.expectLastCall(); Collection<Assertion> assertions = CastUtils.cast(Collections.EMPTY_LIST, Assertion.class); EasyMock.expect(endpointPolicy.getVocabulary(message)).andReturn(assertions); control.replay(); interceptor.handleMessage(message); control.verify(); }
Example #9
Source File: PolicyInterceptorsTest.java From cxf with Apache License 2.0 | 6 votes |
@Test public void testClientPolicyInFaultInterceptor() { ClientPolicyInFaultInterceptor interceptor = new ClientPolicyInFaultInterceptor(); doTestBasics(interceptor, true, false); control.reset(); setupMessage(true, true, false, false, true, true); EndpointPolicy endpointPolicy = control.createMock(EndpointPolicy.class); EasyMock.expect(pe.getClientEndpointPolicy(ei, conduit, message)).andReturn(endpointPolicy); List<Interceptor<? extends Message>> li = createMockInterceptorList(); EasyMock.expect(endpointPolicy.getFaultInterceptors(message)) .andReturn(li); InterceptorChain ic = control.createMock(InterceptorChain.class); EasyMock.expect(message.getInterceptorChain()).andReturn(ic); ic.add(li.get(0)); EasyMock.expectLastCall(); Collection<Assertion> assertions = CastUtils.cast(Collections.EMPTY_LIST, Assertion.class); EasyMock.expect(endpointPolicy.getFaultVocabulary(message)).andReturn(assertions); control.replay(); interceptor.handleMessage(message); control.verify(); }
Example #10
Source File: PolicyInterceptorsTest.java From cxf with Apache License 2.0 | 6 votes |
@Test public void testClientPolicyInInterceptor() { PolicyInInterceptor interceptor = new PolicyInInterceptor(); doTestBasics(interceptor, true, false); control.reset(); setupMessage(true, true, true, true, true, true); EffectivePolicy effectivePolicy = control.createMock(EffectivePolicy.class); EasyMock.expect(pe.getEffectiveClientResponsePolicy(ei, boi, message)).andReturn(effectivePolicy); EasyMock.expect(effectivePolicy.getPolicy()).andReturn(new Policy()).times(2); Interceptor<? extends Message> i = control.createMock(Interceptor.class); List<Interceptor<? extends Message>> lst = new ArrayList<>(); lst.add(i); EasyMock.expect(effectivePolicy.getInterceptors()).andReturn(lst); InterceptorChain ic = control.createMock(InterceptorChain.class); EasyMock.expect(message.getInterceptorChain()).andReturn(ic).anyTimes(); ic.add(i); EasyMock.expectLastCall(); message.put(EasyMock.eq(AssertionInfoMap.class), EasyMock.isA(AssertionInfoMap.class)); EasyMock.expectLastCall(); ic.add(PolicyVerificationInInterceptor.INSTANCE); control.replay(); interceptor.handleMessage(message); control.verify(); }
Example #11
Source File: PolicyInterceptorsTest.java From cxf with Apache License 2.0 | 6 votes |
@Test public void testClientPolicyOutInterceptor() { PolicyOutInterceptor interceptor = new PolicyOutInterceptor(); doTestBasics(interceptor, true, true); control.reset(); setupMessage(true, true, true, true, true, true); EffectivePolicy effectivePolicy = control.createMock(EffectivePolicy.class); EasyMock.expect(pe.getEffectiveClientRequestPolicy(ei, boi, conduit, message)) .andReturn(effectivePolicy); List<Interceptor<? extends Message>> li = createMockInterceptorList(); EasyMock.expect(effectivePolicy.getInterceptors()) .andReturn(li); InterceptorChain ic = control.createMock(InterceptorChain.class); EasyMock.expect(message.getInterceptorChain()).andReturn(ic); ic.add(li.get(0)); EasyMock.expectLastCall(); Collection<Assertion> assertions = CastUtils.cast(Collections.EMPTY_LIST, Assertion.class); EasyMock.expect(effectivePolicy.getChosenAlternative()).andReturn(assertions); control.replay(); interceptor.handleMessage(message); control.verify(); }
Example #12
Source File: LogicalHandlerInInterceptor.java From cxf with Apache License 2.0 | 6 votes |
private void handleAbort(Message message, W3CDOMStreamWriter writer) { message.getInterceptorChain().abort(); if (!message.getExchange().isOneWay()) { //server side inbound Endpoint e = message.getExchange().getEndpoint(); Message responseMsg = new MessageImpl(); responseMsg.setExchange(message.getExchange()); responseMsg = e.getBinding().createMessage(responseMsg); message.getExchange().setOutMessage(responseMsg); XMLStreamReader reader = message.getContent(XMLStreamReader.class); if (reader == null && writer != null) { reader = StaxUtils.createXMLStreamReader(writer.getDocument()); } InterceptorChain chain = OutgoingChainInterceptor .getOutInterceptorChain(message.getExchange()); responseMsg.setInterceptorChain(chain); responseMsg.put("LogicalHandlerInterceptor.INREADER", reader); chain.doIntercept(responseMsg); } }
Example #13
Source File: TestUtil.java From cxf with Apache License 2.0 | 5 votes |
public static SoapMessage createEmptySoapMessage(SoapVersion soapVersion, InterceptorChain chain) { Exchange exchange = new ExchangeImpl(); MessageImpl messageImpl = new MessageImpl(); messageImpl.setInterceptorChain(chain); messageImpl.setExchange(exchange); SoapMessage soapMessage = new SoapMessage(messageImpl); soapMessage.setVersion(soapVersion); soapMessage.put(Message.HTTP_REQUEST_METHOD, "POST"); return soapMessage; }
Example #14
Source File: ColocUtilTest.java From cxf with Apache License 2.0 | 5 votes |
@Test public void testGetInInterceptorChain() throws Exception { PhaseManagerImpl phaseMgr = new PhaseManagerImpl(); SortedSet<Phase> list = phaseMgr.getInPhases(); ColocUtil.setPhases(list, Phase.SETUP, Phase.POST_LOGICAL); Endpoint ep = control.createMock(Endpoint.class); Service srv = control.createMock(Service.class); Exchange ex = new ExchangeImpl(); ex.put(Bus.class, bus); ex.put(Endpoint.class, ep); ex.put(Service.class, srv); EasyMock.expect(bus.getExtension(PhaseManager.class)).andReturn(phaseMgr); 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(); InterceptorChain chain = ColocUtil.getInInterceptorChain(ex, list); control.verify(); assertNotNull("Should have chain instance", chain); Iterator<Interceptor<? extends Message>> iter = chain.iterator(); assertFalse("Should not have interceptors in chain", iter.hasNext()); assertNotNull("OutFaultObserver should be set", chain.getFaultObserver()); }
Example #15
Source File: ColocUtilTest.java From cxf with Apache License 2.0 | 5 votes |
@Test public void testGetOutInterceptorChain() throws Exception { PhaseManagerImpl phaseMgr = new PhaseManagerImpl(); SortedSet<Phase> list = phaseMgr.getInPhases(); ColocUtil.setPhases(list, Phase.SETUP, Phase.POST_LOGICAL); Endpoint ep = control.createMock(Endpoint.class); Service srv = control.createMock(Service.class); Exchange ex = new ExchangeImpl(); ex.put(Bus.class, bus); ex.put(Endpoint.class, ep); ex.put(Service.class, srv); EasyMock.expect(ep.getOutInterceptors()) .andReturn(new ArrayList<Interceptor<? extends Message>>()).atLeastOnce(); EasyMock.expect(ep.getService()).andReturn(srv).atLeastOnce(); EasyMock.expect(srv.getOutInterceptors()) .andReturn(new ArrayList<Interceptor<? extends Message>>()).atLeastOnce(); EasyMock.expect(bus.getOutInterceptors()) .andReturn(new ArrayList<Interceptor<? extends Message>>()).atLeastOnce(); control.replay(); InterceptorChain chain = ColocUtil.getOutInterceptorChain(ex, list); control.verify(); assertNotNull("Should have chain instance", chain); Iterator<Interceptor<? extends Message>> iter = chain.iterator(); assertFalse("Should not have interceptors in chain", iter.hasNext()); }
Example #16
Source File: ColocInInterceptor.java From cxf with Apache License 2.0 | 5 votes |
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); }
Example #17
Source File: ResponseTimeMessageOutInterceptorTest.java From cxf with Apache License 2.0 | 5 votes |
@Test public void testClientOneWayMessageOut() { //need to increase the counter and is a client setupCounterRepository(true, true); setupExchangeForMessage(); setupOperationForMessage(); EasyMock.expect(message.getExchange()).andReturn(exchange).anyTimes(); EasyMock.expect(message.get(Message.PARTIAL_RESPONSE_MESSAGE)).andReturn(Boolean.FALSE).anyTimes(); EasyMock.expect(message.get(Message.REQUESTOR_ROLE)).andReturn(Boolean.TRUE).anyTimes(); EasyMock.expect(exchange.getOutMessage()).andReturn(message).anyTimes(); EasyMock.expect(exchange.get(FaultMode.class)).andReturn(null); EasyMock.expect(exchange.get(Exception.class)).andReturn(null); EasyMock.expect(exchange.isOneWay()).andReturn(true).anyTimes(); MessageHandlingTimeRecorder mhtr = EasyMock.createMock(MessageHandlingTimeRecorder.class); EasyMock.expect(exchange.get(MessageHandlingTimeRecorder.class)).andReturn(mhtr).anyTimes(); EasyMock.expect(exchange.get("org.apache.cxf.management.counter.enabled")).andReturn(null); InterceptorChain chain = EasyMock.createMock(InterceptorChain.class); EasyMock.expect(message.getInterceptorChain()).andReturn(chain); chain.add(EasyMock.isA(ResponseTimeMessageOutInterceptor.EndingInterceptor.class)); EasyMock.expectLastCall(); EasyMock.replay(exchange); EasyMock.replay(message); rtmoi.handleMessage(message); rtmoi.getEndingInterceptor().handleMessage(message); EasyMock.verify(message); EasyMock.verify(bus); EasyMock.verify(exchange); }
Example #18
Source File: JMSContinuationTest.java From cxf with Apache License 2.0 | 5 votes |
@Before public void setUp() { m = new MessageImpl(); Exchange exchange = new ExchangeImpl(); m.setExchange(exchange); m.setInterceptorChain(EasyMock.createMock(InterceptorChain.class)); exchange.setInMessage(m); b = BusFactory.getDefaultBus(); observer = EasyMock.createMock(MessageObserver.class); }
Example #19
Source File: ColocOutInterceptor.java From cxf with Apache License 2.0 | 5 votes |
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 #20
Source File: BareOutInterceptorTest.java From cxf with Apache License 2.0 | 5 votes |
@Before public void setUp() throws Exception { super.setUp(); interceptor = new BareOutInterceptor(); baos = new ByteArrayOutputStream(); writer = getXMLStreamWriter(baos); message.setContent(XMLStreamWriter.class, writer); message.getExchange().put(BindingOperationInfo.class, operation); IMocksControl control = EasyMock.createNiceControl(); InterceptorChain ic = control.createMock(InterceptorChain.class); message.setInterceptorChain(ic); control.replay(); }
Example #21
Source File: ColocUtil.java From cxf with Apache License 2.0 | 5 votes |
public static InterceptorChain getInInterceptorChain(Exchange ex, SortedSet<Phase> phases) { Bus bus = ex.getBus(); PhaseInterceptorChain chain = new PhaseInterceptorChain(phases); Endpoint ep = ex.getEndpoint(); List<Interceptor<? extends Message>> il = ep.getInInterceptors(); if (LOG.isLoggable(Level.FINE)) { LOG.fine("Interceptors contributed by endpoint: " + il); } chain.add(il); il = ep.getService().getInInterceptors(); if (LOG.isLoggable(Level.FINE)) { LOG.fine("Interceptors contributed by service: " + il); } chain.add(il); il = bus.getInInterceptors(); if (LOG.isLoggable(Level.FINE)) { LOG.fine("Interceptors contributed by bus: " + il); } chain.add(il); if (ep.getService().getDataBinding() instanceof InterceptorProvider) { il = ((InterceptorProvider)ep.getService().getDataBinding()).getInInterceptors(); if (LOG.isLoggable(Level.FINE)) { LOG.fine("Interceptors contributed by databinding: " + il); } chain.add(il); } chain.setFaultObserver(new ColocOutFaultObserver(bus)); modifyChain(chain, ex, true); return chain; }
Example #22
Source File: ColocUtil.java From cxf with Apache License 2.0 | 5 votes |
public static InterceptorChain getOutInterceptorChain(Exchange ex, SortedSet<Phase> phases) { Bus bus = ex.getBus(); PhaseInterceptorChain chain = new PhaseInterceptorChain(phases); Endpoint ep = ex.getEndpoint(); List<Interceptor<? extends Message>> il = ep.getOutInterceptors(); if (LOG.isLoggable(Level.FINE)) { LOG.fine("Interceptors contributed by endpoint: " + il); } chain.add(il); il = ep.getService().getOutInterceptors(); if (LOG.isLoggable(Level.FINE)) { LOG.fine("Interceptors contributed by service: " + il); } chain.add(il); il = bus.getOutInterceptors(); if (LOG.isLoggable(Level.FINE)) { LOG.fine("Interceptors contributed by bus: " + il); } chain.add(il); if (ep.getService().getDataBinding() instanceof InterceptorProvider) { il = ((InterceptorProvider)ep.getService().getDataBinding()).getOutInterceptors(); if (LOG.isLoggable(Level.FINE)) { LOG.fine("Interceptors contributed by databinding: " + il); } chain.add(il); } modifyChain(chain, ex, false); return chain; }
Example #23
Source File: RMInInterceptorTest.java From cxf with Apache License 2.0 | 5 votes |
private void testAppMessage(boolean onServer, boolean deferredAbort) throws SequenceFault, RMException, NoSuchMethodException { Method m1 = RMInInterceptor.class.getDeclaredMethod("processAcknowledgments", new Class[] {RMEndpoint.class, RMProperties.class, ProtocolVariation.class}); Method m2 = RMInInterceptor.class.getDeclaredMethod("processAcknowledgmentRequests", new Class[] {Destination.class, Message.class}); Method m3 = RMInInterceptor.class.getDeclaredMethod("processSequence", new Class[] {Destination.class, Message.class}); Method m4 = RMInInterceptor.class.getDeclaredMethod("processDeliveryAssurance", new Class[] {RMProperties.class}); interceptor = EasyMock.createMockBuilder(RMInInterceptor.class) .addMockedMethods(m1, m2, m3, m4).createMock(control); Message message = setupInboundMessage("greetMe", true); Destination d = control.createMock(Destination.class); EasyMock.expect(manager.getDestination(message)).andReturn(d); interceptor.processAcknowledgments(rme, rmps, ProtocolVariation.RM10WSA200408); EasyMock.expectLastCall(); interceptor.processAcknowledgmentRequests(d, message); EasyMock.expectLastCall(); interceptor.processSequence(d, message); EasyMock.expectLastCall(); interceptor.processDeliveryAssurance(rmps); EasyMock.expectLastCall(); EasyMock.expect(message.get(AssertionInfoMap.class)).andReturn(null); Exchange ex = control.createMock(Exchange.class); message.getExchange(); EasyMock.expectLastCall().andReturn(ex).anyTimes(); ex.get("deferred.uncorrelated.message.abort"); EasyMock.expectLastCall().andReturn(Boolean.TRUE); InterceptorChain chain = control.createMock(InterceptorChain.class); message.getInterceptorChain(); EasyMock.expectLastCall().andReturn(chain); chain.abort(); EasyMock.expectLastCall(); control.replay(); interceptor.handle(message); }
Example #24
Source File: RMSoapInInterceptor.java From cxf with Apache License 2.0 | 5 votes |
private RMManager getManager(SoapMessage message) { InterceptorChain chain = message.getInterceptorChain(); ListIterator<Interceptor<? extends Message>> it = chain.getIterator(); while (it.hasNext()) { Interceptor<? extends Message> i = it.next(); if (i instanceof AbstractRMInterceptor) { return ((AbstractRMInterceptor<? extends Message>)i).getManager(); } } return null; }
Example #25
Source File: RedeliveryQueueImpl.java From cxf with Apache License 2.0 | 5 votes |
private void redeliver() throws Exception { LOG.log(Level.INFO, "Redelivering ... for " + (1 + retries)); String restartingPhase; if (message.getContent(Exception.class) != null) { message.removeContent(Exception.class); message.getExchange().put(Exception.class, null); // clean-up message for redelivery closeStreamResources(); message.removeContent(Node.class); } InputStream is = null; CachedOutputStream cos = (CachedOutputStream)message.get(RMMessageConstants.SAVED_CONTENT); is = cos.getInputStream(); message.setContent(InputStream.class, is); message = message.getExchange().getEndpoint().getBinding().createMessage(message); restartingPhase = Phase.POST_STREAM; // skip some interceptor chain phases for redelivery InterceptorChain chain = getRedeliveryInterceptorChain(message, restartingPhase); ListIterator<Interceptor<? extends Message>> iterator = chain.getIterator(); while (iterator.hasNext()) { Interceptor<? extends Message> incept = iterator.next(); if (incept.getClass().getName().equals(RMCaptureInInterceptor.class.getName())) { chain.remove(incept); } } message.getExchange().setInMessage(message); message.setInterceptorChain(chain); chain.doIntercept(message); Exception ex = message.getContent(Exception.class); if (null != ex) { throw ex; } }
Example #26
Source File: RedeliveryQueueImpl.java From cxf with Apache License 2.0 | 5 votes |
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 #27
Source File: PolicyInterceptorsTest.java From cxf with Apache License 2.0 | 5 votes |
private void coachPolicyOverride(boolean in, boolean fault) { Assertion assertion = control.createMock(Assertion.class); EasyMock.expect(assertion.getName()).andReturn(ASSERTION_QNAME); Collection<Assertion> assertions = new ArrayList<>(); assertions.add(assertion); Policy policyOverride = control.createMock(Policy.class); EasyMock.expect(message.getContextualProperty(PolicyConstants.POLICY_OVERRIDE)) .andReturn(policyOverride); AlternativeSelector selector = control.createMock(AlternativeSelector.class); EasyMock.expect(selector.selectAlternative(policyOverride, pe, null, null, message)).andReturn(assertions); EasyMock.expect(pe.getAlternativeSelector()).andReturn(selector); EasyMock.expect(pe.getBus()).andReturn(bus).anyTimes(); PolicyInterceptorProviderRegistry reg = control .createMock(PolicyInterceptorProviderRegistry.class); EasyMock.expect(bus.getExtension(PolicyInterceptorProviderRegistry.class)).andReturn(reg); List<Interceptor<? extends Message>> li = createMockInterceptorList(); if (in && fault) { EasyMock.expect(reg.getInFaultInterceptorsForAssertion(ASSERTION_QNAME)).andReturn(li); } else if (!in && fault) { EasyMock.expect(reg.getOutFaultInterceptorsForAssertion(ASSERTION_QNAME)).andReturn(li); } else if (in && !fault) { EasyMock.expect(reg.getInInterceptorsForAssertion(ASSERTION_QNAME)).andReturn(li); } else if (!in && !fault) { EasyMock.expect(reg.getOutInterceptorsForAssertion(ASSERTION_QNAME)).andReturn(li); } InterceptorChain ic = control.createMock(InterceptorChain.class); EasyMock.expect(message.getInterceptorChain()).andReturn(ic).anyTimes(); ic.add(li.get(0)); EasyMock.expectLastCall(); }
Example #28
Source File: GZIPAcceptEncodingTest.java From cxf with Apache License 2.0 | 5 votes |
@Before public void setUp() throws Exception { interceptor = new GZIPOutInterceptor(); inMessage = new MessageImpl(); outMessage = new MessageImpl(); Exchange exchange = new ExchangeImpl(); exchange.setInMessage(inMessage); inMessage.setExchange(exchange); inMessage.setContent(InputStream.class, new ByteArrayInputStream(new byte[0])); exchange.setOutMessage(outMessage); outMessage.setExchange(exchange); outMessage.setContent(OutputStream.class, new ByteArrayOutputStream()); outInterceptors = EasyMock.createMock(InterceptorChain.class); outMessage.setInterceptorChain(outInterceptors); }
Example #29
Source File: EjbInterceptor.java From tomee with Apache License 2.0 | 5 votes |
private static void copyDataBindingInterceptors(PhaseInterceptorChain newChain, InterceptorChain oldChain) { for (Interceptor interceptor : oldChain) { if (interceptor instanceof AbstractInDatabindingInterceptor) { log.debug("Added data binding interceptor: " + interceptor); newChain.add(interceptor); } } }
Example #30
Source File: PhaseInterceptorChain.java From cxf with Apache License 2.0 | 4 votes |
public synchronized void abort() { this.state = InterceptorChain.State.ABORTED; }