1 package org.apache.commons.jcs3.engine.control.event;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.apache.commons.jcs3.engine.control.event.behavior.ElementEventType;
23 import org.apache.commons.jcs3.engine.control.event.behavior.IElementEvent;
24 import org.apache.commons.jcs3.engine.control.event.behavior.IElementEventHandler;
25 import org.apache.commons.jcs3.log.Log;
26 import org.apache.commons.jcs3.log.LogManager;
27
28
29
30 public class ElementEventHandlerMockImpl
31 implements IElementEventHandler
32 {
33
34 private int callCount;
35
36
37 private static final Log log = LogManager.getLog( ElementEventHandlerMockImpl.class );
38
39
40 private int spoolCount;
41
42
43 private int spoolNotAllowedCount;
44
45
46 private int spoolNoDiskCount;
47
48
49 private int exceededMaxLifeBackgroundCount;
50
51
52 private int exceededIdleTimeBackgroundCount;
53
54
55
56
57 @Override
58 public synchronized <T> void handleElementEvent( final IElementEvent<T> event )
59 {
60 setCallCount( getCallCount() + 1 );
61
62 if ( log.isDebugEnabled() )
63 {
64 log.debug( "HANDLER -- HANDLER -- HANDLER -- ---EVENT CODE = " + event.getElementEvent() );
65 log.debug( "/n/n EVENT CODE = " + event.getElementEvent() + " ***************************" );
66 }
67
68 if ( event.getElementEvent() == ElementEventType.SPOOLED_DISK_AVAILABLE )
69 {
70 setSpoolCount( getSpoolCount() + 1 );
71 }
72 else if ( event.getElementEvent() == ElementEventType.SPOOLED_NOT_ALLOWED )
73 {
74 setSpoolNotAllowedCount( getSpoolNotAllowedCount() + 1 );
75 }
76 else if ( event.getElementEvent() == ElementEventType.SPOOLED_DISK_NOT_AVAILABLE )
77 {
78 setSpoolNoDiskCount( getSpoolNoDiskCount() + 1 );
79 }
80 else if ( event.getElementEvent() == ElementEventType.EXCEEDED_MAXLIFE_BACKGROUND )
81 {
82 setExceededMaxLifeBackgroundCount( getExceededMaxLifeBackgroundCount() + 1 );
83 }
84 else if ( event.getElementEvent() == ElementEventType.EXCEEDED_IDLETIME_BACKGROUND )
85 {
86 setExceededIdleTimeBackgroundCount( getExceededIdleTimeBackgroundCount() + 1 );
87 }
88 }
89
90
91
92
93 public void setSpoolCount( final int spoolCount )
94 {
95 this.spoolCount = spoolCount;
96 }
97
98
99
100
101 public int getSpoolCount()
102 {
103 return spoolCount;
104 }
105
106
107
108
109 public void setSpoolNotAllowedCount( final int spoolNotAllowedCount )
110 {
111 this.spoolNotAllowedCount = spoolNotAllowedCount;
112 }
113
114
115
116
117 public int getSpoolNotAllowedCount()
118 {
119 return spoolNotAllowedCount;
120 }
121
122
123
124
125 public void setSpoolNoDiskCount( final int spoolNoDiskCount )
126 {
127 this.spoolNoDiskCount = spoolNoDiskCount;
128 }
129
130
131
132
133 public int getSpoolNoDiskCount()
134 {
135 return spoolNoDiskCount;
136 }
137
138
139
140
141 public void setExceededMaxLifeBackgroundCount( final int exceededMaxLifeBackground )
142 {
143 this.exceededMaxLifeBackgroundCount = exceededMaxLifeBackground;
144 }
145
146
147
148
149 public int getExceededMaxLifeBackgroundCount()
150 {
151 return exceededMaxLifeBackgroundCount;
152 }
153
154
155
156
157 public void setCallCount( final int callCount )
158 {
159 this.callCount = callCount;
160 }
161
162
163
164
165 public int getCallCount()
166 {
167 return callCount;
168 }
169
170
171
172
173 public void setExceededIdleTimeBackgroundCount( final int exceededIdleTimeBackground )
174 {
175 this.exceededIdleTimeBackgroundCount = exceededIdleTimeBackground;
176 }
177
178
179
180
181 public int getExceededIdleTimeBackgroundCount()
182 {
183 return exceededIdleTimeBackgroundCount;
184 }
185 }