+public class TransactionChainProxy implements DOMStoreTransactionChain {
+
+ private static final Logger LOG = LoggerFactory.getLogger(TransactionChainProxy.class);
+
+ private interface State {
+ boolean isReady();
+
+ List<Future<ActorSelection>> getPreviousReadyFutures();
+ }
+
+ private static class Allocated implements State {
+ private final ChainedTransactionProxy transaction;
+
+ Allocated(ChainedTransactionProxy transaction) {
+ this.transaction = transaction;
+ }
+
+ @Override
+ public boolean isReady() {
+ return transaction.isReady();
+ }
+
+ @Override
+ public List<Future<ActorSelection>> getPreviousReadyFutures() {
+ return transaction.getReadyFutures();
+ }
+ }
+
+ private static abstract class AbstractDefaultState implements State {
+ @Override
+ public List<Future<ActorSelection>> getPreviousReadyFutures() {
+ return Collections.emptyList();
+ }
+ }
+
+ private static final State IDLE_STATE = new AbstractDefaultState() {
+ @Override
+ public boolean isReady() {
+ return true;
+ }
+ };
+
+ private static final State CLOSED_STATE = new AbstractDefaultState() {
+ @Override
+ public boolean isReady() {
+ throw new TransactionChainClosedException("Transaction chain has been closed");
+ }
+ };
+
+ private static final AtomicInteger counter = new AtomicInteger(0);
+