@Test public void test_two_interceptors() throws ProtocolException { List<StanzaHandlerInterceptor> interceptors = new ArrayList<>(); interceptors.add(new InterceptorMock()); interceptors.add(new InterceptorMock()); new SimpleStanzaHandlerInterceptorChain(stanzaHandler, interceptors).intercept(stanza, serverRuntimeContext, false, sessionContext, sessionStateHolder, firstStanzaBroker); verify(stanzaHandler).execute(stanza, serverRuntimeContext, false, sessionContext, sessionStateHolder, firstStanzaBroker); assertTrue(((InterceptorMock) interceptors.get(0)).intercepted); assertTrue(((InterceptorMock) interceptors.get(1)).intercepted); }
@Override public void intercept(Stanza stanza, ServerRuntimeContext serverRuntimeContext, boolean isOutboundStanza, SessionContext sessionContext, SessionStateHolder sessionStateHolder, StanzaBroker stanzaBroker) throws ProtocolException { StanzaHandlerInterceptor interceptor = interceptors.poll(); if (interceptor == null) { LOG.debug("No more interceptor to execute. Executing stanza handler {}.", stanzaHandler); stanzaHandler.execute(stanza, serverRuntimeContext, isOutboundStanza, sessionContext, sessionStateHolder, stanzaBroker); return; } LOG.debug("Executing interceptor {}", interceptor); interceptor.intercept(stanza, serverRuntimeContext, isOutboundStanza, sessionContext, sessionStateHolder, stanzaBroker, this); }
SimpleStanzaHandlerInterceptorChain implements StanzaHandlerInterceptorChain { @Override public void intercept(Stanza stanza, ServerRuntimeContext serverRuntimeContext, boolean isOutboundStanza, SessionContext sessionContext, SessionStateHolder sessionStateHolder, StanzaBroker stanzaBroker) throws ProtocolException { StanzaHandlerInterceptor interceptor = interceptors.poll(); if (interceptor == null) { LOG.debug("No more interceptor to execute. Executing stanza handler {}.", stanzaHandler); stanzaHandler.execute(stanza, serverRuntimeContext, isOutboundStanza, sessionContext, sessionStateHolder, stanzaBroker); return; } LOG.debug("Executing interceptor {}", interceptor); interceptor.intercept(stanza, serverRuntimeContext, isOutboundStanza, sessionContext, sessionStateHolder, stanzaBroker, this); } }
SimpleStanzaHandlerInterceptorChain implements StanzaHandlerInterceptorChain { @Override public void intercept(Stanza stanza, ServerRuntimeContext serverRuntimeContext, boolean isOutboundStanza, SessionContext sessionContext, SessionStateHolder sessionStateHolder, StanzaBroker stanzaBroker) throws ProtocolException { StanzaHandlerInterceptor interceptor = interceptors.poll(); if (interceptor == null) { LOG.debug("No more interceptor to execute. Executing stanza handler {}.", stanzaHandler); stanzaHandler.execute(stanza, serverRuntimeContext, isOutboundStanza, sessionContext, sessionStateHolder, stanzaBroker); return; } LOG.debug("Executing interceptor {}", interceptor); interceptor.intercept(stanza, serverRuntimeContext, isOutboundStanza, sessionContext, sessionStateHolder, stanzaBroker, this); } SimpleStanzaHandlerInterceptorChain(StanzaHandler stanzaHandler,
            List<StanzaHandlerInterceptor> interceptors); }
SimpleStanzaHandlerInterceptorChain implements StanzaHandlerInterceptorChain { @Override public void intercept(Stanza stanza, ServerRuntimeContext serverRuntimeContext, boolean isOutboundStanza, SessionContext sessionContext, SessionStateHolder sessionStateHolder, StanzaBroker stanzaBroker) throws ProtocolException { StanzaHandlerInterceptor interceptor = interceptors.poll(); if (interceptor == null) { LOG.debug("No more interceptor to execute. Executing stanza handler {}.", stanzaHandler); stanzaHandler.execute(stanza, serverRuntimeContext, isOutboundStanza, sessionContext, sessionStateHolder, stanzaBroker); return; } LOG.debug("Executing interceptor {}", interceptor); interceptor.intercept(stanza, serverRuntimeContext, isOutboundStanza, sessionContext, sessionStateHolder, stanzaBroker, this); } SimpleStanzaHandlerInterceptorChain(StanzaHandler stanzaHandler,
            List<StanzaHandlerInterceptor> interceptors); @Override void intercept(Stanza stanza, ServerRuntimeContext serverRuntimeContext, boolean isOutboundStanza,
            SessionContext sessionContext, SessionStateHolder sessionStateHolder, StanzaBroker stanzaBroker); }
SimpleStanzaHandlerInterceptorChain implements StanzaHandlerInterceptorChain { @Override public void intercept(Stanza stanza, ServerRuntimeContext serverRuntimeContext, boolean isOutboundStanza, SessionContext sessionContext, SessionStateHolder sessionStateHolder, StanzaBroker stanzaBroker) throws ProtocolException { StanzaHandlerInterceptor interceptor = interceptors.poll(); if (interceptor == null) { LOG.debug("No more interceptor to execute. Executing stanza handler {}.", stanzaHandler); stanzaHandler.execute(stanza, serverRuntimeContext, isOutboundStanza, sessionContext, sessionStateHolder, stanzaBroker); return; } LOG.debug("Executing interceptor {}", interceptor); interceptor.intercept(stanza, serverRuntimeContext, isOutboundStanza, sessionContext, sessionStateHolder, stanzaBroker, this); } SimpleStanzaHandlerInterceptorChain(StanzaHandler stanzaHandler,
            List<StanzaHandlerInterceptor> interceptors); @Override void intercept(Stanza stanza, ServerRuntimeContext serverRuntimeContext, boolean isOutboundStanza,
            SessionContext sessionContext, SessionStateHolder sessionStateHolder, StanzaBroker stanzaBroker);  }