uk.org.ogsadai.engine
Class ProcessingStatus

java.lang.Object
  |
  +--java.util.Observable
        |
        +--uk.org.ogsadai.engine.ProcessingStatus

public class ProcessingStatus
extends java.util.Observable

An Observable class encapsulating the state of processing of OGSA-DAI entities, such as Request or Activity objects.

Instances of this class are implemented as Observable wrappers around a ProcessingStatus field. Observer implementations can be registered and they will each be updated every time the status is changed using the setXYZ methods.

Each instance of this class is regarded as being "owned" by the object for which it acts as status. This "owner" object, which may not be 'null', is made known to the instance at construction time. A reference to the owner object is then subsequently passed to observers as the second argument of their update() method.

A rich set of predicates is provided to establish:

The present implementation uses synchronised methods for thread-safety.

Author:
The OGSA-DAI Project Team

Field Summary
private static?java.lang.String COPYRIGHT_NOTICE
??????????Copyright statement
private ?java.lang.Object mOwner
??????????Object whose status is provided by this instance.
private ?ProcessingState mState
??????????Current state.
?
Fields inherited from class java.util.Observable
?
Constructor Summary
ProcessingStatus(java.lang.Object?owner)
??????????Constructs an instance of this class using a given owner object.
ProcessingStatus(java.lang.Object?owner, ProcessingState?initialState)
??????????Constructs an instance of this class using a given owner object and initial state.
?
Method Summary
?void copyState(ProcessingStatus?status)
??????????Copies the state of the specified ProcessingStatus object to that of this ProcessingStatus object.
?boolean isActive()
??????????Indicates whether the owner object is being initialised or processed.
?boolean isCompleted()
??????????Indicates whether processing has completed on the owner object.
?boolean isError()
??????????Indicates whether the owner object has stopped processing due to errors.
?boolean isInitialising()
??????????Indicates whether initialisation is being carried out on the object for which this instance acts as status.
?boolean isLive()
??????????Indicates whether the owner object is still processing or pending initialisation.
?boolean isProcessing()
??????????Indicates whether initialisation is complete and processing has commenced.
?boolean isStopped()
??????????Indicates whether all processing has stopped on the owner object.
?boolean isTerminated()
??????????Indicates whether the processing of the owner object has been externally terminated.
?boolean isTimedOut()
??????????Indicates whether processing of the owner object has timed out.
?boolean isUnstarted()
??????????Indicates whether the owner object remains uninitialised.
?void setCompleted()
??????????Updates the status to reflect that the onwer object has completed processing.
?void setError()
??????????Updates the status to reflect that the initialisation or processing of the onwer object has yielded errors.
?void setInitialising()
??????????Updates the status to reflect that the onwer object is being initialised.
?void setProcessing()
??????????Updates the status to reflect that the onwer object is being actively processed.
private ?void setState(ProcessingState?nextState)
??????????Effects an internal change of state.
?void setTerminated()
??????????Updates the status to reflect that the onwer object has been terminated.
?void setTimedOut()
??????????Updates the status to reflect that the onwer object has been timed out.
?java.lang.String toString()
??????????Provides a textual rendition of the current state.
?
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
?
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
?

Field Detail

COPYRIGHT_NOTICE

private static final java.lang.String COPYRIGHT_NOTICE
Copyright statement

See Also:
Constant Field Values

mState

private ProcessingState mState
Current state.


mOwner

private java.lang.Object mOwner
Object whose status is provided by this instance.

Constructor Detail

ProcessingStatus

public ProcessingStatus(java.lang.Object?owner,
                        ProcessingState?initialState)
                 throws java.lang.IllegalArgumentException
Constructs an instance of this class using a given owner object and initial state.

Parameters:
owner - the object for which the new instance acts as status
initialState - the state with which to initialise the new instance
Throws:
java.lang.IllegalArgumentException - if either of the two parameters is null

ProcessingStatus

public ProcessingStatus(java.lang.Object?owner)
                 throws java.lang.IllegalArgumentException
