com.philemonworks.selfdiagnose
Class DiagnosticTask

java.lang.Object
  extended by com.philemonworks.selfdiagnose.DiagnosticTask
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
CheckClassLoadable, CheckDatabaseTableExists, CheckDatasourceConnectable, CheckDirectoryAccessible, CheckEndecaService, CheckFileContainsString, CheckJNDIBinding, CheckPropertyValuesAreJavaTypes, CheckResourceAccessible, CheckResourceBundleKey, CheckSpringDatasourceConnectable, CheckValidURL, CheckXMLContent, CollectionIteratorTask, CustomDiagnosticTask, PatternMatchingTask, ReportJamonMonitors, ReportJVMRuntimeMemory

public abstract class DiagnosticTask
extends Object
implements Serializable

DiagnosticTask is the abstract class for all tasks that can be registered with SelfDiagnose. Typically tasks are parameterized in order to run. Tasks may want to re-implement the setUp method in which parameter verification should be done.

Author:
emicklei
See Also:
Serialized Form

Field Summary
 String comment
          Used to explain the task in both the log and the configuration.
static String PARAMETER_COMMENT
           
static String PARAMETER_REPORT
           
static String PARAMETER_VARIABLE
           
 boolean reportResults
          Indication for whether the receiver will report the result.
protected  String requestor
           
 String variableName
          Name of the reference that refers to the value of the property.
 
Constructor Summary
DiagnosticTask()
           
 
Method Summary
 DiagnosticTaskResult createResult()
          Return an object to store the results of running the receiver.
 String getComment()
           
 String getDefaultReportTemplate(boolean isSuccess)
          User-defined Diagnostic Task subclasses should redefine this method to provide reporttemplates for both a successful and failed run.
abstract  String getDescription()
           
 String getRequestor()
          Return the identifier for the object that created and will register this task.
 String getTaskName()
          On default, the task is the unqualified name for the class in lowercase.
 String getVariableName()
           
 boolean hasComment()
           
 void initializeFromAttributes(Attributes attributes)
          This method is sent from the SelfDiagnoseHandler when a configuration is being processed.
 boolean isReportResults()
           
 DiagnosticTaskResult run()
          Run the task and answer the result.
 DiagnosticTaskResult run(ExecutionContext ctx)
          Run the task and answer the result.
abstract  void run(ExecutionContext ctx, DiagnosticTaskResult result)
          Run the task.
 void setComment(String comment)
           
 void setReportResults(boolean reportResults)
           
 void setRequestor(String identifier)
          Set the identifier for the object that created and registered this task.
 void setUp(ExecutionContext ctx)
          Override this method to verify that task parameters are initialized/set correctly.
 void setVariableName(String varName)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PARAMETER_VARIABLE

public static final String PARAMETER_VARIABLE
See Also:
Constant Field Values

PARAMETER_COMMENT

public static final String PARAMETER_COMMENT
See Also:
Constant Field Values

PARAMETER_REPORT

public static final String PARAMETER_REPORT
See Also:
Constant Field Values

requestor

protected String requestor

variableName

public String variableName
Name of the reference that refers to the value of the property.


comment

public String comment
Used to explain the task in both the log and the configuration.


reportResults

public boolean reportResults
Indication for whether the receiver will report the result.

Constructor Detail

DiagnosticTask

public DiagnosticTask()
Method Detail

createResult

public DiagnosticTaskResult createResult()
Return an object to store the results of running the receiver.

Returns:
DiagnosticTaskResult

getDescription

public abstract String getDescription()
Returns:
String the description

getTaskName

public String getTaskName()
On default, the task is the unqualified name for the class in lowercase. This name must be equal to that of the complexType as defined in the XSD.

Returns:
String the name for this task

getRequestor

public String getRequestor()
Return the identifier for the object that created and will register this task.

Returns:
String

setUp

public void setUp(ExecutionContext ctx)
           throws DiagnoseException
Override this method to verify that task parameters are initialized/set correctly.

Parameters:
ctx - ExecutionContext
Throws:
DiagnoseException

run

public DiagnosticTaskResult run()
Run the task and answer the result.

Returns:
DiagnosticTaskResult

run

public DiagnosticTaskResult run(ExecutionContext ctx)
Run the task and answer the result.

Parameters:
ctx - : ExecutionContext
Returns:
DiagnosticTaskResult

run

public abstract void run(ExecutionContext ctx,
                         DiagnosticTaskResult result)
                  throws DiagnoseException
Run the task. If an error is detected then raise a DiagnoseException. Otherwise use the result object to the report any messages when a run is completed.

Parameters:
ctx - ExecutionContext
result - DiagnosticTaskResult
Throws:
DiagnoseException

setRequestor

public void setRequestor(String identifier)
Set the identifier for the object that created and registered this task.

Parameters:
identifier -

initializeFromAttributes

public void initializeFromAttributes(Attributes attributes)
This method is sent from the SelfDiagnoseHandler when a configuration is being processed. Use the passed attributes to initialize the receiver. If a variable parameter is passed then store it.

Parameters:
attributes - org.xml.sax.Attributes

getDefaultReportTemplate

public String getDefaultReportTemplate(boolean isSuccess)
User-defined Diagnostic Task subclasses should redefine this method to provide reporttemplates for both a successful and failed run. This is only needed if the task uses the method DiagnoseUtil.report(DiagnosticTaskResult result, boolean isSucces, ...).

Parameters:
isSuccess - result of running the task
Returns:
String containing one or more template arguments such as {0}

getVariableName

public String getVariableName()
Returns:
String

setVariableName

public void setVariableName(String varName)
Parameters:
varName - : String

hasComment

public boolean hasComment()

getComment

public String getComment()

setComment

public void setComment(String comment)

isReportResults

public boolean isReportResults()

setReportResults

public void setReportResults(boolean reportResults)


Copyright © 2012. All Rights Reserved.