com.ibm.dtfj.analyzer.base
Class SimpleAnalyzerBean

java.lang.Object
  extended by TranslatableAnalyzer
      extended by com.ibm.dtfj.analyzer.base.SimpleAnalyzerBean
All Implemented Interfaces:
IAnalyzerBase, IReport, IWrapper
Direct Known Subclasses:
AllEnvVars, AllJavaClassLoaders, AllJavaMonitors, AllJVMInitArgs, ClassFinder, CollectionAnalyzerBase, MapEntryWrapperBase, ObjectFinder, OneContextHeader, OneImage, OneImageModule, OneImageProcess, OneImageSection, OneImageStackFrame, OneImageThread, OneJavaClass, OneJavaClassLoader, OneJavaHeap, OneJavaMethod, OneJavaMonitor, OneJavaObject, OneJavaRuntime, OneJavaStackFrame, OneJavaThread, SectionsTableBase, ValueWrapper

public abstract class SimpleAnalyzerBean
extends TranslatableAnalyzer
implements IAnalyzerBase, IWrapper, IReport

Common base class for all simple Analyzer bean classes in the DEAL library


Constructor Summary
SimpleAnalyzerBean()
           
 
Method Summary
protected  IAnalysisReport allocateReport(java.lang.Object refKey)
          Create and initialize the default type of AnalysisReport object used by Analyzers using this infrastructure.
protected static IReportOptions allocateReportOptions()
          Create and initialize the default type of ReportOptions object used by Analyzers using this infrastructure.
protected  IAnalysisReport allocateSecondaryReport(java.lang.String sectionName, java.lang.Object refKey)
          Create and initialize an AnalysisReport object suitable for holding a secondary report, to be included as a sub-section of the main report from an Analyzer.
 int getCachingPriority()
          Return an indication of how desirable it is for the AnalyzerContext to cache instances of this analyzer, so that multiple calls to loadAnalyzer() will return the cached instance instead of allocating and initializing a new one each time.
 java.lang.String[] getCategories()
           
 IAnalyzerContext getContext()
           
 java.lang.String getIdentityString()
          Provide a way for an analyzer to specify a customized identity string, that will be used in report references created with IAnalysisReport.printIdent().
protected static SimpleAnalyzerBean getInstance(IAnalyzerContext context, java.lang.String analyzerName, java.lang.Object parent)
          Utility method to gain access to an instance of a specific analyzer object
protected  java.util.logging.Logger getLogger()
          Return the shared logger object to report errors and for tracing.
 java.lang.String getLongDescription()
          Produce a long description of the function of this analyser.
 java.lang.String getName()
           
protected  java.lang.Object getNextValidObject(java.util.Iterator it, java.lang.String desc, IAnalysisReport out)
          Return the next valid object from an iterator that may contain some CorrupData fillers.
 java.lang.Object getParent()
          Return the parent object of which this analyzer bean represents some aspect (either a core DTFJ object or another analyzer bean).
protected static ReportExtensionHelper getReportExtensionHelper()
           
 java.lang.String getResourceBundleName()
          (non-Javadoc) SimpleAnalyzerBean uses SimpleAnalyzerBean.properties because it is not derived from MessageLogger and to keep them separate from MessageLogger.properties which might still be available from the context
 java.lang.String getShortDescription()
          Return a short description of the analyser purpose.
 java.lang.String getVersion()
          Get version information for this analyser.
 boolean isPrimaryAnalyzer()
          Some Analyzers are designed to perform analysis tasks and others are designed to perform supporting tasks such as wrapping a DTFJ object and providing extra information.
protected  void printEmbeddedReport(IAnalysisReport out, java.lang.String title, IReport target, java.lang.String tag)
          Utility method to invoke a report from another analyzer and include it in the current analyzer's report.
protected  void printEmbeddedReport(IAnalysisReport out, java.lang.String title, java.lang.String analyzerName, java.lang.Object parent, java.lang.String tag)
          Utility method to invoke a report from another analyzer and include it in the current analyzer's report.
protected  void printEmbeddedReportWithOptions(IAnalysisReport out, java.lang.String title, IReport target, IReportOptions options, java.lang.String tag)
          Utility method to invoke a report from another analyzer and include it in the current analyzer's report.
