public interface Tracker
Tracker tracker = ...
tracker.moveTo("Started);
someObject.invokeMethod();
tracker.moveTo("Finished");
The above code tells the tracker to move to the "Start" state, invoke the
method, and finally move to the "Finished" state.
invoke method
| Start | --------------------> | Finished |
Not all invocations may succeed - so callers may catch the exception thrown
in their code, and move the tracker to a different state such as:
Tracker tracker = ...
tracker.moveTo("Started);
try {
someObject.invokeMethod();
} catch ( SomeException ex ) {
tracker.moveTo("Failed");
throw ex;
}
tracker.moveTo("Finished");
The above code treats the exception as fatal - so the last transition is not
called.
Data collected by the tracker are retrievable and may serve as an audit
trail for observing execution flow.Modifier and Type | Method and Description |
---|---|
void |
addChild(String trackerId)
Register a child to the document associated with the tracker
|
void |
addParent(String trackerId)
Register a parent to the document associated with the tracker
|
default void |
debug(String message)
Logs message as
DEBUG |
default void |
error(String message)
Logs message as
ERROR |
default String |
get(String key) |
String |
getOrDefault(String key,
String defaultValue) |
String |
id() |
default void |
info(String message)
Logs message as
INFO |
void |
log(String type,
String message)
Logs the
message under the type as level |
void |
moveTo(Document.State state,
byte[] content)
Tells the tracker to move to the
state , using state as name,
and then associates the content to it. |
void |
moveTo(Document.State state,
Throwable throwable)
Tells the tracker to move to
state , and associates the stacktrace of the
throwable |
default void |
moveTo(String state)
Tells the tracker to move the
state |
default void |
moveTo(String stateName,
byte[] content)
Tells the tracker to move to the
state , using state as name,
and then associates the content to it. |
default void |
moveTo(String stateName,
Throwable throwable)
Tells the tracker to move to
state , and associates the stacktrace of the
throwable |
void |
put(String key,
String value)
Puts the
value in this context, associated with the key |
String |
remove(String key)
Removes the value associated with
key |
boolean |
removeChild(String trackerId)
Unregister a child from the document associated with the tracker
|
boolean |
removeParent(String trackerId)
Unregister a parent from the document associated with the tracker
|
default void |
warn(String message)
Logs message as
WARN |
String id()
default void moveTo(String state)
state
default void moveTo(String stateName, byte[] content)
state
, using state
as name,
and then associates the content
to it.void moveTo(Document.State state, byte[] content)
state
, using state
as name,
and then associates the content
to it.default void moveTo(String stateName, Throwable throwable)
state
, and associates the stacktrace of the
throwable
void moveTo(Document.State state, Throwable throwable)
state
, and associates the stacktrace of the
throwable
default void info(String message)
INFO
default void warn(String message)
WARN
default void error(String message)
ERROR
default void debug(String message)
DEBUG
String getOrDefault(String key, String defaultValue)
key
, or defaultValue
String remove(String key)
key
key
, or null
void addParent(String trackerId)
trackerId
- The id of the tracker to be set as a parentboolean removeParent(String trackerId)
trackerId
- The id of the parent to be unregisteredvoid addChild(String trackerId)
trackerId
- The id of the tracker to be set as a childboolean removeChild(String trackerId)
trackerId
- The id of the child to be unregisteredCopyright © 2023. All rights reserved.