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 a new analysis module or script > Write and running a new analysis module


Write an analyzer that implements IReport

When creating an analysis module that implements the IReport interface, follow the same steps for creating a new class that were outlined in the Write an analyzer that implements IAnalyze section. However, this time you should enter the following information in the New Class wizard:

The code in List 2 demonstrates a class that implements the IReport interface. This simple example outputs the machine type that the dump was created on. No decisions are made by the class as its sole function is to create a report. Enter the contents of List 2 into your newly created DWReport class to follow along with the example.

List 2. Example of an Analyzer that implements IReport

 package mypackage;

import com.ibm.dtfj.analyzer.base.AnalyzerBase;
import com.ibm.dtfj.analyzer.base.AnalyzerContext;
import com.ibm.dtfj.analyzer.ext.IAnalysisReport;
import com.ibm.dtfj.analyzer.ext.IAnalyzerContext;
import com.ibm.dtfj.analyzer.ext.IReport;
import com.ibm.dtfj.image.DTFJException;
import com.ibm.dtfj.image.Image;

/**
 * This is the basic design required to implement an IReport Interface  */
public class DWReport extends AnalyzerBase implements IReport {

    private static String description = "DWReport example";

    public DWReport() {}

    /*
     * (non-Javadoc)
     * @see com.ibm.dtfj.analyzer.base.AnalyzerBase#getShortDescription()
     */
    public String getShortDescription() {
        return description;
    }

    /*
     * (non-Javadoc)
     * @see com.ibm.dtfj.analyzer.ext.IReport#produceReport()
     */
    public IAnalysisReport produceReport() {
        IAnalysisReport ret = allocateReport();

        IAnalyzerContext ctx = getContext();

        if (ctx instanceof AnalyzerContext) {
            try {
                Image p = ((AnalyzerContext)ctx).getCurrentImage();
                ret.printLiteral("Image created on " + p.getSystemType());
            } catch (DTFJException e) {
                e.printStackTrace();
            }
        }

        return ret;
    }
}



We can see from this example that there are two methods that require an implementation: getShortDescription() and produceReport(). The aim of the produceReport method is to extract some useful information from the dump and return it in report form so that it can be encapsulated in the IAnalysisReport object for later use. The report object will then be formatted for viewing. In the above example a simple report is produced which contains the type of system that the dump was created on. disclosure restricted by GSA ADP Schedule Contract with IBM Corp.

+

Search Tips   |   Advanced Search