Command pattern can be used to implement Transactional behavior
(and Undo
).
But I could not find an example of these by googling. I could only find
public final class Ping implements Callable {
private final InetAddress peer;
public Ping(final InetAddress peer) {
this.peer = peer;
}
public Boolean call() {
/* do the ping */
...
}
}
...
final Future result
= executorService.submit(new Ping(InetAddress.getByName("google.com")));
System.out.println("google.com is " + (result.get() ? "UP" : "DOWN"));