1 5 package org.prevayler.implementation.clock; 6 7 import java.util.Date ; 8 9 import org.prevayler.Clock; 10 11 public class PausableClock implements Clock { 12 13 private final Clock _realClock; 14 private final BrokenClock _brokenClock = new BrokenClock(); 15 private Clock _activeClock; 16 17 18 public PausableClock(Clock realClock) { 19 _realClock = realClock; 20 resume(); 21 } 22 23 public Date time() { return _activeClock.time(); } 24 25 public void pause() { 26 advanceTo(_realClock.time()); 27 _activeClock = _brokenClock; 28 } 29 30 public void advanceTo(Date time) { 31 _brokenClock.advanceTo(time); 32 } 33 34 public void resume() { _activeClock = _realClock; } 35 36 public Date realTime() { return _realClock.time(); } 37 } 38 | Popular Tags |