/** * Invoke the handlers in this collection attached to the given {@code phase}. * * @param unitOfWork The Unit of Work that is changing its phase * @param phase The phase for which attached handlers should be invoked */ @SuppressWarnings("unchecked") public void notifyHandlers(UnitOfWork<T> unitOfWork, Phase phase) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("Notifying handlers for phase {}", phase.toString()); } Deque<Consumer<UnitOfWork<T>>> l = handlers.getOrDefault(phase, EMPTY); while (!l.isEmpty()) { l.remove().accept(unitOfWork); } }
/** * 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); } }
/** * Invoke the handlers in this collection attached to the given {@code phase}. * * @param unitOfWork The Unit of Work that is changing its phase * @param phase The phase for which attached handlers should be invoked */ @SuppressWarnings("unchecked") public void notifyHandlers(UnitOfWork<T> unitOfWork, Phase phase) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("Notifying handlers for phase {}", phase.toString()); } Deque<Consumer<UnitOfWork<T>>> l = handlers.getOrDefault(phase, EMPTY); while (!l.isEmpty()) { l.remove().accept(unitOfWork); } }
/** * 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); } }
/** * Invoke the handlers in this collection attached to the given {@code phase}. * * @param unitOfWork The Unit of Work that is changing its phase * @param phase The phase for which attached handlers should be invoked */ @SuppressWarnings("unchecked") public void notifyHandlers(UnitOfWork<T> unitOfWork, Phase phase) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("Notifying handlers for phase {}", phase.toString()); } Deque<Consumer<UnitOfWork<T>>> l = handlers.getOrDefault(phase, EMPTY); while (!l.isEmpty()) { l.remove().accept(unitOfWork); } }