    001    package com.hammurapi.eventbus;
    002
    003    import java.util.Queue;
    004    import java.util.Set;
    005
    006    import com.hammurapi.common.ExceptionHandler;
    007    import com.hammurapi.common.concurrent.TrackingExecutorService;
    008    import com.hammurapi.eventbus.AbstractEventBus.Handle;
    009    import com.hammurapi.extract.Predicate;
    010
    011    /**
    012     * Wrapper interface.
    013     * @author Pavel Vlasov
    014     *
    015     * @param <E>
    016     * @param <P>
    017     */
    018    public interface EventHandlerWrapper<E, P extends Comparable<P>, C, K, H extends EventBus.Handle<E, P, C>, S extends EventStore<E,P,C,H,S>> extends EventHandlerBase<E, P, C> {
    019
    020            /**
    021             * Posts event for handling.
    022             * @param context Event dispatching context.
    023             * @param events Events to handle. An event to handle if there is one event.
    024             * A tuple of joined events to handle otherwise.
    025             * @return Events to post to the bus as a result of event handling.
    026             */
    027            void post(
    028                            EventDispatchContext<E,P,C,H,S> context,
    029                            InferenceContext<E,P,C,K,H,S> inferenceContext,
    030                            Handle<E,P,C,K>... events);
    031
    032            /**
    033             * @return set of registration keys. Shared join event handler can have more than one
    034             * registration key. When the set becomes empty the handler shall be removed from the
    035             * inference network. Join event handlers shall cascade remove(K) to target handlers.
    036             */
    037            Set<K> getRegistrationKeys();
    038
    039            EventHandler<E, P, C, H, S> getHandler();
    040
    041            void takeSnapshot(AbstractEventBus.Snapshot<E, P, C, K, H, S> snapshot, Set<K> taken);
    042
    043            /**
    044             * Predicate which was used during registration.
    045             * @return
    046             */
    047            Predicate<E, C> getPredicate();
    048
    049    //      boolean isRemoved();
    050
    051    //      void remove();
    052    }