protected  void printEmbeddedReportWithOptions(IAnalysisReport out, java.lang.String title, java.lang.String analyzerName, java.lang.Object parent, IReportOptions options, java.lang.String tag)
          Utility method to invoke a report from another analyzer and include it in the current analyzer's report.
protected  void printReportInfoHeader(IAnalysisReport out)
          Utility method to print a header for the current report, containing some basic information about the nature of this report.
 IAnalysisReport produceReport()
          Generate a report which will be encapsulated in the IAnalysisReport object for later use by some formatter.
protected static java.lang.Exception recordInternalExceptionStatic(java.lang.Exception e)
          Record the fact that an exception was encountered during internal processing by an analysis object - at a time when we are not actively printing a report and hence no AnalysisReport object is available.
 void setContext(IAnalyzerContext analyzerContext)
          Define the context associated with this analyzer instance.
 void setParent(java.lang.Object parent)
          Set the parent object of which this analyzer bean represents some aspect (either a core DTFJ object or another analyzer bean).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleAnalyzerBean

public SimpleAnalyzerBean()
Method Detail

getContext

public final IAnalyzerContext getContext()
Specified by:
getContext in interface IAnalyzerBase
Returns:
- the context associated with this analyser instance
See Also:
IAnalyzerBase.getContext()

setContext

public final void setContext(IAnalyzerContext analyzerContext)
Description copied from interface: IAnalyzerBase
Define the context associated with this analyzer instance. This is invoked by the framework after the analyser is created and will thus never be null when the analyser is invoked.

Specified by:
setContext in interface IAnalyzerBase
Parameters:
analyzerContext - - the context to be associated with this analyser
See Also:
IAnalyzerBase.setContext(com.ibm.dtfj.analyzer.ext.IAnalyzerContext)

getName

public java.lang.String getName()
Specified by:
getName in interface IAnalyzerBase
Returns:
- the unique name associated with this type of analyser
See Also:
IAnalyzerBase.getName()

getVersion

public java.lang.String getVersion()
Description copied from interface: IAnalyzerBase
Get version information for this analyser.

Specified by:
getVersion in interface IAnalyzerBase
Returns:
- a String containing the version information
See Also:
IAnalyzerBase.getVersion()

getCategories

public java.lang.String[] getCategories()
Specified by:
getCategories in interface IAnalyzerBase
Returns:
- the set of categories the analyzer associated with. Categories can have tree type hierarchy with '.' used as a path separator. This method should never return null - "no category" should be indicated by an empty array or an empty string.
See Also:
IAnalyzerBase.getCategories()

getShortDescription

public java.lang.String getShortDescription()
Description copied from interface: IAnalyzerBase
Return a short description of the analyser purpose. This will be printed prior to running the analyser.

Specified by:
getShortDescription in interface IAnalyzerBase
Returns:
- the short description
See Also:
IAnalyzerBase.getShortDescription()

getLongDescription

public java.lang.String getLongDescription()
Description copied from interface: IAnalyzerBase
Produce a long description of the function of this analyser. The long description may use multiple lines, and should be suitable for using in a help message associated with this analyser. The description should include information about the report options and types of rules accepted by this bean, if any.

Specified by:
getLongDescription in interface IAnalyzerBase
Returns:
- a String containing the long description.
See Also:
IAnalyzerBase.getLongDescription()

isPrimaryAnalyzer

public boolean isPrimaryAnalyzer()
Description copied from interface: IAnalyzerBase
Some Analyzers are designed to perform analysis tasks and others are designed to perform supporting tasks such as wrapping a DTFJ object and providing extra information. At the end of an analysis run we would like to summarise the analyzers which have been run but we also want to avoid having a huge list. Hence we only choose to list analyzers which are designated 'primary' and typically are doing some specific analysis rather that providing a service to other analyzers.

Specified by:
isPrimaryAnalyzer in interface IAnalyzerBase
Returns:
true if this is a primary analyzer, false otherwise
See Also:
IAnalyzerBase.isPrimaryAnalyzer()

getResourceBundleName

public java.lang.String getResourceBundleName()
(non-Javadoc) SimpleAnalyzerBean uses SimpleAnalyzerBean.properties because it is not derived from MessageLogger and to keep them separate from MessageLogger.properties which might still be available from the context

