/** * Helper method to get the current <code>{@link javax.transaction.Transaction}</code> * from the <code>{@link javax.transaction.TransactionManager}</code> in JNDI. * * @return The current <code>{@link javax.transaction.Transaction}</code>, null if * not currently in a transaction. */ protected Transaction getTransaction() throws LockException{ InitialContext ic = null; try { ic = new InitialContext(); TransactionManager tm = (TransactionManager)ic.lookup(transactionManagerJNDIName); return tm.getTransaction(); } catch (SystemException e) { throw new LockException("Failed to get Transaction from TransactionManager", e); } catch (NamingException e) { throw new LockException("Failed to find TransactionManager in JNDI under name: " + transactionManagerJNDIName, e); } finally { if (ic != null) { try { ic.close(); } catch (NamingException ignored) { } } } }
/** * Helper method to get the current <code>{@link javax.transaction.Transaction}</code> * from the <code>{@link javax.transaction.TransactionManager}</code> in JNDI. * * @return The current <code>{@link javax.transaction.Transaction}</code>, null if * not currently in a transaction. */ protected Transaction getTransaction() throws LockException{ InitialContext ic = null; try { ic = new InitialContext(); TransactionManager tm = (TransactionManager)ic.lookup(transactionManagerJNDIName); return tm.getTransaction(); } catch (SystemException e) { throw new LockException("Failed to get Transaction from TransactionManager", e); } catch (NamingException e) { throw new LockException("Failed to find TransactionManager in JNDI under name: " + transactionManagerJNDIName, e); } finally { if (ic != null) { try { ic.close(); } catch (NamingException ignored) { } } } }
/** * Execute the SQL select for update that will lock the proper database row. */ @Override protected void executeSQL(Connection conn, final String lockName, final String expandedSQL, final String expandedInsertSQL) throws LockException { SQLException lastFailure = null; for (int i = 0; i < RETRY_COUNT; i++) { try { if (!lockViaUpdate(conn, lockName, expandedSQL)) { lockViaInsert(conn, lockName, expandedInsertSQL); } return; } catch (SQLException e) { lastFailure = e; if ((i + 1) == RETRY_COUNT) { getLog().debug("Lock '{}' was not obtained by: {}", lockName, Thread.currentThread().getName()); } else { getLog().debug("Lock '{}' was not obtained by: {} - will try again.", lockName, Thread.currentThread().getName()); } try { Thread.sleep(1000L); } catch (InterruptedException _) { Thread.currentThread().interrupt(); } } } throw new LockException("Failure obtaining db row lock: " + lastFailure.getMessage(), lastFailure); }
/** * Execute the SQL select for update that will lock the proper database row. */ @Override protected void executeSQL(Connection conn, final String lockName, final String expandedSQL, final String expandedInsertSQL) throws LockException { SQLException lastFailure = null; for (int i = 0; i < RETRY_COUNT; i++) { try { if (!lockViaUpdate(conn, lockName, expandedSQL)) { lockViaInsert(conn, lockName, expandedInsertSQL); } return; } catch (SQLException e) { lastFailure = e; if ((i + 1) == RETRY_COUNT) { getLog().debug("Lock '{}' was not obtained by: {}", lockName, Thread.currentThread().getName()); } else { getLog().debug("Lock '{}' was not obtained by: {} - will try again.", lockName, Thread.currentThread().getName()); } try { Thread.sleep(1000L); } catch (InterruptedException _) { Thread.currentThread().interrupt(); } } } throw new LockException("Failure obtaining db row lock: " + lastFailure.getMessage(), lastFailure); }
t.registerSynchronization(new SemaphoreSynchronization(lockName)); } catch (Exception e) { throw new LockException("Failed to register semaphore with Transaction.", e);
t.registerSynchronization(new SemaphoreSynchronization(lockName)); } catch (Exception e) { throw new LockException("Failed to register semaphore with Transaction.", e);
throw new LockException("Failure obtaining db row lock: " + sqle.getMessage(), sqle); } finally { throw new LockException("Failure obtaining db row lock, reached maximum number of attempts. Initial exception (if any) attached as root cause.", initCause);
throw new LockException("Failure obtaining db row lock: " + sqle.getMessage(), sqle); } finally { throw new LockException("Failure obtaining db row lock, reached maximum number of attempts. Initial exception (if any) attached as root cause.", initCause);
/** * Helper method to get the current <code>{@link javax.transaction.Transaction}</code> * from the <code>{@link javax.transaction.TransactionManager}</code> in JNDI. * * @return The current <code>{@link javax.transaction.Transaction}</code>, null if * not currently in a transaction. */ protected Transaction getTransaction() throws LockException{ InitialContext ic = null; try { ic = new InitialContext(); TransactionManager tm = (TransactionManager)ic.lookup(transactionManagerJNDIName); return tm.getTransaction(); } catch (SystemException e) { throw new LockException("Failed to get Transaction from TransactionManager", e); } catch (NamingException e) { throw new LockException("Failed to find TransactionManager in JNDI under name: " + transactionManagerJNDIName, e); } finally { if (ic != null) { try { ic.close(); } catch (NamingException ignored) { } } } }
/** * Helper method to get the current <code>{@link javax.transaction.Transaction}</code> * from the <code>{@link javax.transaction.TransactionManager}</code> in JNDI. * * @return The current <code>{@link javax.transaction.Transaction}</code>, null if * not currently in a transaction. */ protected Transaction getTransaction() throws LockException{ InitialContext ic = null; try { ic = new InitialContext(); TransactionManager tm = (TransactionManager)ic.lookup(transactionManagerJNDIName); return tm.getTransaction(); } catch (SystemException e) { throw new LockException("Failed to get Transaction from TransactionManager", e); } catch (NamingException e) { throw new LockException("Failed to find TransactionManager in JNDI under name: " + transactionManagerJNDIName, e); } finally { if (ic != null) { try { ic.close(); } catch (NamingException ignored) { } } } }
t.registerSynchronization(new SemaphoreSynchronization(lockName)); } catch (Exception e) { throw new LockException("Failed to register semaphore with Transaction.", e);
t.registerSynchronization(new SemaphoreSynchronization(lockName)); } catch (Exception e) { throw new LockException("Failed to register semaphore with Transaction.", e);
throw new LockException( "Failure obtaining db row lock: " + sqle.getMessage(), sqle); } finally {
throw new LockException("Failure obtaining db row lock: " + sqle.getMessage(), sqle); } finally {
throw new LockException( "Failure obtaining db row lock: " + sqle.getMessage(), sqle); } finally {
throw new LockException("Failure obtaining db row lock: " + sqle.getMessage(), sqle); } finally {