1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 package net.sourceforge.servletspy.handler.std;
23
24 import java.util.Map;
25
26 import net.sourceforge.servletspy.IContext;
27 import net.sourceforge.servletspy.IContextHandler;
28 import net.sourceforge.servletspy.Node;
29 import net.sourceforge.servletspy.config.Param;
30 import net.sourceforge.servletspy.ctx.Context;
31
32 /***
33 * @author arno schumacher
34 */
35 public final class CycleDetectorHandler implements IContextHandler {
36
37
38
39
40
41
42 public void init(final Param[] params) {
43 }
44
45
46
47
48
49
50 public void destroy() {
51 }
52
53
54
55
56
57
58 public final void handle(final IContext context) throws Exception {
59 doHandle((Context) context);
60 }
61
62 /***
63 * @param context
64 * The context
65 */
66 private void doHandle(final Context context) {
67
68
69
70 try {
71 final Object anObject = new Object();
72 context.getSubject().equals(anObject);
73 } catch (Throwable t) {
74 context.proceed();
75 return;
76 }
77
78
79 final Map introspected = context.getIntrospectedMap();
80 if (introspected.containsKey(context.getSubject())) {
81 context.getNode().setReference(
82 (Node) introspected.get(context.getSubject()));
83 } else {
84 introspected.put(context.getSubject(), context.getNode());
85 context.proceed();
86 }
87 }
88 }