Constructs an instance of this class using a given owner object. The instance produced reflects an initial state of ProcessingState.UNSTARTED.

Parameters:
owner - the object for which the new instance acts as status
Throws:
java.lang.IllegalArgumentException - if the supplied argument is null
Method Detail

setState

private void setState(ProcessingState?nextState)
Effects an internal change of state.

Parameters:
nextState - the target state to which a transition is made.

isStopped

public boolean isStopped()
Indicates whether all processing has stopped on the owner object.

Returns:
true if processing has stopped, either normally or as a result of errors, termination or timing out; false otherwise.

isLive

public boolean isLive()
Indicates whether the owner object is still processing or pending initialisation.

Returns:
true if processing is as yet unstarted or ongoing; false otherwise.

isActive

public boolean isActive()
Indicates whether the owner object is being initialised or processed.

Returns:
true if processing is ongoing (i.e., the processing entity is initialising or being processed); false otherwise.

isCompleted

public final boolean isCompleted()
Indicates whether processing has completed on the owner object.

Returns:
true if and only if the current state is ProcessingState.COMPLETED.

isError

public final boolean isError()
Indicates whether the owner object has stopped processing due to errors.

Returns:
true if and only if the current state is ProcessingState.ERROR.

isTimedOut

public final boolean isTimedOut()
Indicates whether processing of the owner object has timed out.

Returns:
true if and only if the current state is ProcessingState.TIMEDOUT.

isUnstarted

public final boolean isUnstarted()
Indicates whether the owner object remains uninitialised.

Returns:
true if and only if the current state is ProcessingState.UNSTARTED.

isInitialising

public final boolean isInitialising()
Indicates whether initialisation is being carried out on the object for which this instance acts as status.

Returns:
true if and only if the current state is ProcessingState.INITIALISING.

isProcessing

public final boolean isProcessing()
Indicates whether initialisation is complete and processing has commenced.

Returns:
true if and only if the current state is ProcessingState.PROCESSING.

isTerminated

public final boolean isTerminated()
Indicates whether the processing of the owner object has been externally terminated.

Returns:
true if and only if the current state is ProcessingState.TERMINATED.

setInitialising

public void setInitialising()
                     throws java.lang.IllegalStateException
Updates the status to reflect that the onwer object is being initialised.

Throws:
java.lang.IllegalStateException - if the current status indicates that initialisation has already commenced or completed.

setProcessing

public void setProcessing()
                   throws java.lang.IllegalStateException
Updates the status to reflect that the onwer object is being actively processed.

Throws:
java.lang.IllegalStateException - if the current status indicates that processing has already commenced or completed.

setCompleted

public void setCompleted()
                  throws java.lang.IllegalStateException
Updates the status to reflect that the onwer object has completed processing.

Throws:
java.lang.IllegalStateException - if the current status indicates that processing has already completed, either normally or otherwise.

setError

public void setError()
              throws java.lang.IllegalStateException
Updates the status to reflect that the initialisation or processing of the onwer object has yielded errors.

Throws:
java.lang.IllegalStateException - if the current status indicates that the owner object is already inactive.

setTerminated

public void setTerminated()
                   throws java.lang.IllegalStateException
Updates the status to reflect that the onwer object has been terminated.

Throws:
java.lang.IllegalStateException - if the current status indicates that all activity on the owner object has already stopped, either normally or otherwise.

setTimedOut

public void setTimedOut()
Updates the status to reflect that the onwer object has been timed out.

Throws:
java.lang.IllegalStateException - if the current status indicates that all activity on the owner object has already stopped, either normally or otherwise.

toString

public java.lang.String toString()
Provides a textual rendition of the current state.

Overrides:
toString in class java.lang.Object
Returns:
a String object encoding the current state, e.g., "INITIALISING" or "TIMEDOUT".
See Also:
ProcessingState

copyState

public void copyState(ProcessingStatus?status)
Copies the state of the specified ProcessingStatus object to that of this ProcessingStatus object.

Parameters:
status - the status to copy