Java Reference
In-Depth Information
private
Trackable target
#
null
;
// a copy of a recoverable object
private
String targetRef;
// the label identifying a recoverable object
private
String methodName; // the name of a method
private
String when;
// a label assuming values "before" and "after"
public
Entry(Trackable target, String methodName,
String when) {
this
.target
#
target.cloneTarget();
this
.targetRef
#
Tracker.getObjectRef(target);
this
.methodName
#
methodName;
this
.when
#
when;
}
public
Trackable getTarget() {
return
target; }
public
String getTargetRef() {
return
targetRef; }
public
String toString() {
return
targetRef
!
"."
!
methodName
!
"() - "
!
when;
}
}
Class
Tracker
is the service component that implements the function-
alities for managing application recovery. It uses two distinct files to save
stable states and state changes. The first is opened when a stable state is
saved, the second when method
startTracking()
is invoked, i.e. when the
application is started and when a new stable state is saved.
Member variable
recording
assumes the value
true
when
Tracker
is record-
ing state changes and
false
when
Tracker
is redoing operations. Member vari-
able
objectList
is a hash table that records the references to all the trackable
objects that have been registered with method
bind()
along with their unique
string identifiers. Member variable
entrytList
records the list of
Entity
objects
loaded from the log file when the application is restarted or its operations are
undone or redone.
public final class
Tracker {
private static int
currentEntry
#
0;
private static
FileOutputStream outputFile
#
null
;
private static
ObjectOutputStream outputObject
#
null
;
private static
Hashtable objectList
#
new
Hashtable();
private static
ArrayList entryList
#
new
ArrayList();
public static final
String BEFORE
#
"before";
public static final
String AFTER
#
"after";
public static void
startTracking() {
try
{
outputFile
#
new
FileOutputStream
("trackerPhysical.log");