Java Reference
In-Depth Information
if
(entryID < currentEntry)
restore(); // restores the last saved stable state
tracking
#
false
; // disables the tracking process
while
(entryID > currentEntry){
Entry entry
#
(Entry) entryList.get(currentEntry);
Target target
#
(Trackable)
objectList.get(entry.getTargetRef());
if
(logicalRecording)
entry.invoke(target);
else
target.restore(entry.getTarget());
currentEntry
!!
;
}
tracking
#
true
; // enables the tracking process
}
}
18.5.4
Test
We need to test the logical recording functionalities in two scenarios: logical
recording of simple operations and logical recording of complex operations.
Figure 18.4 shows a snapshot of the puzzle application, where the tracking
console displays the sequence of simple operations performed on the three
instances of class
Tower
. The code below exemplifies logical recording of
pull()
and
push()
methods invocation of class
Tower
.
package
hanoi;
import
recap.*;
import
java.io.*;
public class
Tower
implements
Trackable {
. . .
public
Tower() { }
Figure 18.4
The Tower of Hanoi after the re-execution of simple operation
push()
.
Copyright © 2005 Sun Microsystems, Inc. All rights reserved. Reproduced by permission of Sun
Microsystems, Inc.