public Object getVersion(Transaction tx) { if (tx == null) return currentObject; return txLocal.get(tx); }
/** * Sets the value of this TransactionLocal variable associtated with the * thread context transaction. This is only used to change the value from * the one assigned by the initialValue method, and many applications will * have no need for this functionality. * * @param value the value to be associated with the thread context * transactions's TransactionLocal */ public void set(Object value) { set(getTransaction(), value); }
/** Initialization */ public static void setTransactionManager(TransactionManager tm) { txSynchs = new TransactionLocal(tm); }
/** * Unlock the TransactionLocal using the current transaction */ public void unlock() { unlock(getTransaction()); }
/** * Lock the TransactionLocal using the current transaction<p> * * WARN: The current implemention just "locks the transactions" * * @throws IllegalStateException if the transaction is not active * @throws InterruptedException if the thread is interrupted */ public void lock() throws InterruptedException { lock(getTransaction()); }
/** * Returns the value of this TransactionLocal variable associated with the * thread context transaction. Creates and initializes the copy if this is * the first time the method is called in a transaction. * * @return the value of this TransactionLocal */ public Object get() { return get(getTransaction()); }
public GlobalTxSynchronization getGlobalSynchronization(Transaction tx) throws RollbackException, SystemException { GlobalTxSynchronization globalSync = (GlobalTxSynchronization) txSynch.get(tx); if(globalSync == null) { globalSync = new GlobalTxSynchronization(tx); txSynch.set(tx, globalSync); tx.registerSynchronization(globalSync); } return globalSync; }
trackByTx.lock(trackByTransaction); ConnectionListener cl = (ConnectionListener) trackByTx.get(trackByTransaction); if (cl != null) trackByTx.unlock(trackByTransaction); trackByTx.lock(trackByTransaction); ConnectionListener other = (ConnectionListener) trackByTx.get(trackByTransaction); if (other != null) trackByTx.set(cl); if (traceEnabled) dump("Using connection from pool tracked by transaction " + cl + " tx=" + trackByTransaction); trackByTx.unlock(trackByTransaction);
try trackByTx.lock(); rethrowAsSystemException("Unable to begin transaction with JCA lazy enlistment scenario", trackByTx.getTransaction(), t); trackByTx.set(cl); trackByTx.unlock();
/** * Sets the value of this TransactionLocal variable associtated with the * specified transaction. This is only used to change the value from * the one assigned by the initialValue method, and many applications will * have no need for this functionality. * * @param transaction the transaction for which the value will be set * @param value the value to be associated with the thread context * transactions's TransactionLocal */ public void set(Transaction transaction, Object value) { if (transaction == null) throw new IllegalStateException("there is no transaction"); // If this transaction is unknown, register for synchroniztion callback, // and call initialValue to give subclasses a chance to do some // initialization. if(!containsValue(transaction)) { initialValue(); } // if value is null replace it with the null value standin if(value == null) { value = NULL_VALUE; } // finally store the value storeValue(transaction, value); }
if (transaction == null) return initialValue(); Object value = getValue(transaction); value = initialValue(); storeValue(transaction, value); return initialValue();
public Transaction getTransaction() { return txSynch.getTransaction(); }
public Object createVersion(Transaction tx) throws Exception { final Object version; final long versionId; lock.acquire(); try { version = new MarshalledValue(currentObject).get(); if (version instanceof Advised) { // REVISIT: Currently share the InstanceAdvisor between versions Advised versionAdvised = (Advised)version; Advised currentAdvised = (Advised)currentObject; versionAdvised._setInstanceAdvisor(currentAdvised._getInstanceAdvisor()); } versionId = ++versionIdGenerator; } finally { lock.release(); } tx.registerSynchronization(new VersionSynchronization(tx, versionId, version)); txLocal.set(tx, version); return version; }
/** * Unlock for the given transaction * * @param tx the transaction */ static void unlock(Transaction tx) { txSynchs.unlock(tx); }
/** * Creates a transaction local variable. Using the given transaction manager * * @param tm the transaction manager */ public TransactionLocal(TransactionManager tm) { if (tm == null) throw new IllegalArgumentException("Null transaction manager"); this.transactionManager = tm; initDelegate(); }
/** * Lock for the given transaction * * @param tx the transaction */ static void lock(Transaction tx) { try { txSynchs.lock(tx); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new NestedRuntimeException("Unable to get synchronization", e); } }
/** * associate entity with transaction */ public void associate(Transaction tx, EntityEnterpriseContext entity) throws RollbackException, SystemException { HashMap entityMap = (HashMap) m_map.get(tx); if(entityMap == null) { entityMap = new HashMap(); m_map.set(tx, entityMap); } //EntityContainer.getGlobalTxEntityMap().associate(tx, entity); entityMap.put(entity.getCacheKey(), entity); }
/** * Returns the value of this TransactionLocal variable associated with the * thread context transaction. Creates and initializes the copy if this is * the first time the method is called in a transaction. * * @return the value of this TransactionLocal */ public Object get() { return get(getTransaction()); }
/** * Unlock the TransactionLocal using the current transaction */ public void unlock() { unlock(getTransaction()); }
/** * Lock the TransactionLocal using the current transaction<p> * * WARN: The current implemention just "locks the transactions" * * @throws IllegalStateException if the transaction is not active * @throws InterruptedException if the thread is interrupted */ public void lock() throws InterruptedException { lock(getTransaction()); }