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