From 4de94e3d21d9c7e4e1e1b17d852509e587906b76 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Wed, 14 Apr 2021 16:45:24 +0200 Subject: [PATCH] IDEMPIERE-4759 Method to create Trx with other Connection (FHCA-2544) (#654) --- .../src/org/compiere/util/Trx.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/org.adempiere.base/src/org/compiere/util/Trx.java b/org.adempiere.base/src/org/compiere/util/Trx.java index 573d4f5354..74eb4f2d9d 100644 --- a/org.adempiere.base/src/org/compiere/util/Trx.java +++ b/org.adempiere.base/src/org/compiere/util/Trx.java @@ -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 s_cache = new ConcurrentHashMap();