org.springframework.transaction.TransactionTimedOutException Java Examples

The following examples show how to use org.springframework.transaction.TransactionTimedOutException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ResourceHolderSupport.java    From spring-analysis-note with MIT License 5 votes vote down vote up
/**
 * Return the time to live for this object in milliseconds.
 * @return number of milliseconds until expiration
 * @throws TransactionTimedOutException if the deadline has already been reached
 */
public long getTimeToLiveInMillis() throws TransactionTimedOutException{
	if (this.deadline == null) {
		throw new IllegalStateException("No timeout specified for this resource holder");
	}
	long timeToLive = this.deadline.getTime() - System.currentTimeMillis();
	checkTransactionTimeout(timeToLive <= 0);
	return timeToLive;
}
 
Example #2
Source File: ResourceHolderSupport.java    From spring-analysis-note with MIT License 5 votes vote down vote up
/**
 * Set the transaction rollback-only if the deadline has been reached,
 * and throw a TransactionTimedOutException.
 */
private void checkTransactionTimeout(boolean deadlineReached) throws TransactionTimedOutException {
	if (deadlineReached) {
		setRollbackOnly();
		throw new TransactionTimedOutException("Transaction timed out: deadline was " + this.deadline);
	}
}
 
Example #3
Source File: ResourceHolderSupport.java    From java-technology-stack with MIT License 5 votes vote down vote up
/**
 * Return the time to live for this object in milliseconds.
 * @return number of milliseconds until expiration
 * @throws TransactionTimedOutException if the deadline has already been reached
 */
public long getTimeToLiveInMillis() throws TransactionTimedOutException{
	if (this.deadline == null) {
		throw new IllegalStateException("No timeout specified for this resource holder");
	}
	long timeToLive = this.deadline.getTime() - System.currentTimeMillis();
	checkTransactionTimeout(timeToLive <= 0);
	return timeToLive;
}
 
Example #4
Source File: ResourceHolderSupport.java    From java-technology-stack with MIT License 5 votes vote down vote up
/**
 * Set the transaction rollback-only if the deadline has been reached,
 * and throw a TransactionTimedOutException.
 */
private void checkTransactionTimeout(boolean deadlineReached) throws TransactionTimedOutException {
	if (deadlineReached) {
		setRollbackOnly();
		throw new TransactionTimedOutException("Transaction timed out: deadline was " + this.deadline);
	}
}
 
Example #5
Source File: RepositoryManagerImpl.java    From syndesis with Apache License 2.0 5 votes vote down vote up
@Override
@SuppressWarnings({"Finally", "PMD.DoNotThrowExceptionInFinally"})
public <T> T runInTransaction(boolean rollbackOnly, Task<T> callable) {
    TransactionStatus transactionStatus = platformTransactionManager.getTransaction(NEW_TRANSACTION_DEFINITION);

    boolean shouldRollback = rollbackOnly;
    if (transactionStatus.isNewTransaction()) {
        if (rollbackOnly) {
            transactionStatus.setRollbackOnly();
        }
    } else {
        //there is a surrounding txn, so we can't set the rollback only flag
        shouldRollback = false;
    }
    String txnName = null;
    if (LOGGER.isDebugEnabled()) {
        StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
        txnName = stackTraceElements[2].getMethodName();
        LOGGER.debug( "createTransaction:created '%s', rollbackOnly = '%b'", txnName, shouldRollback ); //$NON-NLS-1$
    }
    try {
        return callable.call();
    } finally {
        try {
            platformTransactionManager.commit(transactionStatus);
            if (LOGGER.isDebugEnabled()) {
                LOGGER.debug( "transaction ended '%s'", //$NON-NLS-1$
                        txnName);
            }
        } catch (TransactionTimedOutException e) {
            throw new TimeoutException(e);
        }
    }
}
 
Example #6
Source File: ResourceHolderSupport.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Return the time to live for this object in milliseconds.
 * @return number of millseconds until expiration
 * @throws TransactionTimedOutException if the deadline has already been reached
 */
public long getTimeToLiveInMillis() throws TransactionTimedOutException{
	if (this.deadline == null) {
		throw new IllegalStateException("No timeout specified for this resource holder");
	}
	long timeToLive = this.deadline.getTime() - System.currentTimeMillis();
	checkTransactionTimeout(timeToLive <= 0);
	return timeToLive;
}
 
Example #7
Source File: ResourceHolderSupport.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Set the transaction rollback-only if the deadline has been reached,
 * and throw a TransactionTimedOutException.
 */
private void checkTransactionTimeout(boolean deadlineReached) throws TransactionTimedOutException {
	if (deadlineReached) {
		setRollbackOnly();
		throw new TransactionTimedOutException("Transaction timed out: deadline was " + this.deadline);
	}
}
 
Example #8
Source File: ResourceHolderSupport.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
/**
 * Return the time to live for this object in milliseconds.
 * @return number of millseconds until expiration
 * @throws TransactionTimedOutException if the deadline has already been reached
 */
public long getTimeToLiveInMillis() throws TransactionTimedOutException{
	if (this.deadline == null) {
		throw new IllegalStateException("No timeout specified for this resource holder");
	}
	long timeToLive = this.deadline.getTime() - System.currentTimeMillis();
	checkTransactionTimeout(timeToLive <= 0);
	return timeToLive;
}
 
Example #9
Source File: ResourceHolderSupport.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
/**
 * Set the transaction rollback-only if the deadline has been reached,
 * and throw a TransactionTimedOutException.
 */
private void checkTransactionTimeout(boolean deadlineReached) throws TransactionTimedOutException {
	if (deadlineReached) {
		setRollbackOnly();
		throw new TransactionTimedOutException("Transaction timed out: deadline was " + this.deadline);
	}
}