@Test (expected = RuntimeException.class) public void testTransactionWithoutInitAndStart() throws Exception { transaction.startTransaction(); }
public void startTransaction() { synchronized (transactionLock) { if (!transactionState.compareAndSet(TransactionState.STOPED, TransactionState.READY) && !transactionState.compareAndSet(TransactionState.INIT, TransactionState.READY)) { throw new RuntimeException("We are already in transaction state"); } doStartTransaction(); } }
Transaction { public void startTransaction() { synchronized (transactionLock) { if (!transactionState.compareAndSet(TransactionState.STOPED, TransactionState.READY) && !transactionState.compareAndSet(TransactionState.INIT, TransactionState.READY)) { throw new RuntimeException("We are already in transaction state"); } doStartTransaction(); } } }
Transaction { public void startTransaction() { synchronized (transactionLock) { if (!transactionState.compareAndSet(TransactionState.STOPED, TransactionState.READY) && !transactionState.compareAndSet(TransactionState.INIT, TransactionState.READY)) { throw new RuntimeException("We are already in transaction state"); } doStartTransaction(); } } protected  Transaction(); }
Transaction { public void startTransaction() { synchronized (transactionLock) { if (!transactionState.compareAndSet(TransactionState.STOPED, TransactionState.READY) && !transactionState.compareAndSet(TransactionState.INIT, TransactionState.READY)) { throw new RuntimeException("We are already in transaction state"); } doStartTransaction(); } } protected  Transaction(); void initTransaction(); void startTransaction(); T take(); void commitTransaction(); void rollbackTransaction(); void closeTransaction(); }
Transaction { public void startTransaction() { synchronized (transactionLock) { if (!transactionState.compareAndSet(TransactionState.STOPED, TransactionState.READY) && !transactionState.compareAndSet(TransactionState.INIT, TransactionState.READY)) { throw new RuntimeException("We are already in transaction state"); } doStartTransaction(); } } protected  Transaction(); void initTransaction(); void startTransaction(); T take(); void commitTransaction(); void rollbackTransaction(); void closeTransaction();  }