EMMA Coverage Report (generated Sun Aug 17 11:20:34 PDT 2014)
[all classes][net.digitaltsunami.tmeter.action]

COVERAGE SUMMARY FOR SOURCE FILE [TimerStatsPublisherAction.java]

nameclass, %method, %block, %line, %
TimerStatsPublisherAction.java100% (1/1)100% (3/3)85%  (29/34)92%  (11/12)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class TimerStatsPublisherAction100% (1/1)100% (3/3)85%  (29/34)92%  (11/12)
TimerStatsPublisherAction (TimerStatsPublisher): void 100% (1/1)62%  (8/13)80%  (4/5)
processTimer (Timer): void 100% (1/1)100% (11/11)100% (3/3)
reset (): void 100% (1/1)100% (10/10)100% (4/4)

1/**
2 * 
3 */
4package net.digitaltsunami.tmeter.action;
5 
6import java.util.Collection;
7 
8import net.digitaltsunami.tmeter.Timer;
9import net.digitaltsunami.tmeter.TimerBasicStatistics;
10 
11/**
12 * Timer statistics action that publishes all accumulated statistics to the
13 * provided {@link TimerStatsPublisher}.
14 * <p>
15 * Note: This action is defined to accumulate and publish statistic with each
16 * completion of a timer. As such, the publisher may come under heavy load.
17 * 
18 * @author dhagberg
19 * 
20 */
21public class TimerStatsPublisherAction extends TimerStatsAction {
22    private final TimerStatsPublisher publisher;
23 
24    /**
25     * Create an instance with the required publisher.
26     * 
27     * @param publisher
28     *            Publisher to which all events will be sent.
29     */
30    public TimerStatsPublisherAction(TimerStatsPublisher publisher) {
31        super();
32        if (publisher == null) {
33            throw new IllegalArgumentException("Publisher cannot be null");
34        }
35        this.publisher = publisher;
36    }
37 
38    /*
39     * (non-Javadoc)
40     * 
41     * @see
42     * net.digitaltsunami.tmeter.action.TimerAction#processTimer(net.digitaltsunami
43     * .tmeter.Timer)
44     */
45    @Override
46    protected void processTimer(Timer timer) {
47        super.processTimer(timer);
48        publisher.publish(getTimerStatisticsSnapshot(timer.getTaskName()));
49    }
50 
51    /*
52     * (non-Javadoc)
53     * 
54     * @see net.digitaltsunami.tmeter.action.TimerStatsAction#reset()
55     */
56    @Override
57    protected void reset() {
58        Collection<TimerBasicStatistics> stats = getAllTimerStatisticsSnapshot();
59        super.reset();
60        publisher.reset(stats);
61    }
62 
63}

[all classes][net.digitaltsunami.tmeter.action]
EMMA 2.1.5320 (stable) (C) Vladimir Roubtsov