From 95a4c42e882f97c9053f24f200dc102e2137821e Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Mon, 17 Aug 2015 17:11:12 -0500 Subject: [PATCH] IDEMPIERE-2771 Improve 2pack tracing for errors / drop unused transaction from 2pack activator --- .../plugin/utils/AdempiereActivator.java | 14 ++------------ .../plugin/utils/Incremental2PackActivator.java | 17 ++++------------- 2 files changed, 6 insertions(+), 25 deletions(-) diff --git a/org.adempiere.plugin.utils/src/org/adempiere/plugin/utils/AdempiereActivator.java b/org.adempiere.plugin.utils/src/org/adempiere/plugin/utils/AdempiereActivator.java index dee2f98b30..d24a2d15c4 100644 --- a/org.adempiere.plugin.utils/src/org/adempiere/plugin/utils/AdempiereActivator.java +++ b/org.adempiere.plugin.utils/src/org/adempiere/plugin/utils/AdempiereActivator.java @@ -16,7 +16,6 @@ import org.compiere.model.ServerStateChangeListener; import org.compiere.model.X_AD_Package_Imp; import org.compiere.util.CLogger; import org.compiere.util.Env; -import org.compiere.util.Trx; import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceReference; @@ -53,9 +52,6 @@ public class AdempiereActivator implements BundleActivator, ServiceTrackerCustom } private void installPackage() { - String trxName = Trx.createTrxName(); - try { - // e.g. 1.0.0.qualifier, check only the "1.0.0" part String version = getVersion(); if (version != null) @@ -86,22 +82,16 @@ public class AdempiereActivator implements BundleActivator, ServiceTrackerCustom X_AD_Package_Imp pkg = q.first(); if (pkg == null) { System.out.println("Installing " + getName() + " " + version + " ..."); - packIn(trxName); + packIn(); install(); System.out.println(getName() + " " + version + " installed."); } else { if (logger.isLoggable(Level.INFO)) logger.info(getName() + " " + version + " was installed: " + pkg.getCreated()); } - Trx.get(trxName, false).commit(); - } finally { - if (Trx.get(trxName, false) != null) { - Trx.get(trxName, false).close(); - } - } } - protected void packIn(String trxName) { + protected void packIn() { URL packout = context.getBundle().getEntry("/META-INF/2Pack.zip"); if (packout != null && service != null) { FileOutputStream zipstream = null; diff --git a/org.adempiere.plugin.utils/src/org/adempiere/plugin/utils/Incremental2PackActivator.java b/org.adempiere.plugin.utils/src/org/adempiere/plugin/utils/Incremental2PackActivator.java index 6567865070..7e5754b62d 100644 --- a/org.adempiere.plugin.utils/src/org/adempiere/plugin/utils/Incremental2PackActivator.java +++ b/org.adempiere.plugin.utils/src/org/adempiere/plugin/utils/Incremental2PackActivator.java @@ -34,7 +34,6 @@ import org.compiere.model.ServerStateChangeListener; import org.compiere.model.X_AD_Package_Imp; import org.compiere.util.CLogger; import org.compiere.util.Env; -import org.compiere.util.Trx; import org.compiere.util.Util; import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; @@ -88,8 +87,6 @@ public class Incremental2PackActivator implements BundleActivator, ServiceTracke } private void installPackage() { - String trxName = Trx.createTrxName(); - try { // e.g. 1.0.0.qualifier, check only the "1.0.0" part String bundleVersionPart = getVersion(); String installedVersionPart = null; @@ -120,14 +117,8 @@ public class Incremental2PackActivator implements BundleActivator, ServiceTracke } } } - packIn(trxName, installedVersionPart, bundleVersionPart); + packIn(installedVersionPart, bundleVersionPart); afterPackIn(); - Trx.get(trxName, false).commit(); - } finally { - if (Trx.get(trxName, false) != null) { - Trx.get(trxName, false).close(); - } - } } private static class TwoPackEntry { @@ -139,7 +130,7 @@ public class Incremental2PackActivator implements BundleActivator, ServiceTracke } } - protected void packIn(String trxName, String installedVersionPart, String bundleVersionPart) { + protected void packIn(String installedVersionPart, String bundleVersionPart) { List list = new ArrayList(); //2Pack_1.0.0.zip, 2Pack_1.0.1.zip, etc @@ -172,7 +163,7 @@ public class Incremental2PackActivator implements BundleActivator, ServiceTracke }); for(TwoPackEntry entry : list) { - packIn(trxName, entry.url); + packIn(entry.url); } } @@ -184,7 +175,7 @@ public class Incremental2PackActivator implements BundleActivator, ServiceTracke return v; } - protected void packIn(String trxName, URL packout) { + protected void packIn(URL packout) { if (packout != null && service != null) { String path = packout.getPath(); String suffix = path.substring(path.lastIndexOf("_"));