Skip to content
tminglei edited this page Jun 8, 2012 · 11 revisions

Welcome to the page-debugging wiki! pls see below guide to use the tool.


Guide to Page-Debugging Tool

Summary

Current site pages are always divided into many nested page fragments. These page fragments improved code re-usability, but meantime made it more difficult for a web developer to find the right fragment file to modify. This tool can make the finding easy.

Features

This tool’s functions can be simply described as follows:

  • Before using the tool, before using page-debugging
  • After using the tool (i.e. append ‘pageDebugging=on’ to current url),

As you seen, the included files are traced with “<!—[debugging code] - start -->” and “”, so you can easily find the right fragment files.

Tips: You can get such info from it:

  • The path name of an included file
  • Begin and end points of an included file
  • Level of an included file in current page structure

p.s. debugging code format := ‘L’ + [level number] + ‘#’ + [sequence number] + ‘:’ + [file name]

Technical Principles

Use the aspect technology to insert a HTML comment (tracking code) at begin and end of the output content when the web container or template engine includes a page fragment.

  • Supports Tomcat 6.0+, JBoss-Web 2, Freemarker 2+ and Velocity 1.5/1.7.

Installation & Configuration

  1. Deploy related files to their specific dirs, and that means: a) Ensure aspectjweaver.jar is on your machine; b) Place page-debugging.jar and aspectjrt.jar under dir ‘[tomcat home]\lib’

  2. Let AspectJ take over class loading job, so it can weave them if necessary, which can be done by simply adding JVM arguments when launching tomcat like belows: -javaagent:[pathto]\aspectjweaver.jar

  3. Add listener class (a tomcat valve) to runtime environment, so you can turn on/off this tool as you expected; and add customized class loader to your app’s element, so it can load the tool related classes on command under app runtime environment. You can do it just as below picture described:

*note: above ‘BridgedClassLoader’ need a working parameter ‘pageDebuggingJarPath’, which was used to tell ‘BridgedClassLoader’ the path to page-tracking.jar and then the class loader can find other required java classes in it. You can set it by adding a jvm parameter like below: -DpageDebuggingJarPath=[path_to_page-debugging.jar]

** So all the extra jvm arguments that you’ll add for the page debugging tool will like as below: -javaagent:[pathto]\aspectjweaver.jar -DpageDebuggingJarPath=[path_to_page-debugging.jar]

  1. Then you can turn on/off this tool by appending “pageDebugging=true/on” or “pageDebugging=false/off” to current page URL. And this configuration info will be kept during your current session.
  • Tips: cleanup tomcat working cache before firstly using it.

FAQ Q: How to resolve if name conflict occurred with the default debugging switch key name “pageDebugging”? A: You can specify a new debugging switch key name by appending JVM argument: -DpageDebugging.switchKey=[new debugging switch key name]

Q: If I want to specify some files or dirs not to be tracked, can I? How? A: Yes, you can. By default all files under /WEB-INF/tags/ (include its sub dirs) and file StandardFunctions.jsp are not be tracked. If your requirement is different, you can change it by appending one more JVM argument like below: -DpageDebugging.excluded=”foo/bar/, tttt.txt” Or -DpageDebugging.excluded_append:“foo/bar/, tttt.txt”

  • Please use ‘,’ or ‘;’ to split these files or dirs. ** ‘append:’ means append to current item list. *** Don’t worry about the redundant whitespaces between them.

Clone this wiki locally