1 package test.crispy.example;
2
3 import net.sf.crispy.InterceptorHandler;
4 import net.sf.crispy.interceptor.StopWatchInterceptor;
5 import net.sf.crispy.server.InterceptorHandlerCreator;
6
7 public class InterceptorHandlerCreatorExample implements InterceptorHandlerCreator {
8
9 private StopWatchInterceptor stopWatch = null;
10 private InterceptorHandler interceptorHandler = null;
11
12 public InterceptorHandlerCreatorExample() {
13 }
14
15 public InterceptorHandlerCreatorExample(StopWatchInterceptor pvStopWatch) {
16 setStopWatch(pvStopWatch);
17 }
18
19 public void setInterceptorHandler(InterceptorHandler pvInterceptorHandler) {
20 interceptorHandler = pvInterceptorHandler;
21 }
22 public InterceptorHandler getInterceptorHandler() {
23 return interceptorHandler;
24 }
25
26 /**
27 * This method create a new <code>InterceptorHandler</code> instance.
28 * If set a <code>InterceptorHandler</code> (with setInterceptorHandler), than
29 * is by every call from this method the return object the same. This behavior is
30 * for tests suitable. For production is it nor suittable.
31 *
32 * @return The <code>InterceptorHandler</code> object.
33 */
34 public InterceptorHandler createNewInterceptorHandlerInstance() {
35 if (interceptorHandler == null) {
36 interceptorHandler = new InterceptorHandler();
37 }
38 return interceptorHandler;
39 }
40
41 public StopWatchInterceptor getStopWatch() {
42 return stopWatch;
43 }
44 public void setStopWatch(StopWatchInterceptor pvStopWatch) {
45 interceptorHandler = new InterceptorHandler();
46 stopWatch = pvStopWatch;
47 interceptorHandler.addInterceptor(stopWatch);
48 }
49
50
51 }