com.philemonworks.selfdiagnose
Class DiagnosticTask

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

public abstract class DiagnosticTask
extends java.lang.Object
implements java.io.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
 java.lang.String comment
          Used to explain the task in both the log and the configuration.
static java.lang.String PARAMETER_COMMENT
           
static java.lang.String PARAMETER_VARIABLE
           
protected  java.lang.String requestor
           
 java.lang.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.
 java.lang.String getComment()
           
 java.lang.String getDefaultReportTemplate(boolean isSuccess)
          User-defined Diagnostic Task subclasses should redefine this method to provide reporttemplates for both a successful and failed run.
abstract  java.lang.String getDescription()
           
 java.lang.String getRequestor()
          Return the identifier for the object that created and will register this task.
 java.lang.String getTaskName()
          On default, the task is the unqualified name for the class in lowercase.
 java.lang.String getVariableName()
           
 boolean hasComment()
           
 void initializeFromAttributes(org.xml.sax.Attributes attributes)
          This method is sent from the SelfDiagnoseHandler when a configuration is being processed.
 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(java.lang.String comment)
           
 void setRequestor(java.lang.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(java.lang.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 java.lang.String PARAMETER_VARIABLE
See Also:
Constant Field Values

PARAMETER_COMMENT

public static final java.lang.String PARAMETER_COMMENT
See Also:
Constant Field Values

requestor

protected java.lang.String requestor

variableName

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


comment

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

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 java.lang.String getDescription()
Returns:
String the description

getTaskName

public java.lang.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 java.lang.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(java.lang.String identifier)
Set the identifier for the object that created and registered this task.

Parameters:
identifier -

initializeFromAttributes

public void initializeFromAttributes(org.xml.sax.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 java.lang.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 java.lang.String getVariableName()
Returns:
String

setVariableName

public void setVariableName(java.lang.String varName)
Parameters:
varName - : String

hasComment

public boolean hasComment()

getComment

public java.lang.String getComment()

setComment

public void setComment(java.lang.String comment)


Copyright © 2008. All Rights Reserved.