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