@Override public void clear() { super.clear(); this.transactionActive = false; this.savepointManager = null; }
/** * Return the time to live for this object in seconds. * Rounds up eagerly, e.g. 9.00001 still to 10. * @return number of seconds until expiration * @throws TransactionTimedOutException if the deadline has already been reached */ public int getTimeToLiveInSeconds() { double diff = ((double) getTimeToLiveInMillis()) / 1000; int secs = (int) Math.ceil(diff); checkTransactionTimeout(secs <= 0); return secs; }
/** * 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); } }
/** * Set the timeout for this object in seconds. * @param seconds number of seconds until expiration */ public void setTimeoutInSeconds(int seconds) { setTimeoutInMillis(seconds * 1000L); }
/** * 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; }
/** * Releases the current Connection held by this ConnectionHolder. * <p>This is necessary for ConnectionHandles that expect "Connection borrowing", * where each returned Connection is only temporarily leased and needs to be * returned once the data operation is done, to make the Connection available * for other operations within the same transaction. */ @Override public void released() { super.released(); if (!isOpen() && this.currentConnection != null) { if (this.connectionHandle != null) { this.connectionHandle.releaseConnection(this.currentConnection); } this.currentConnection = null; } }
/** * Set the timeout for this object in seconds. * @param seconds number of seconds until expiration */ public void setTimeoutInSeconds(int seconds) { setTimeoutInMillis(seconds * 1000L); }
/** * 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; }
/** * Releases the current Connection held by this ConnectionHolder. * <p>This is necessary for ConnectionHandles that expect "Connection borrowing", * where each returned Connection is only temporarily leased and needs to be * returned once the data operation is done, to make the Connection available * for other operations within the same transaction. */ @Override public void released() { super.released(); if (!isOpen() && this.currentConnection != null) { if (this.connectionHandle != null) { this.connectionHandle.releaseConnection(this.currentConnection); } this.currentConnection = null; } }
@Override public void clear() { super.clear(); this.transactionActive = false; this.savepointsSupported = null; this.savepointCounter = 0; }
/** * Return the time to live for this object in seconds. * Rounds up eagerly, e.g. 9.00001 still to 10. * @return number of seconds until expiration * @throws TransactionTimedOutException if the deadline has already been reached */ public int getTimeToLiveInSeconds() { double diff = ((double) getTimeToLiveInMillis()) / 1000; int secs = (int) Math.ceil(diff); checkTransactionTimeout(secs <= 0); return secs; }
/** * Set the timeout for this object in seconds. * @param seconds number of seconds until expiration */ public void setTimeoutInSeconds(int seconds) { setTimeoutInMillis(seconds * 1000L); }
/** * 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); } }
/** * 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; }
/** * Releases the current Connection held by this ConnectionHolder. * <p>This is necessary for ConnectionHandles that expect "Connection borrowing", * where each returned Connection is only temporarily leased and needs to be * returned once the data operation is done, to make the Connection available * for other operations within the same transaction. This is the case with * JDO 2.0 DataStoreConnections, for example. * @see org.springframework.orm.jdo.DefaultJdoDialect#getJdbcConnection */ @Override public void released() { super.released(); if (!isOpen() && this.currentConnection != null) { this.connectionHandle.releaseConnection(this.currentConnection); this.currentConnection = null; } }
/** * Reset this resource holder - transactional state as well as reference count. */ @Override public void reset() { clear(); this.referenceCount = 0; }
/** * Return the time to live for this object in seconds. * Rounds up eagerly, e.g. 9.00001 still to 10. * @return number of seconds until expiration * @throws TransactionTimedOutException if the deadline has already been reached */ public int getTimeToLiveInSeconds() { double diff = ((double) getTimeToLiveInMillis()) / 1000; int secs = (int) Math.ceil(diff); checkTransactionTimeout(secs <= 0); return secs; }
/** * Set the timeout for this object in seconds. * @param seconds number of seconds until expiration */ public void setTimeoutInSeconds(int seconds) { setTimeoutInMillis(seconds * 1000L); }
/** * 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); } }
/** * 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; }