001 package com.hammurapi.eventbus;
002
003 import com.hammurapi.eventbus.EventHandlerBase.Mode;
004 import com.hammurapi.extract.Predicate;
005
006 /**
007 * Context of event dispatching.
008 * @author Pavel Vlasov.
009 * @param <E> Event type.
010 */
011 public interface EventDispatchContext<E, P extends Comparable<P>, C, H extends EventBus.Handle<E,P,C>, S extends EventStore<E,P,C,H,S>> {
012
013 /**
014 * Posts new event to the bus.
015 * @param events
016 */
017 void post(E event, Predicate<E, S>... validators);
018
019 /**
020 * Consumes event at index removing them from further multi-event joins.
021 * @param indices
022 */
023 void consume(int index);
024
025 /**
026 * Consumes event.
027 * @param events
028 */
029 void consume(E event);
030
031 // /**
032 // * Replaces an event with a new event. This method is intended for
033 // * enrichment scenarios where a new event is a subclass of the
034 // * original event type and all original event attributes remain
035 // * the same, i.e. the new event can be used in place of the original event.
036 // * @param <T> Event type.
037 // * @param oldEvent
038 // * @param newEvent
039 // */
040 // <T extends E, S extends T> void substitute(T oldEvent, S newEvent);
041
042 /**
043 * Invocation of this method indicates that one of source events has
044 * been chanded and shall be re-posted.
045 * @param event
046 */
047 void update(E event);
048
049 /**
050 * Removes given handler from the inference network so it is never fired again.
051 */
052 void removeHandler();
053
054 /**
055 * @return event store.
056 */
057 S getEventStore();
058
059 /**
060 * Handler mode - POST or REMOVE
061 * @return
062 */
063 Mode getMode();
064
065 // TODO method to request derivation tree
066
067 }