See Also:
com.ibm.dtfj.analyzer.util.TranslatableMessageLogger#getResourceBundleName()

setParent

public void setParent(java.lang.Object parent)
               throws java.lang.IllegalArgumentException
Description copied from interface: IWrapper
Set the parent object of which this analyzer bean represents some aspect (either a core DTFJ object or another analyzer bean). This method should normally be overridden in subclasses to implement type-checking suitable for each type of analyzer bean.

Specified by:
setParent in interface IWrapper
Parameters:
parent - The parent object to set. This parameter is specified as type Object to enable a common factory, but the method should throw an exception if the actual class of the parent object supplied is not compatible with the particular type of analyzer bean that receives it.
Throws:
java.lang.IllegalArgumentException - thrown if the parent object supplied is not compatible with the type of analyzer bean that receives it
See Also:
IWrapper.setParent(java.lang.Object)

getParent

public final java.lang.Object getParent()
Description copied from interface: IWrapper
Return the parent object of which this analyzer bean represents some aspect (either a core DTFJ object or another analyzer bean).

This method may optionally be supplemented in subclasses by other methods that return the same parent object, but as a specific type suitable for each particular bean instead of as an Object, thereby providing more type checking at compile time.

Specified by:
getParent in interface IWrapper
Returns:
the parent object, as an Object
See Also:
IWrapper.getParent()

getIdentityString

public java.lang.String getIdentityString()
                                   throws com.ibm.dtfj.image.DTFJException
Description copied from interface: IWrapper
Provide a way for an analyzer to specify a customized identity string, that will be used in report references created with IAnalysisReport.printIdent(). If this method returns null (which should be the default for most analyzers), then the system will create an identity string derived from the identity string of the parent object, using default rules.

Specified by:
getIdentityString in interface IWrapper
Returns:
the custom identity string for this analyzer instance, or null if the system default should be used
Throws:
com.ibm.dtfj.image.DTFJException
See Also:
IWrapper.getIdentityString()

produceReport

public IAnalysisReport produceReport()
Description copied from interface: IReport
Generate a report which will be encapsulated in the IAnalysisReport object for later use by some formatter.

Specified by:
produceReport in interface IReport
Returns:
- the generic report object which will be given to some formatter
See Also:
IReport.produceReport()

getCachingPriority

public int getCachingPriority()
Description copied from interface: IAnalyzerBase
Return an indication of how desirable it is for the AnalyzerContext to cache instances of this analyzer, so that multiple calls to loadAnalyzer() will return the cached instance instead of allocating and initializing a new one each time. The caching priority is represented as a number between 0 and 10, where 0 means never cache instances of this analyzer, 10 means always cache all instances, and any number in-between indicates that we should try to cache it as long as there is enough memory available and that we give precedence to higher-priority analyzers when memory is scarce.

Specified by:
getCachingPriority in interface IAnalyzerBase
Returns:
the caching priority, as a number between 0 and 10
See Also:

The implementation in the base class returns 5, meaning all analyzers are cacheable by default when possible. This method should be overridden in specific analyzers that do not wish to be cached or that wish to be cached more aggressively.


getInstance

protected static SimpleAnalyzerBean getInstance(IAnalyzerContext context,
                                                java.lang.String analyzerName,
                                                java.lang.Object parent)
Utility method to gain access to an instance of a specific analyzer object

Parameters:
context - the analyzerContext in which to load the new analyzer object
analyzerName - name of the analyzer object to load
parent - a parent analyzer for this new analyzer
Returns:
the desired new analyzer object (a new instance or a pre-existing instance, as appropriate)

recordInternalExceptionStatic

protected static java.lang.Exception recordInternalExceptionStatic(java.lang.Exception e)
Record the fact that an exception was encountered during internal processing by an analysis object - at a time when we are not actively printing a report and hence no AnalysisReport object is available. Static version for use from static analyzer methods (no context available, no logger)

Parameters:
e - the exception that was encountered
Returns:
a new exception (or the same exception) to be stored and thrown during subsequent report attempts

getNextValidObject

protected java.lang.Object getNextValidObject(java.util.Iterator it,
                                              java.lang.String desc,
                                              IAnalysisReport out)
Return the next valid object from an iterator that may contain some CorrupData fillers. Transparently skip over any CorruptData entries, after printing a warning on the specified AnalysisReport object.

