org.jasig.portal.tools.checks
Class ClassPresenceCheck

java.lang.Object
  extended by org.jasig.portal.tools.checks.ClassPresenceCheck
All Implemented Interfaces:
ICheck

public class ClassPresenceCheck
extends java.lang.Object
implements ICheck

Checks that a class named as a constructor argument is present.

Since:
uPortal 2.5
Version:
$Revision: 1.1 $ $Date: 2005/05/20 19:01:34 $

Field Summary
private  java.lang.String checkDescription
          A String describing this check.
private  CheckResult failureResult
          The CheckResult we will return if our target class is not present.
protected  org.apache.commons.logging.Log log
           
private  CheckResult successResult
          The CheckResult we will return if our target class is present.
private  java.lang.String targetClass
          The class we will be looking for.
 
Constructor Summary
ClassPresenceCheck(java.lang.String targetClass)
          Each instance of ClassPresenceCheck exists to test for the presence of exactly one class.
 
Method Summary
 CheckResult doCheck()
          Perform an arbitrary check.
 java.lang.String getDescription()
          Get a description of what it is the check is intended to check.
(package private)  CheckResult getFailureResult()
          Get the CheckResult we will return when we fail to touch our configured targetClass.
(package private)  CheckResult getSuccessResult()
          Get the CheckResult we will return when we succeed in touching our configured targetClass.
(package private)  java.lang.String getTargetClass()
          Get the name of the class for which we check.
 void setDescription(java.lang.String description)
          Set the check description which we will return for on calls to the getDescription() method we're implementing as part of being an ICheck.
(package private)  void setFailureResult(CheckResult failureResult)
          Set the CheckResult we will return when we fail to touch our configured targetClass.
(package private)  void setSuccessResult(CheckResult successResult)
          Set the CheckResult we will return when we succeed in touching our configured targetClass.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected final org.apache.commons.logging.Log log

targetClass

private final java.lang.String targetClass
The class we will be looking for.


successResult

private CheckResult successResult
The CheckResult we will return if our target class is present. We populate this field with a default at construction and allow it to be overridden via a setter method.


failureResult

private CheckResult failureResult
The CheckResult we will return if our target class is not present. We populate this field with a default at costruction and allow it to be overridden via a setter method.


checkDescription

private java.lang.String checkDescription
A String describing this check. We populate this field with a default at construction and allow it to be overridden via a setter method.

Constructor Detail

ClassPresenceCheck

public ClassPresenceCheck(java.lang.String targetClass)
Each instance of ClassPresenceCheck exists to test for the presence of exactly one class. That class must be specified as the single required constructor argument, which must be a non-null String representing the fully qualified name of the class.

Parameters:
targetClass - fully qualified name of the target class
Throws:
java.lang.IllegalArgumentException - if targetClass is null
Method Detail

doCheck

public CheckResult doCheck()
Description copied from interface: ICheck
Perform an arbitrary check. The result of this method should be a CheckResult representing either a success or failure of the check. Implementations should catch their own exceptions and translate them into CheckResults representing failures, since the intent of this API is to translate arcane deployment issues into friendly results with remediation messages. However, the implementation of this method may throw any RuntimeException, and clients must cope with such exceptions. Cope with probably means translate it into a CheckResult representing a failure of this check. The client of a Check implementation will be less effective in translating a thrown Throwable into an intelligent CheckResult representing a failure than the Check would have been in doing this itself.

Specified by:
doCheck in interface ICheck
Returns:
a CheckResult representing the result of the check

getDescription

public java.lang.String getDescription()
Description copied from interface: ICheck
Get a description of what it is the check is intended to check. Implementations of this method must always return a non-null String and should not throw anything.

Specified by:
getDescription in interface ICheck
Returns:
a description of what it is that the check checks.

setDescription

public void setDescription(java.lang.String description)
Set the check description which we will return for on calls to the getDescription() method we're implementing as part of being an ICheck.

Parameters:
description -

getFailureResult

CheckResult getFailureResult()
Get the CheckResult we will return when we fail to touch our configured targetClass.

Returns:
CheckResult we will return on failure

setFailureResult

void setFailureResult(CheckResult failureResult)
Set the CheckResult we will return when we fail to touch our configured targetClass.

Parameters:
failureResult - desired CheckResult on failure

getSuccessResult

CheckResult getSuccessResult()
Get the CheckResult we will return when we succeed in touching our configured targetClass.

Returns:
CheckResult we will return on success.

setSuccessResult

void setSuccessResult(CheckResult successResult)
Set the CheckResult we will return when we succeed in touching our configured targetClass.

Parameters:
successResult - desired CheckResult on success.

getTargetClass

java.lang.String getTargetClass()
Get the name of the class for which we check.

Returns:
the fully qualified name of the class for which we check.