EMMA Coverage Report (generated Thu Jan 20 11:39:44 EST 2011)
[all classes][com.hammurapi.eventbus.local]

COVERAGE SUMMARY FOR SOURCE FILE [RemoveListener.java]

nameclass, %method, %block, %line, %
RemoveListener.java100% (1/1)100% (2/2)100% (57/57)100% (11/11)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class RemoveListener100% (1/1)100% (2/2)100% (57/57)100% (11/11)
RemoveListener (EventHandler, Long, AbstractEventBus$Handle [], Class): void 100% (1/1)100% (38/38)100% (8/8)
postRetractCommand (InferenceContext): void 100% (1/1)100% (19/19)100% (3/3)

1package com.hammurapi.eventbus.local;
2 
3import java.lang.reflect.Array;
4import java.util.Arrays;
5import java.util.concurrent.atomic.AtomicBoolean;
6 
7import com.hammurapi.eventbus.AbstractEventBus;
8import com.hammurapi.eventbus.AbstractEventBus.Handle;
9import com.hammurapi.eventbus.EventHandler;
10import com.hammurapi.eventbus.EventStore;
11import com.hammurapi.eventbus.InferenceContext;
12import com.hammurapi.eventbus.RetractCommand;
13 
14/**
15 * Stores handles and handler for posting retract command.
16 * @author Pavel Vlasov
17 *
18 */
19class RemoveListener<E, P extends Comparable<P>, C, S extends EventStore<E,P,C,AbstractEventBus.Handle<E,P,C,Long>,S>> {
20        
21        /**
22         * @return Handler which posted this event.
23         */
24        private EventHandler<E, P, C, AbstractEventBus.Handle<E,P,C,Long>, S> handler;
25        
26        /**
27         * @return List of handler inputs which produced this event.
28         */
29        private E[] events;
30 
31        private Long handlerId;
32 
33        RemoveListener(
34                        EventHandler<E, P, C, Handle<E, P, C, Long>, S> handler,
35                        Long handlerId,
36                        Handle<E, P, C, Long>[] handles,
37                        Class<E> eventType) {
38                super();
39                this.handler = handler;
40                this.handlerId = handlerId;
41                events = (E[]) Array.newInstance(eventType, handles.length);
42                for (int i=0; i<events.length; ++i) {
43                        events[i] = handles[i].getEvent();
44                }
45        }
46        
47        private AtomicBoolean fired = new AtomicBoolean();
48        
49        void postRetractCommand(InferenceContext<E, P, C, Long, Handle<E, P, C, Long>, S> inferenceContext) {
50                if (!fired.getAndSet(true)) {
51                        inferenceContext.postInferenceCommand(new RetractCommand<E, P, C, Long, AbstractEventBus.Handle<E,P,C,Long>, S>(events, handlerId, handler, inferenceContext.createNext()));
52                }
53        }
54 
55}

[all classes][com.hammurapi.eventbus.local]
EMMA 2.0.5312 EclEmma Fix 2 (C) Vladimir Roubtsov