1 | package com.hammurapi.eventbus; |
2 | |
3 | import com.hammurapi.common.ExceptionHandler; |
4 | import com.hammurapi.eventbus.AbstractEventBus.Handle; |
5 | |
6 | |
7 | /** |
8 | * Events posted by handlers are wrapped into instances of this class. |
9 | * Inference commands are queued or processed immediately depending on inference policy. |
10 | * Inference commands are filtered by InferenceCommandFilter before being applied to |
11 | * event store and posted to further dispatching. |
12 | * @author Pavel Vlasov |
13 | * |
14 | * @param <E> |
15 | * @param <P> |
16 | * @param <C> |
17 | * @param <H> |
18 | */ |
19 | public abstract class InferenceCommand<E, P extends Comparable<P>, C, K, H extends EventBus.Handle<E,P,C>, S extends EventStore<E,P,C,H,S>> { |
20 | |
21 | /** |
22 | * @return Handler which posted this event. |
23 | */ |
24 | private EventHandler<E, P, C, H, S> handler; |
25 | |
26 | /** |
27 | * @return List of handler inputs which produced this event. |
28 | */ |
29 | private Handle<E,P,C,K>[] inputs; |
30 | |
31 | private K handlerId; |
32 | |
33 | private InferenceContext<E, P, C, K, H, S> inferenceContext; |
34 | |
35 | protected InferenceCommand( |
36 | K handlerId, |
37 | EventHandler<E, P, C, H, S> handler, |
38 | Handle<E,P,C,K>[] inputs, |
39 | InferenceContext<E,P,C,K,H,S> inferenceContext) { |
40 | super(); |
41 | this.handlerId = handlerId; |
42 | this.handler = handler; |
43 | this.inputs = inputs; |
44 | this.inferenceContext = inferenceContext; |
45 | } |
46 | |
47 | public EventHandler<E, P, C, H, S> getHandler() { |
48 | return handler; |
49 | } |
50 | |
51 | public Handle<E,P,C,K>[] getInputs() { |
52 | return inputs; |
53 | } |
54 | |
55 | public InferenceContext<E, P, C, K, H, S> getInferenceContext() { |
56 | return inferenceContext; |
57 | } |
58 | |
59 | public K getHandlerId() { |
60 | return handlerId; |
61 | } |
62 | |
63 | public void setInferenceContext(InferenceContext<E, P, C, K, H, S> inferenceContext) { |
64 | this.inferenceContext = inferenceContext; |
65 | } |
66 | } |
67 | |