| Overview | Package | Class | Tree | Deprecated | Index | Help | |||
| PREV CLASS | NEXT CLASS | FRAMES | NO FRAMES | ||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||
java.lang.Object | +--ncsa.horizon.util.Metarunner
To make this object do anything useful, one must sub-class it and override the getDatum() method. (One should not override the run() method which, in addition to calling the getDatum() method, updates internal data regarding its execution history.) The user then has several ways to fetch and return a value:
This class is provided as part of support for metadata within Metadata objects. For example, some metadata may be costly to load into memory if it needs to be downloaded from the network or it requires an expensive computation. This effort may be wasted if the user never asks for the data. The Metadata class provides a mechanism for one to store procedures, in the form of Metarunner objects, for obtaining metadata. The Metarunner is then tranparently executed by the Metadata object when the user first requests the data.
To make use of this capability, programmers should sub-class the
Metarunner class, overridding the getDatum() method to fetch and return
the value of the metadatum works for. The Metarunner object should then
stored in the Metadata
object using the name of metadatum appended with the String
Metadata.METARUNNER_TAG. When the user later requests the metadatum,
the Metadata object first
looks for a static value in its hashtable. If it does not exist, then the
Metadata object engages the
surrogate Metarunner object to fetch the value. If the getDatum() method
returns with a status of OK, the
Metadata store the returned
value as a static value in its list before passing it on to its client.
If getDataum() returns RUN_PROBLEM, the
Metadata object does not
store the returned value, though it does return the value to the client.
Any other status from getDatum() will cause null to be
returned to the Metadata
object. See the Metadata
API for more details.
| Field Summary | |
| int | errState
value of the error state resulting from the last execution of this Runnable |
| java.lang.Boolean | isrunning
true if this Runnable is currently being executed. |
| java.lang.Object | lastValue
value of metadatum from the last time this Runnable was executed |
| static int | OK
error state: no error occurred |
| static int | RUN_FAILED
error state: runnable encountered an application-specific error |
| static int | RUN_PROBLEM
error state: runnable encountered an application-specific error; however, a usuable or default value has been returned. |
| int | runCount
true if this Runnable has been executed at least once since being instantiated. |
| static int | THREAD_FAILED
error state: failed to initiate or complete execution of Thread |
| Constructor Summary | |
| Metarunner()
construct a Metarunner object |
|
| Method Summary | |
| static java.lang.Object | fetchDatum(Metarunner fetcher)
create a Thread, execute the specified Metarunnable, wait for its completion, then return the result. |
| ValueAndStatus | getDatum()
calculate, read, or make up a value for a piece of data. |
| int | getErrorState()
return the error state resulting from the last time this runnable was executed. |
| java.lang.Object | getLastValue()
return the value from the last time this runnable was executed |
| int | getRunCount()
return the number of times this runnable has been fully executed via the run() method. |
| boolean | hasRun()
return true if this runnable has been fully executed via the run() method at least once. |
| boolean | isRunning()
return true if this runnable is currently being run by some thread |
| void | run()
execute this Runnable. |
| Methods inherited from class java.lang.Object | |
| clone, equals, finalize, getClass, hashCode, notifyAll, notify, toString, wait, wait, wait | |
| Field Detail |
public static final int OK
public static final int RUN_PROBLEM
public static final int THREAD_FAILED
public static final int RUN_FAILED
protected java.lang.Object lastValue
protected java.lang.Boolean isrunning
protected int runCount
protected int errState
| Constructor Detail |
public Metarunner()
| Method Detail |
public boolean isRunning()
public int getErrorState()
public java.lang.Object getLastValue()
public boolean hasRun()
public int getRunCount()
public void run()
public ValueAndStatus getDatum()
throws java.lang.Exception
public static java.lang.Object fetchDatum(Metarunner fetcher)
| Overview | Package | Class | Tree | Deprecated | Index | Help | |||
| PREV CLASS | NEXT CLASS | FRAMES | NO FRAMES | ||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||