1 | |
package org.apache.maven.monitor.event; |
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
import java.util.Arrays; |
23 | |
import java.util.List; |
24 | |
|
25 | |
|
26 | |
|
27 | |
|
28 | |
public abstract class AbstractSelectiveEventMonitor |
29 | |
implements EventMonitor |
30 | |
{ |
31 | |
|
32 | |
private List boundStartEvents; |
33 | |
private List boundErrorEvents; |
34 | |
private List boundEndEvents; |
35 | |
|
36 | |
protected AbstractSelectiveEventMonitor(String[] startEvents, String[] endEvents, String[] errorEvents) |
37 | 0 | { |
38 | 0 | this.boundStartEvents = Arrays.asList( startEvents ); |
39 | |
|
40 | 0 | this.boundEndEvents = Arrays.asList( endEvents ); |
41 | |
|
42 | 0 | this.boundErrorEvents = Arrays.asList( errorEvents ); |
43 | 0 | } |
44 | |
|
45 | |
public final void startEvent( String eventName, String target, long timestamp ) |
46 | |
{ |
47 | 0 | if( boundStartEvents.contains( eventName ) ) |
48 | |
{ |
49 | 0 | doStartEvent( eventName, target, timestamp ); |
50 | |
} |
51 | 0 | } |
52 | |
|
53 | |
protected void doStartEvent( String eventName, String target, long timestamp ) |
54 | |
{ |
55 | 0 | } |
56 | |
|
57 | |
public final void endEvent( String eventName, String target, long timestamp ) |
58 | |
{ |
59 | 0 | if( boundEndEvents.contains( eventName ) ) |
60 | |
{ |
61 | 0 | doEndEvent( eventName, target, timestamp ); |
62 | |
} |
63 | 0 | } |
64 | |
|
65 | |
protected void doEndEvent( String eventName, String target, long timestamp ) |
66 | |
{ |
67 | 0 | } |
68 | |
|
69 | |
public final void errorEvent( String eventName, String target, long timestamp, Throwable cause ) |
70 | |
{ |
71 | 0 | if( boundErrorEvents.contains( eventName ) ) |
72 | |
{ |
73 | 0 | doErrorEvent( eventName, target, timestamp, cause ); |
74 | |
} |
75 | 0 | } |
76 | |
|
77 | |
protected void doErrorEvent( String eventName, String target, long timestamp, Throwable cause ) |
78 | |
{ |
79 | 0 | } |
80 | |
|
81 | |
} |