/** * Adds a handler to the collection. Note that the order in which you register the handlers determines the order * in which they will be handled during the various stages of a unit of work. * * @param phase The phase of the unit of work to attach the handler to * @param handler The handler to invoke in the given phase */ public void addHandler(Phase phase, Consumer<UnitOfWork<T>> handler) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("Adding handler {} for phase {}", handler.getClass().getName(), phase.toString()); } final Deque<Consumer<UnitOfWork<T>>> consumers = handlers.computeIfAbsent(phase, p -> new ArrayDeque<>()); if (phase.isReverseCallbackOrder()) { consumers.addFirst(handler); } else { consumers.add(handler); } }
@Override protected void notifyHandlers(Phase phase) { Iterator<MessageProcessingContext<T>> iterator = phase.isReverseCallbackOrder() ? new LinkedList<>(processingContexts).descendingIterator() : processingContexts.iterator(); iterator.forEachRemaining(context -> (processingContext = context).notifyHandlers(this, phase)); }
/** * Adds a handler to the collection. Note that the order in which you register the handlers determines the order * in which they will be handled during the various stages of a unit of work. * * @param phase The phase of the unit of work to attach the handler to * @param handler The handler to invoke in the given phase */ public void addHandler(Phase phase, Consumer<UnitOfWork<T>> handler) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("Adding handler {} for phase {}", handler.getClass().getName(), phase.toString()); } final Deque<Consumer<UnitOfWork<T>>> consumers = handlers.computeIfAbsent(phase, p -> new ArrayDeque<>()); if (phase.isReverseCallbackOrder()) { consumers.addFirst(handler); } else { consumers.add(handler); } }
/** * Adds a handler to the collection. Note that the order in which you register the handlers determines the order * in which they will be handled during the various stages of a unit of work. * * @param phase The phase of the unit of work to attach the handler to * @param handler The handler to invoke in the given phase */ public void addHandler(Phase phase, Consumer<UnitOfWork<T>> handler) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("Adding handler {} for phase {}", handler.getClass().getName(), phase.toString()); } final Deque<Consumer<UnitOfWork<T>>> consumers = handlers.computeIfAbsent(phase, p -> new ArrayDeque<>()); if (phase.isReverseCallbackOrder()) { consumers.addFirst(handler); } else { consumers.add(handler); } }
@Override protected void notifyHandlers(Phase phase) { Iterator<MessageProcessingContext<T>> iterator = phase.isReverseCallbackOrder() ? new LinkedList<>(processingContexts).descendingIterator() : processingContexts.iterator(); iterator.forEachRemaining(context -> (processingContext = context).notifyHandlers(this, phase)); }
@Override protected void notifyHandlers(Phase phase) { Iterator<MessageProcessingContext<T>> iterator = phase.isReverseCallbackOrder() ? new LinkedList<>(processingContexts).descendingIterator() : processingContexts.iterator(); iterator.forEachRemaining(context -> (processingContext = context).notifyHandlers(this, phase)); }