ObjectSnoop |
||
Inspecting objects in Java
|
||
ObjectSnoop Homepage Features History Download Contact Links Manual SourceForge Project homepage Website | I've listed here a brief summary of the things that you can do with ObjectSnoop. There is more detailed documentation for programmers on how to make the most of these features in the following pages. The complete and entire purpose of ObjectSnoop. Examining an object is handled by the built in Java reflection API: giving access to an object's true class, methods, instance variables, and inheritance relationships. ObjectSnoop takes this information and tries to present it to the developer in a more human readable form. This snooped information is recursive in nature; given an object to snoop, any class instance variables will also be snooped. Obviously this can't go too deep or we'd be buried in data and have closed reference loops to deal with. This kind of snooped information is available to a developer through the Java debugger, so ObjectSnoop is a complementary tool and not intended as a replacement. With control over output formatting, the snooped data can be viewed on screen, in a file, or any other destination that can present itself as either a java.io.Writer object (using an existing formatter), or a custom formatter in its own right. In order to make ObjectSnoop more powerful and flexible, filters can be used to process objects of a given class, or derived from that class. Java Server Pages are also supported with their own tag library. An output formatter applies post processing to the analysis of an object. Actually the relationship is a little bit more intimate than that: the snooping of an object directs the construction of the formatted output. The formatter makes decisions about how to present the snooped object, providing an understanding of some of the strengths and limitations of the output format. By way of example the HTML formatter builds nested tables, one table for each class instance object. It understands that nested tables in HTML can get pretty ugly, so it only nests to a depth of 3 objects. Further depth is built up in a separate table, and anchored links to and from this table are inserted into the HTML. Quite often developers aren't interested in the nitty gritty implementation of an object or an interface; the information needed is tied up in the behaviour or presentation of an object. Class and interface filters help by intercepting the inspection of an object and providing a customized view. These filters are straightforward to implement, so developers can build them for their own classes and interfaces as well. A set of filters has already been built to support Servlets and JSP, and more are planned. The flexibility of rebuilding a JSP on demand, without restarting the web application, makes a tag library a natural addition. When a page isn't behaving how you expect it to, you can add a tag that inspects page attributes, form posted data, or session variables. As you can also add scriptlets to a JSP, you can access variables in page or local scope too. | |