public final void abort() { ensureThatState(getState().canAbort(), is(true), "state is: " + getState()); if (LOG.isInfoEnabled()) { LOG.info("abort transaction " + this); } try { doAbort(); } catch(RuntimeException ex) { setAbortCause(ex); throw ex; } finally { setState(State.ABORTED); } }
public final void commit() { ensureThatState(getState().canCommit(), is(true), "state is: " + getState()); if (LOG.isInfoEnabled()) { LOG.info("commit transaction " + this); } if (getState() == State.COMMITTED) { if (LOG.isInfoEnabled()) { LOG.info("already committed; ignoring"); } return; } try { doFlush(); setState(State.COMMITTED); } catch(RuntimeException ex) { setAbortCause(ex); throw ex; } }
public final void flush() { ensureThatState(getState().canFlush(), is(true), "state is: " + getState()); if (LOG.isInfoEnabled()) { LOG.info("flush transaction " + this); } try { doFlush(); } catch(RuntimeException ex) { setState(State.MUST_ABORT); setAbortCause(ex); throw ex; } }
public void startTransaction() { boolean noneInProgress = false; if (getTransaction() == null || getTransaction().getState().isComplete()) { noneInProgress = true; createTransaction(); transactionLevel = 0; objectStore.startTransaction(); } transactionLevel++; if (LOG.isInfoEnabled()) { LOG.info( "startTransaction: level " + (transactionLevel-1) + "->" + (transactionLevel) + (noneInProgress?" (no transaction in progress or was previously completed; transaction created)":"")); } }
public boolean inTransaction() { return getTransaction() != null && !getTransaction().getState().isComplete(); }
public static boolean inTransaction() { return inSession() && getCurrentTransaction() != null && !getCurrentTransaction().getState().isComplete(); }
protected void ensureTransactionNotInProgress() { ensureThatState( getTransaction() != null && !getTransaction().getState().isComplete(), is(false), "Transaction in progress"); }
protected void ensureTransactionInProgress() { ensureThatState( getTransaction() != null && !getTransaction().getState().isComplete(), is(true), "No transaction in progress"); }