.
It duplicates non-managed transaction control.
| Method from org.apache.openjpa.kernel.LocalManagedRuntime Detail: |
public synchronized void begin() {
if (_active)
throw new InvalidStateException(_loc.get("active"));
_active = true;
}
|
public synchronized void commit() {
if (!_active)
throw new InvalidStateException(_loc.get("not-active"));
// try to invoke before completion in preparation for commit
RuntimeException err = null;
if (_rollbackOnly == null) {
try {
_broker.beforeCompletion();
if (_factorySync != null)
_factorySync.beforeCompletion();
} catch (RuntimeException re) {
_rollbackOnly = re;
err = re;
}
} else // previously marked rollback only
err = new StoreException(_loc.get("marked-rollback")).
setCause(_rollbackOnly).setFatal(true);
if (_rollbackOnly == null) {
try {
_broker.afterCompletion(Status.STATUS_COMMITTED);
notifyAfterCompletion(Status.STATUS_COMMITTED);
} catch (RuntimeException re) {
if (err == null)
err = re;
}
}
// if we haven't managed to commit, rollback
if (_active) {
try {
rollback();
} catch (RuntimeException re) {
if (err == null)
err = re;
}
}
// throw the first exception we encountered, if any
if (err != null)
throw err;
}
|
public boolean delistResource(XAResource xaRes,
int flag) throws SystemException {
throw new SystemException(NotSupportedException.class.getName());
}
|
public boolean enlistResource(XAResource xaRes) throws SystemException {
throw new SystemException(NotSupportedException.class.getName());
}
|
public Throwable getRollbackCause() {
return _rollbackOnly;
}
|
public synchronized int getStatus() {
if (_rollbackOnly != null)
return Status.STATUS_MARKED_ROLLBACK;
if (_active)
return Status.STATUS_ACTIVE;
return Status.STATUS_NO_TRANSACTION;
}
|
public Transaction getTransaction() {
return this;
}
|
public TransactionManager getTransactionManager() {
return this;
}
|
public synchronized void registerSynchronization(Synchronization sync) {
if (sync == _broker)
return;
if (_factorySync != null)
throw new InternalException();
_factorySync = sync;
}
|
public void resume(Transaction tobj) throws SystemException {
throw new SystemException(NotSupportedException.class.getName());
}
|
public synchronized void rollback() {
if (!_active)
throw new InvalidStateException(_loc.get("not-active"));
// rollback broker
RuntimeException err = null;
try {
_broker.afterCompletion(Status.STATUS_ROLLEDBACK);
} catch (RuntimeException re) {
err = re;
}
// rollback synch, even if broker throws exception
try {
notifyAfterCompletion(Status.STATUS_ROLLEDBACK);
} catch (RuntimeException re) {
if (err == null)
err = re;
}
if (err != null)
throw err;
}
|
public synchronized void setRollbackOnly() {
setRollbackOnly(new UserException());
}
|
public void setRollbackOnly(Throwable cause) {
_rollbackOnly = cause;
}
|
public void setTransactionTimeout(int sec) throws SystemException {
throw new SystemException(NotSupportedException.class.getName());
}
|
public Transaction suspend() throws SystemException {
throw new SystemException(NotSupportedException.class.getName());
}
|