本文整理汇总了Java中javax.transaction.Status.STATUS_MARKED_ROLLBACK属性的典型用法代码示例。如果您正苦于以下问题:Java Status.STATUS_MARKED_ROLLBACK属性的具体用法?Java Status.STATUS_MARKED_ROLLBACK怎么用?Java Status.STATUS_MARKED_ROLLBACK使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类javax.transaction.Status
的用法示例。
在下文中一共展示了Status.STATUS_MARKED_ROLLBACK属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: resolveUserTransaction
/**
* If the given UserTransaction is not null, it is committed/rolledback,
* and then returned to the UserTransactionHelper.
*/
private void resolveUserTransaction(UserTransaction userTransaction) {
if (userTransaction != null) {
try {
if (userTransaction.getStatus() == Status.STATUS_MARKED_ROLLBACK) {
userTransaction.rollback();
} else {
userTransaction.commit();
}
} catch (Throwable t) {
getLog().error("Failed to resolve UserTransaction for plugin: " + getName(), t);
} finally {
UserTransactionHelper.returnUserTransaction(userTransaction);
}
}
}
示例2: buildErrorString
/**
* Utility method to report errors about invalid state.
*
* @return - an error based on status
*/
private String buildErrorString()
{
StringBuilder buffer = new StringBuilder(128);
buffer.append("The indexer is unable to accept more work: ");
switch (getStatus().getStatus())
{
case Status.STATUS_COMMITTED:
buffer.append("The indexer has been committed");
break;
case Status.STATUS_COMMITTING:
buffer.append("The indexer is committing");
break;
case Status.STATUS_MARKED_ROLLBACK:
buffer.append("The indexer is marked for rollback");
break;
case Status.STATUS_PREPARED:
buffer.append("The indexer is prepared to commit");
break;
case Status.STATUS_PREPARING:
buffer.append("The indexer is preparing to commit");
break;
case Status.STATUS_ROLLEDBACK:
buffer.append("The indexer has been rolled back");
break;
case Status.STATUS_ROLLING_BACK:
buffer.append("The indexer is rolling back");
break;
case Status.STATUS_UNKNOWN:
buffer.append("The indexer is in an unknown state");
break;
default:
break;
}
return buffer.toString();
}
示例3: tearDown
protected void tearDown() throws Exception
{
if ((testTX.getStatus() == Status.STATUS_ACTIVE) || (testTX.getStatus() == Status.STATUS_MARKED_ROLLBACK))
{
testTX.rollback();
}
AuthenticationUtil.clearCurrentSecurityContext();
super.tearDown();
}
示例4: tearDown
@Override
protected void tearDown() throws Exception
{
if ((userTransaction.getStatus() == Status.STATUS_ACTIVE) || (userTransaction.getStatus() == Status.STATUS_MARKED_ROLLBACK))
{
userTransaction.rollback();
}
AuthenticationUtil.clearCurrentSecurityContext();
super.tearDown();
}
示例5: registerTransactionSynchronization
/**
* Register a transaction synchronization for closing the given LobCreator,
* preferring Spring transaction synchronization and falling back to
* plain JTA transaction synchronization.
* @param lobCreator the LobCreator to close after transaction completion
* @param jtaTransactionManager the JTA TransactionManager to fall back to
* when no Spring transaction synchronization is active (may be {@code null})
* @throws IllegalStateException if there is neither active Spring transaction
* synchronization nor active JTA transaction synchronization
*/
public static void registerTransactionSynchronization(
LobCreator lobCreator, TransactionManager jtaTransactionManager) throws IllegalStateException {
if (TransactionSynchronizationManager.isSynchronizationActive()) {
logger.debug("Registering Spring transaction synchronization for LobCreator");
TransactionSynchronizationManager.registerSynchronization(
new SpringLobCreatorSynchronization(lobCreator));
}
else {
if (jtaTransactionManager != null) {
try {
int jtaStatus = jtaTransactionManager.getStatus();
if (jtaStatus == Status.STATUS_ACTIVE || jtaStatus == Status.STATUS_MARKED_ROLLBACK) {
logger.debug("Registering JTA transaction synchronization for LobCreator");
jtaTransactionManager.getTransaction().registerSynchronization(
new JtaLobCreatorSynchronization(lobCreator));
return;
}
}
catch (Throwable ex) {
throw new TransactionSystemException(
"Could not register synchronization with JTA TransactionManager", ex);
}
}
throw new IllegalStateException("Active Spring transaction synchronization or active " +
"JTA transaction with specified [javax.transaction.TransactionManager] required");
}
}
示例6: tearDown
@Override
protected void tearDown() throws Exception
{
if ((tx.getStatus() == Status.STATUS_ACTIVE) || (tx.getStatus() == Status.STATUS_MARKED_ROLLBACK))
{
tx.rollback();
}
AuthenticationUtil.clearCurrentSecurityContext();
super.tearDown();
}
示例7: isTransactionActive
/**
* Checks if the current transaction is active, rolled back or marked for
* rollback.
*
* @return {@code true} if the current transaction is active, rolled back or
* marked for rollback, {@code false} otherwise.
* @throws SystemException thrown if the transaction manager encounters an
* unexpected error condition
*/
private boolean isTransactionActive(TransactionManager transactionManager) throws SystemException {
switch (transactionManager.getStatus()) {
case Status.STATUS_ACTIVE:
case Status.STATUS_MARKED_ROLLBACK:
case Status.STATUS_ROLLEDBACK:
return true;
default:
return false;
}
}
示例8: getStatus
/**
* This status is a combination of the internal status, as recorded during explicit operations,
* and the status provided by the Spring support.
*
* @see Status
*/
public synchronized int getStatus() throws SystemException
{
TransactionInfo txnInfo = getTransactionInfo();
// if the txn info is null, then we are outside a transaction
if (txnInfo == null)
{
return internalStatus; // this is checked in getTransactionInfo
}
// normally the internal status is correct, but we only need to double check
// for the case where the transaction was marked for rollback, or rolledback
// in a deeper transaction
TransactionStatus txnStatus = txnInfo.getTransactionStatus();
if (internalStatus == Status.STATUS_ROLLEDBACK)
{
// explicitly rolled back at some point
return internalStatus;
}
else if (txnStatus.isRollbackOnly())
{
// marked for rollback at some point in the stack
return Status.STATUS_MARKED_ROLLBACK;
}
else
{
// just rely on the internal status
return internalStatus;
}
}
示例9: call
public Object call(Callable<Object> callable,
IInvocationHandler.IInvocationCtx ctx) throws Exception {
final Object result;
ctx.getTransactionManager().begin();
try {
result = callable.call();
} catch (Exception ex) {
if (ctx.isApplicationException(ex)) {
if (hasRollbackAnnotation(ex)
|| ctx.getTransactionManager().getStatus() == Status.STATUS_MARKED_ROLLBACK) {
ctx.getTransactionManager().rollback();
} else {
commit(ctx);
}
throw ex;
}
ctx.getTransactionManager().rollback();
throw setCause(new EJBException(ex));
} catch (Error err) {
// Required for AssertErrors thrown by JUnit4 assertions:
ctx.getTransactionManager().rollback();
throw err;
}
if (ctx.getTransactionManager().getStatus() == Status.STATUS_MARKED_ROLLBACK) {
ctx.getTransactionManager().rollback();
throw new EJBTransactionRolledbackException();
}
commit(ctx);
return result;
}
示例10: isRollbackOnly
/**
* This implementation checks the UserTransaction's rollback-only flag.
*/
@Override
public boolean isRollbackOnly() {
if (this.userTransaction == null) {
return false;
}
try {
int jtaStatus = this.userTransaction.getStatus();
return (jtaStatus == Status.STATUS_MARKED_ROLLBACK || jtaStatus == Status.STATUS_ROLLEDBACK);
}
catch (SystemException ex) {
throw new TransactionSystemException("JTA failure on getStatus", ex);
}
}
示例11: endTransaction
/**
* End an active transaction
*
* @param sess SrvSession
* @param tx Object
*/
public void endTransaction(SrvSession sess, Object tx) {
// Check that the transaction object is valid
if ( tx == null)
return;
// Get the filesystem transaction
FilesysTransaction filesysTx = (FilesysTransaction) tx;
// Check if there is an active transaction
if ( filesysTx != null && filesysTx.hasTransaction())
{
// Get the active transaction
UserTransaction ftx = filesysTx.getTransaction();
try
{
// Commit or rollback the transaction
if ( ftx.getStatus() == Status.STATUS_MARKED_ROLLBACK ||
ftx.getStatus() == Status.STATUS_ROLLEDBACK ||
ftx.getStatus() == Status.STATUS_ROLLING_BACK)
{
// Transaction is marked for rollback
ftx.rollback();
// DEBUG
if ( logger.isDebugEnabled())
logger.debug("End transaction (rollback)");
}
else
{
// Commit the transaction
ftx.commit();
// DEBUG
if ( logger.isDebugEnabled())
logger.debug("End transaction (commit)");
}
}
catch ( Exception ex)
{
if ( logger.isDebugEnabled())
logger.debug("Failed to end transaction, " + ex.getMessage());
// throw new AlfrescoRuntimeException("Failed to end transaction", ex);
}
finally
{
// Clear the current transaction
sess.clearTransaction();
}
}
}
示例12: tearDown
@After
public void tearDown() throws Exception
{
method = null;
request = null;
response = null;
testDataFile = null;
davLockInfoAdminFile = null;
if (txn.getStatus() == Status.STATUS_MARKED_ROLLBACK)
{
txn.rollback();
}
else
{
txn.commit();
}
AuthenticationUtil.setAdminUserAsFullyAuthenticatedUser();
deleteUser(USER1_NAME);
deleteUser(USER2_NAME);
nodeService.deleteNode(versionableDoc);
// As per MNT-10037 try to create a node and delete it in the next txn
txn = transactionService.getUserTransaction();
txn.begin();
Map<QName, Serializable> properties = new HashMap<QName, Serializable>();
String nodeName = "leak-session-doc-" + GUID.generate();
properties.put(ContentModel.PROP_NAME, nodeName);
NodeRef nodeRef = nodeService.createNode(companyHomeNodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName(ContentModel.USER_MODEL_URI, nodeName),
ContentModel.TYPE_CONTENT, properties).getChildRef();
contentService.getWriter(nodeRef, ContentModel.PROP_CONTENT, true).putContent("WebDAVTestContent");
txn.commit();
txn = transactionService.getUserTransaction();
txn.begin();
nodeService.deleteNode(nodeRef);
txn.commit();
AuthenticationUtil.clearCurrentSecurityContext();
}
示例13: registerJtaSynchronization
/**
* Register a JTA synchronization for the given Session, if any.
* @param sessionHolder the existing thread-bound SessionHolder, if any
* @param session the Session to register
* @param sessionFactory the SessionFactory that the Session was created with
* @param jdbcExceptionTranslator SQLExcepionTranslator to use for flushing the
* Session on transaction synchronization (may be {@code null})
*/
private static void registerJtaSynchronization(Session session, SessionFactory sessionFactory,
SQLExceptionTranslator jdbcExceptionTranslator, SessionHolder sessionHolder) {
// JTA synchronization is only possible with a javax.transaction.TransactionManager.
// We'll check the Hibernate SessionFactory: If a TransactionManagerLookup is specified
// in Hibernate configuration, it will contain a TransactionManager reference.
TransactionManager jtaTm = getJtaTransactionManager(sessionFactory, session);
if (jtaTm != null) {
try {
Transaction jtaTx = jtaTm.getTransaction();
if (jtaTx != null) {
int jtaStatus = jtaTx.getStatus();
if (jtaStatus == Status.STATUS_ACTIVE || jtaStatus == Status.STATUS_MARKED_ROLLBACK) {
logger.debug("Registering JTA transaction synchronization for new Hibernate Session");
SessionHolder holderToUse = sessionHolder;
// Register JTA Transaction with existing SessionHolder.
// Create a new SessionHolder if none existed before.
if (holderToUse == null) {
holderToUse = new SessionHolder(jtaTx, session);
}
else {
holderToUse.addSession(jtaTx, session);
}
jtaTx.registerSynchronization(
new SpringJtaSynchronizationAdapter(
new SpringSessionSynchronization(holderToUse, sessionFactory, jdbcExceptionTranslator, true),
jtaTm));
holderToUse.setSynchronizedWithTransaction(true);
if (holderToUse != sessionHolder) {
TransactionSynchronizationManager.bindResource(sessionFactory, holderToUse);
}
}
}
}
catch (Throwable ex) {
throw new DataAccessResourceFailureException(
"Could not register synchronization with JTA TransactionManager", ex);
}
}
}
示例14: tearDown
@After
public void tearDown() throws Exception
{
if (trans != null)
{
try
{
trans.commit();
trans = null;
}
catch (Exception e)
{
if ((trans.getStatus() == Status.STATUS_ACTIVE) ||
(trans.getStatus() == Status.STATUS_MARKED_ROLLBACK))
{
trans.rollback();
trans = null;
}
}
}
RetryingTransactionCallback<Void> cleanup = new RetryingTransactionCallback<Void>()
{
@Override
public Void execute() throws Throwable
{
Set<NodeRef> adminGuestUserHomeFolders = deleteNonAdminGuestUsers();
deleteNonAdminGuestFolders(adminGuestUserHomeFolders);
deleteAllTenants();
return null;
}
};
try
{
transactionService.getRetryingTransactionHelper().doInTransaction(cleanup);
}
finally
{
AuthenticationUtil.clearCurrentSecurityContext();
userNameMatcher.setUserNamesAreCaseSensitive(false); // Put back the default
}
}
示例15: tearDown
@After
public void tearDown() throws Exception
{
method = null;
request = null;
response = null;
if (txn.getStatus() == Status.STATUS_MARKED_ROLLBACK)
{
txn.rollback();
}
else
{
txn.commit();
}
AuthenticationUtil.setAdminUserAsFullyAuthenticatedUser();
nodeService.deleteNode(versionableDoc);
// As per MNT-10037 try to create a node and delete it in the next txn
txn = transactionService.getUserTransaction();
txn.begin();
Map<QName, Serializable> properties = new HashMap<QName, Serializable>();
String nodeName = "leak-session-doc-" + GUID.generate();
properties.put(ContentModel.PROP_NAME, nodeName);
NodeRef nodeRef = nodeService.createNode(companyHomeNodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName(ContentModel.USER_MODEL_URI, nodeName),
ContentModel.TYPE_CONTENT, properties).getChildRef();
contentService.getWriter(nodeRef, ContentModel.PROP_CONTENT, true).putContent("WebDAVTestContent");
txn.commit();
txn = transactionService.getUserTransaction();
txn.begin();
nodeService.deleteNode(nodeRef);
txn.commit();
AuthenticationUtil.clearCurrentSecurityContext();
}