class MAMStanzaHandlerInterceptor implements StanzaHandlerInterceptor {

    @Override
    public void intercept(Stanza stanza, ServerRuntimeContext serverRuntimeContext, boolean isOutboundStanza,
            SessionContext sessionContext, SessionStateHolder sessionStateHolder, StanzaBroker stanzaBroker,
            StanzaHandlerInterceptorChain interceptorChain) throws ProtocolException {

        StanzaBroker stanzaBrokerToUse;
        if (isCandidateForArchiving(stanza)) {
            stanzaBrokerToUse = stanzaBrokerProviders.stream()
                    .filter(mamStanzaBrokerProvider -> mamStanzaBrokerProvider.supports(stanza, serverRuntimeContext))
                    .map(mamStanzaBrokerProvider -> mamStanzaBrokerProvider.proxy(stanzaBroker, serverRuntimeContext,
                            sessionContext, isOutboundStanza, isArchivingForced(stanza)))
                    .findFirst().orElse(stanzaBroker);
        } else {
            stanzaBrokerToUse = stanzaBroker;
        }

        interceptorChain.intercept(stanza, serverRuntimeContext, isOutboundStanza, sessionContext, sessionStateHolder,
                stanzaBrokerToUse);
    }

    public  MAMStanzaHandlerInterceptor();
      MAMStanzaHandlerInterceptor(List<MAMStanzaBrokerProvider> stanzaBrokerProviders);

}