001 package com.hammurapi.eventbus;
002
003 /**
004 * Inference policy defines how new events (conclusions) posted by handlers are dispatched.
005 * Different policies provide different levels of serialization/concurrency of event processing.
006 * @author Pavel Vlasov
007 *
008 */
009 public enum InferencePolicy {
010
011 /**
012 * New events (conclusions) are dispatched immediately when they are posted.
013 * IMPORTANT: Use of this policy with join handlers may lead to ConcurrentModificationException if
014 * posted events match the same join handlers and inference commands are executed in
015 * the same thread.
016 */
017 IMMEDIATELY,
018
019 /**
020 * Conclusions are accumulated during handler execution and are posted to the
021 * bus after the handler successfully finishes execution (without exception).
022 */
023 AFTER_HANDLER,
024
025 /**
026 * Conclusions are accumulated during event dispatching and are posted to the
027 * bus after all handlers for the current event finish execution.
028 */
029 AFTER_EVENT,
030
031 /**
032 * "Root event" is an event which is posted to the bus by the client code (not by a handler) through
033 * EventBus.post() method. With this inference policy conclusions are accumulated and get posted
034 * to the bus after all handlers for the root event and previously posted conclusions finish execution.
035 */
036 AFTER_ROOT_EVENT,
037
038 /**
039 * Only one event at a time is dispatched by the bus. Handlers and predicates still execute in parallel by
040 * the executor service.
041 */
042 EXCLUSIVE
043
044 }