/** * Convenience method returning the {@link UpdateNotifier} * of the {@link #getTransaction() current transaction}. */ protected UpdateNotifier getUpdateNotifier() { return getTransaction().getUpdateNotifier(); }
/** * Convenience method returning the {@link MessageBroker} * of the {@link #getTransaction() current transaction}. */ protected MessageBroker getMessageBroker() { return getTransaction().getMessageBroker(); }
public boolean inTransaction() { return getTransaction() != null && !getTransaction().getState().isComplete(); }
public <Q> Q executeWithinTransaction(TransactionalClosureWithReturn<Q> closure) { boolean initiallyInTransaction = inTransaction(); if(!initiallyInTransaction) { startTransaction(); } try { closure.preExecute(); Q retVal = closure.execute(); closure.onSuccess(); if(!initiallyInTransaction) { endTransaction(); } return retVal; } catch (RuntimeException ex) { closure.onFailure(); if(!initiallyInTransaction) { abortTransaction(); } throw ex; } }
public static void abort(final NakedObjectTransactionManager transactionManager, final FacetHolder holder) { LOG.info("exception executing " + holder + ", aborting transaction"); try { transactionManager.abortTransaction(); } catch (final Exception e2) { LOG.error("failure during abort", e2); } }
/** * Creates a new transaction and saves, to be accessible in {@link #getTransaction()}. */ protected final T createTransaction() { this.transaction = createTransaction(createMessageBroker(), createUpdateNotifier()); return transaction; }
public void execute(final List<PersistenceCommand> commands) { LOG.debug("start execution of transaction"); for (PersistenceCommand command: commands) { command.execute(null); } LOG.debug("end execution"); }
public NakedObject invoke(final NakedObject targetAdapter, final NakedObject[] parameterAdapters) { return getTransactionManager().executeWithinTransaction( new TransactionalClosureWithReturnAbstract<NakedObject>(){ public NakedObject execute() { return underlyingFacet.invoke(targetAdapter, parameterAdapters); }}); }
public void close() { if (getTransaction() != null) { try { abortTransaction(); } catch (final Exception e2) { LOG.error("failure during abort", e2); } } session = null; }
public static boolean inTransaction() { return inSession() && getCurrentTransaction() != null && !getCurrentTransaction().getState().isComplete(); }
/** * Convenience method, returning the {@link MessageBroker} of the {@link #getCurrentTransaction() current * transaction}. */ public static MessageBroker getMessageBroker() { return getCurrentTransaction().getMessageBroker(); }
/** * Convenience method that returns the {@link NakedObjectTransaction} of the session, if any. */ public NakedObjectTransaction getCurrentTransaction() { return getTransactionManager().getTransaction(); }
/** * Convenience method, returning the {@link UpdateNotifier} of the {@link #getCurrentTransaction() current * transaction}. */ public static UpdateNotifier getUpdateNotifier() { return getCurrentTransaction().getUpdateNotifier(); }
public boolean flush() { return getTransactionManager().flushTransaction(); }
public void debugData(final DebugString debug) { debug.appendln("Transaction", getTransaction()); }
@Override public String toString() { return appendTo(new ToString(this)).toString(); }
protected void ensureTransactionNotInProgress() { ensureThatState( getTransaction() != null && !getTransaction().getState().isComplete(), is(false), "Transaction in progress"); }
public void execute(final List<PersistenceCommand> commands) throws ObjectPersistenceException { if (LOG.isInfoEnabled()) { LOG.info("execute commands"); } for (PersistenceCommand command : commands) { command.execute(null); } LOG.info("end execution"); }
protected void ensureTransactionInProgress() { ensureThatState( getTransaction() != null && !getTransaction().getState().isComplete(), is(true), "No transaction in progress"); }