Parameters:
it - iterator from which to extract objects
desc - text message used to report errors
out - AnalysisReport object used to report errors, or null if errors should be only be reported through the logger
Returns:
the next valid object from the iterator, or null if at end

getLogger

protected java.util.logging.Logger getLogger()
Return the shared logger object to report errors and for tracing.

Returns:
Returns the logger.

printEmbeddedReportWithOptions

protected void printEmbeddedReportWithOptions(IAnalysisReport out,
                                              java.lang.String title,
                                              java.lang.String analyzerName,
                                              java.lang.Object parent,
                                              IReportOptions options,
                                              java.lang.String tag)
Utility method to invoke a report from another analyzer and include it in the current analyzer's report. This method handles the allocation of the target analyzer and deals with any errors that might occur.

Parameters:
out - a AnalysisReport in which the target analyzer's report must be added
title - a title for the report to be included
analyzerName - name of target analyzer whose report is to be include
parent - parent object for the target analyzer
options - ReportOptions to be used for the included report
tag - a formatting tag for the title of this report, or null

printEmbeddedReportWithOptions

protected void printEmbeddedReportWithOptions(IAnalysisReport out,
                                              java.lang.String title,
                                              IReport target,
                                              IReportOptions options,
                                              java.lang.String tag)
Utility method to invoke a report from another analyzer and include it in the current analyzer's report. This method assumes deals with any errors that might occur during report generation.

Parameters:
out - a AnalysisReport in which the target analyzer's report must be added
title - a title for the report to be included
target - an analyzer whose report is to be invoked
options - ReportOptions to be used for the included report
tag - a formatting tag for the title of this report, or null

printEmbeddedReport

protected void printEmbeddedReport(IAnalysisReport out,
                                   java.lang.String title,
                                   java.lang.String analyzerName,
                                   java.lang.Object parent,
                                   java.lang.String tag)
Utility method to invoke a report from another analyzer and include it in the current analyzer's report. This method handles the allocation of the target analyzer and deals with any errors that might occur.

Parameters:
out - a AnalysisReport in which the target analyzer's report must be added
title - a title for the report to be included
analyzerName - name of target analyzer whose report is to be include
parent - parent object for the target analyzer
tag - a formatting tag for the title of this report, or null

printEmbeddedReport

protected void printEmbeddedReport(IAnalysisReport out,
                                   java.lang.String title,
                                   IReport target,
                                   java.lang.String tag)
Utility method to invoke a report from another analyzer and include it in the current analyzer's report. This method assumes deals with any errors that might occur during report generation.

Parameters:
out - a AnalysisReport in which the target analyzer's report must be added
title - a title for the report to be included
target - an analyzer whose report is to be invoked
tag - a formatting tag for the title of this report, or null

printReportInfoHeader

protected void printReportInfoHeader(IAnalysisReport out)
Utility method to print a header for the current report, containing some basic information about the nature of this report. This header should only be used from top-level reports.

Parameters:
out - a AnalysisReport to receive the output

allocateReport

protected IAnalysisReport allocateReport(java.lang.Object refKey)
Create and initialize the default type of AnalysisReport object used by Analyzers using this infrastructure.

Parameters:
refKey - a reference key that can be used in calls to printIdent() that reference this report
Returns:
a new AnalysisReport object

allocateSecondaryReport

protected IAnalysisReport allocateSecondaryReport(java.lang.String sectionName,
                                                  java.lang.Object refKey)
Create and initialize an AnalysisReport object suitable for holding a secondary report, to be included as a sub-section of the main report from an Analyzer.

Parameters:
sectionName - the name for this sub-section in the main report
refKey - a reference key that can be used in calls to printIdent() that reference this report
Returns:
a new AnalysisReport object

allocateReportOptions

protected static IReportOptions allocateReportOptions()
Create and initialize the default type of ReportOptions object used by Analyzers using this infrastructure.

Returns:
a new ReportOptions object

getReportExtensionHelper

protected static ReportExtensionHelper getReportExtensionHelper()
Returns:
a reference to a ReportExtensionHelper object, suitable for managing report extensions used by or declared by this analyzer.


© Copyright IBM Corp. 2007, 2008 All Rights Reserved. US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.