IDEMPIERE-2771 Improve 2pack tracing for errors / drop unused transaction from 2pack activator

This commit is contained in:
Carlos Ruiz 2015-08-17 17:11:12 -05:00
parent 1fc8f9cb95
commit 95a4c42e88
2 changed files with 6 additions and 25 deletions

View File

@ -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;

View File

@ -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<TwoPackEntry> list = new ArrayList<TwoPackEntry>();
//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("_"));