|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.ibm.are.plugin.BasePlugin
public abstract class BasePlugin
The BasePlugin
class is an abstract base class that implements much of the behavior
required for a Plugin
in the Application Runtime Expert. This class provides the
following set of implemented features available for use by any sub-class:
PluginReporting
interfacePlugin
interfaceRunnable
interface
Although this class implements the PluginReporting
interface, the actual implementation
is nothing more than delegating each reporting event to registered reporters. By default
there are three registered reporters: PlainTextReporter
,
XmlReporter
, and SummaryReporter
. Methods are
provided to replace the default reporters or add additional reporters.
Nested Class Summary | |
---|---|
class |
BasePlugin.ReporterCollection
|
Field Summary | |
---|---|
static java.lang.String |
COPYRIGHT
Copyright for class bytecode |
protected java.util.logging.Logger |
log
The logger associated with the plugin |
protected java.io.PrintWriter |
out
The output writer for the plugin |
protected PluginData |
pluginData
Data associated with the plugin. |
protected Version |
pluginVersion
The plugin's version |
protected BasePlugin.ReporterCollection |
reporter
Collection of reporters used to format and generate reports for the plugin |
protected ResultInfo |
result
The result value of running the plugin |
Fields inherited from interface com.ibm.are.report.Reporting |
---|
FORMAT_BINARY, FORMAT_HTML, FORMAT_PLAIN_TEXT, FORMAT_SERIALIZED, FORMAT_USER_DEFINED, FORMAT_XML, LEVEL_ERROR, LEVEL_INFO, LEVEL_NONE, LEVEL_WARNING, MAX_REPORT_DEPTH, MIN_REPORT_DEPTH |
Constructor Summary | |
---|---|
protected |
BasePlugin()
Constructs and initializes fields for a new plugin. |
Method Summary | |
---|---|
void |
addReporter(ReporterReporting reporter)
Add a reporter to this group |
com.ibm.are.core.ElementData |
getElementData()
|
protected java.lang.String |
getInput(java.lang.String prompt)
Retrieves an input value from standard input. |
java.util.logging.Logger |
getLogger()
Retrieves the logger associated with the plugin |
PluginData |
getPluginData()
Retrieves the plugin data associated with this plugin. |
PluginReporting |
getReporter()
Retrieves the reporter for the plugin |
java.io.PrintWriter |
getStandardOut()
Retrieves the standard output writer for the plugin. |
java.io.InputStream |
getTemplateResource(java.lang.String resName)
Answers a stream on a resource found by looking up 'resName' in the template. |
Version |
getVersion()
|
void |
init(java.util.List initArgs)
Any initialization that the plugin needs to do prior to running can be done in this method. |
protected boolean |
initOutput(java.lang.String outputFileName)
Initializes the plugin's out stream to the given file name. |
protected abstract Version |
initPluginVersion()
Used to initialize the plugin's pluginVersion field |
void |
removeAllReporters()
Removes all reporters |
void |
removeReporter(java.lang.String className)
Removes all reporters whose class name matches the given class name |
void |
report(java.lang.String msg,
int depth)
Report a message at the given level in the reporting hierarchy. |
ProblemContext |
report(java.lang.String msg,
java.lang.String errorLevel)
Report a message at the given error level during the runtime processing. |
ProblemContext |
report(java.lang.String msg,
java.lang.String errorLevel,
com.ibm.are.autofix.FixAction fixAction)
Report a message at the given error level during the runtime processing, with info about how to fix the problem. |
ProblemContext |
reportError(java.lang.String msg)
Report an error message during the runtime processing. |
ProblemContext |
reportError(java.lang.String msg,
com.ibm.are.autofix.FixAction fixAction)
Report an error message during the runtime processing, with info about how to fix the problem. |
void |
reportFinish(com.ibm.are.core.Element elem,
ResultInfo result)
Reports the result of the runtime processing for a plugin. |
ProblemContext |
reportInfo(java.lang.String msg)
Report an informational message during the runtime processing. |
ProblemContext |
reportInfo(java.lang.String msg,
com.ibm.are.autofix.FixAction fixAction)
Report an informational message during the runtime processing, with info about how to fix the problem. |
void |
reportStart(com.ibm.are.core.Element elem)
Reports the start of a plugin |
void |
reportStatistic(java.lang.String description,
java.lang.Object value,
int depth)
Reports an interesting or very important statistic. |
void |
reportStep(java.lang.String msg)
Reports a new step in the runtime processing. |
void |
reportStepDetail(java.lang.String msg)
Reports a new step detail in the runtime processing. |
void |
reportSubStep(java.lang.String msg)
Reports a new sub step in the runtime processing. |
void |
reportSubStepDetail(java.lang.String msg)
Reports a new sub step detail in the runtime processing. |
ProblemContext |
reportWarning(java.lang.String msg)
Report a warning message during the runtime processing. |
ProblemContext |
reportWarning(java.lang.String msg,
com.ibm.are.autofix.FixAction fixAction)
Report a warning message during the runtime processing, with info about how to fix the problem. |
ResultInfo |
result()
Retrieves the result of the plugin being run. |
void |
run()
This method is used to bookend the real implementation of the plugin, the runImpl() method. |
protected abstract ResultInfo |
runImpl()
The implementation of the plugin. |
void |
setElementData(com.ibm.are.core.ElementData newData)
|
void |
setLogger(java.util.logging.Logger appLogger)
Sets the logger to be used for logging events |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface com.ibm.are.core.Element |
---|
getCommonName, getDescription |
Field Detail |
---|
public static final java.lang.String COPYRIGHT
protected java.io.PrintWriter out
protected java.util.logging.Logger log
protected Version pluginVersion
protected PluginData pluginData
protected ResultInfo result
protected BasePlugin.ReporterCollection reporter
Constructor Detail |
---|
protected BasePlugin()
Method Detail |
---|
public void init(java.util.List initArgs)
init
in interface Plugin
initArgs
- Initialization arguments. Currently the core does not
pass any arguments upon initialization, so this list will
always be empty.public ResultInfo result()
result
in interface Plugin
public com.ibm.are.core.ElementData getElementData()
getElementData
in interface com.ibm.are.core.Element
public void setElementData(com.ibm.are.core.ElementData newData)
setElementData
in interface com.ibm.are.core.Element
public final PluginReporting getReporter()
getReporter
in interface Plugin
PluginReporting
public Version getVersion()
getVersion
in interface com.ibm.are.core.Element
public PluginData getPluginData()
PluginData
public void setLogger(java.util.logging.Logger appLogger)
appLogger
- The logger to be usedpublic java.util.logging.Logger getLogger()
getLogger
in interface Plugin
public java.io.PrintWriter getStandardOut()
getStandardOut
in interface Plugin
public final ProblemContext reportInfo(java.lang.String msg)
reportInfo
in interface PluginReporting
msg
- The message to print
public final ProblemContext reportInfo(java.lang.String msg, com.ibm.are.autofix.FixAction fixAction)
reportInfo
in interface PluginReporting
msg
- The message to printfixAction
- The info about how to fix the problem.
public final ProblemContext reportWarning(java.lang.String msg)
reportWarning
in interface PluginReporting
msg
- The message to print
public final ProblemContext reportWarning(java.lang.String msg, com.ibm.are.autofix.FixAction fixAction)
reportWarning
in interface PluginReporting
msg
- The message to printfixAction
- The info about how to fix the problem.
public final ProblemContext reportError(java.lang.String msg)
reportError
in interface PluginReporting
msg
- The message to print
public final ProblemContext reportError(java.lang.String msg, com.ibm.are.autofix.FixAction fixAction)
reportError
in interface PluginReporting
msg
- The message to printfixAction
- The info about how to fix the problem.
public final ProblemContext report(java.lang.String msg, java.lang.String errorLevel, com.ibm.are.autofix.FixAction fixAction)
report
in interface PluginReporting
msg
- The message to printerrorLevel
- The error level to use when reportingfixAction
- The info about how to fix the problem.
public final void reportStatistic(java.lang.String description, java.lang.Object value, int depth)
reportStatistic
in interface StatusReporting
description
- A description of the statistic being reportedvalue
- The (statistic) value to reportdepth
- The depth in the status reporting hierarchy where the statistic will be reportedpublic final void reportStep(java.lang.String msg)
reportStep
in interface StatusReporting
msg
- The message to reportpublic final void reportStepDetail(java.lang.String msg)
reportStepDetail
in interface StatusReporting
msg
- The message to reportpublic final void reportSubStep(java.lang.String msg)
reportSubStep
in interface StatusReporting
msg
- The message to reportpublic final void reportSubStepDetail(java.lang.String msg)
reportSubStepDetail
in interface StatusReporting
msg
- The message to reportpublic void addReporter(ReporterReporting reporter)
reporter
- The reporter to be addedpublic void removeReporter(java.lang.String className)
className
- The package and class name of the reporter to removepublic void removeAllReporters()
public final ProblemContext report(java.lang.String msg, java.lang.String errorLevel)
report
in interface PluginReporting
msg
- The message to printerrorLevel
- The error level to use when reporting
public final void report(java.lang.String msg, int depth)
report
in interface StatusReporting
msg
- The message to printdepth
- The level within the reporting hierarchy. If this
parameter were set to 1 it would be equivalent to
invoking the StatusReporting.reportStep(String)
method.
The valid value ranges from MIN_REPORT_DEPTH (include) to
MAN_REPORT_DEPTH (include).public final void reportStart(com.ibm.are.core.Element elem)
reportStart
in interface StatusReporting
elem
- The plugin that is startingpublic final void reportFinish(com.ibm.are.core.Element elem, ResultInfo result)
reportFinish
in interface StatusReporting
result
- The resultpublic final void run()
runImpl()
method. By bookending the actual
implementation of the plugin, this method provides the base class
a way to perform standard "pre" and "post" run operations for every
plugin, thus freeing plugin developers from having to perform a
set of standardized tasks at the beginning and end of their plugins.
run
in interface Plugin
run
in interface java.lang.Runnable
protected abstract Version initPluginVersion()
protected abstract ResultInfo runImpl()
run()
method. Subclasses put their implementation of the
plugin in this method.
protected java.lang.String getInput(java.lang.String prompt)
prompt
- The message to display when prompting for input
protected boolean initOutput(java.lang.String outputFileName)
outputFileName
- The name of the output file. If the
input file name is null or equal to "stdout" the output stream
is initialized to standard out.
public java.io.InputStream getTemplateResource(java.lang.String resName)
null
is returned.
Note that this method is based on the class loader of this (BasePlugin) class. Normally it's the default class loader and resource out side of the template jar can also be found if a resource with the same name exists in any jar listed in the classpath. However this method is provided as a helper method intended for easy retrieval of resource within the same template which contains the caller plugin.
Example:
InputStream is = myPlugin.getTemplateResource("xml/myConfig.xml");
resName
- String
the name of the resource to find.
null
if the resource cannot be foundClass.getResourceAsStream(String resName)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |