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 net.sourceforge.servletspy.IContext;
25 import net.sourceforge.servletspy.IContextHandler;
26 import net.sourceforge.servletspy.config.Param;
27 import net.sourceforge.servletspy.ctx.Context;
28
29 import org.apache.commons.logging.Log;
30 import org.apache.commons.logging.LogFactory;
31
32 /***
33 * @author arno schumacher
34 */
35 public final class DebugHandler implements IContextHandler {
36
37 /*** The logger. */
38 private static final Log LOGGER = LogFactory.getLog(DebugHandler.class);
39
40
41
42
43 public void init(final Param[] params) {
44 }
45
46
47
48
49 public void destroy() {
50 }
51
52
53
54
55 public void handle(final IContext pContext) throws Exception {
56 final Context context = (Context) pContext;
57 final Object subject = context.getSubject();
58
59 final long time = System.currentTimeMillis();
60 try {
61 context.proceed();
62 } finally {
63 final long deltaTime = System.currentTimeMillis() - time;
64 final boolean nodeCreated = context.getNode() != null;
65 final String nodeName = nodeCreated ? context.getNode().getName()
66 : "";
67 final boolean isReference = nodeCreated ? context.getNode()
68 .hasReference() : false;
69 if (isReference) {
70 LOGGER.debug(nodeName + ": subject=" + subject + ", time="
71 + deltaTime + ", nodeCreated=" + nodeCreated
72 + ", isReference=" + isReference);
73 }
74 }
75 }
76 }