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