Express (Distributed operating systems), v8.0 > Troubleshoot and support > Analyzing application server Java system dumps with the IBM Monitoring and Diagnostic Tools for Java - Dump Analyzer > Write Dump Analyzer modules for WAS diagnostics - Tutorial


Tutorial: Writing Dump Analyzer modules for WAS diagnostics


The Hello World Analyzer

Here is the simplest possible analyzer. It reads the dump, but ignores its contents and simply prints "Hello World" as its output.

public class HelloWorldAnalyzer extends WASAnalyzerBase implements IReport {

public IAnalysisReport produceReport() { IAnalysisReport out = allocateReport(null); out.printLiteral("Hello World"); return out; } }

Though obviously very simple, this analyzer actually illustrates several basic principles common to all analyzers:


Analyzers are Java classes

An analyzer is a simply a Java class that implements a particular set of interfaces and methods. End-users of the Dump Analyzer tool, and other analyzers, can invoke our new analyzer by specifying its class name (which serves as the analyzer name)

Notes:


Use a standard base class: WASAnalyzerBase

In principle, an analyzer may need to or wish to implement a wide variety of methods from several different interfaces in order to declare itself to the framework and to customize how the framework invokes it. But in practice, all these methods can have default implementations in various common base classes provided with the library. So our analyzer simply needs to extend one of these common base classes, in this case WASAnalyzerBase. WASAnalyzerBase contains common definitions suitable for most analyzers that are part of the collection of analyzers used to analyze WAS information from a dump.

Our analyzer only needs to override the methods from WASAnalyzerBase for which the default implementation is not appropriate for our analyzer. In this simplest case, we do not override any methods from WASAnalyzerBase.

Notes:


Declare the main function of the analyzer: IReport

There are a few different styles of analyzers, which perform different functions and whose functions are invoked in different ways by the framework or by other analyzers. Our analyzer declares which style of function it performs by declaring that it implements a particular standard interface; in this case IReport.

The IReport interface corresponds to analyzers whose main function is to perform some analysis on the dump, and then generate a human-readable report that summarizes the information resulting from that analysis.

Notes:


Implement the main function: produceReport()

Since we declared that our analyzer was going to produce a report, it needs to provide an implementation of the method produceReport(), which is the only method declared in the IReport interface. produceReport() is the method that will be invoked from the framework when the tool actually invokes our analyzer to ask it to perform its role.

The body of produceReport() does the following:

  1. allocate an empty report object, using the allocateReport() utility method (provided by the common base class WASAnalyzerBase)
  2. put one line of text in the report object: the string "Hello World". Using the method printLiteral() in the report object, which is intended to write constant strings (literals) in a report. Other methods are available to write other types of information in a report.
  3. return the filled-in report object. The framework (which invoked our analyzer's produceReport() method) will take care of formatting and printing the report for the end-user of the tool to see.

Notes:


Next Topic


A Simple Analyzer to Examine Data Structures