IDEMPIERE-4759 Method to create Trx with other Connection (FHCA-2544) (#654)

This commit is contained in:
Carlos Ruiz 2021-04-14 16:45:24 +02:00 committed by GitHub
parent 355ef166f1
commit 4de94e3d21
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 21 additions and 0 deletions

View File

@ -81,6 +81,27 @@ public class Trx
return retValue;
} // get
/**
* Get Transaction in a Connection
* @param trxName trx name
* @param createNew if false, null is returned if not found
* @param con Connection
* @return Transaction or null
*/
public static Trx get (String trxName, boolean createNew, Connection con)
{
if (trxName == null || trxName.length() == 0)
throw new IllegalArgumentException ("No Transaction Name");
Trx retValue = (Trx)s_cache.get(trxName);
if (retValue == null && createNew)
{
retValue = new Trx (trxName, con);
s_cache.put(trxName, retValue);
}
return retValue;
} // get
/** Transaction Cache */
private static final Map<String,Trx> s_cache = new ConcurrentHashMap<String, Trx>();