IDEMPIERE-2771 Improve 2pack tracing for errors / drop unused transaction from 2pack activator
This commit is contained in:
parent
1fc8f9cb95
commit
95a4c42e88
|
@ -16,7 +16,6 @@ import org.compiere.model.ServerStateChangeListener;
|
||||||
import org.compiere.model.X_AD_Package_Imp;
|
import org.compiere.model.X_AD_Package_Imp;
|
||||||
import org.compiere.util.CLogger;
|
import org.compiere.util.CLogger;
|
||||||
import org.compiere.util.Env;
|
import org.compiere.util.Env;
|
||||||
import org.compiere.util.Trx;
|
|
||||||
import org.osgi.framework.BundleActivator;
|
import org.osgi.framework.BundleActivator;
|
||||||
import org.osgi.framework.BundleContext;
|
import org.osgi.framework.BundleContext;
|
||||||
import org.osgi.framework.ServiceReference;
|
import org.osgi.framework.ServiceReference;
|
||||||
|
@ -53,9 +52,6 @@ public class AdempiereActivator implements BundleActivator, ServiceTrackerCustom
|
||||||
}
|
}
|
||||||
|
|
||||||
private void installPackage() {
|
private void installPackage() {
|
||||||
String trxName = Trx.createTrxName();
|
|
||||||
try {
|
|
||||||
|
|
||||||
// e.g. 1.0.0.qualifier, check only the "1.0.0" part
|
// e.g. 1.0.0.qualifier, check only the "1.0.0" part
|
||||||
String version = getVersion();
|
String version = getVersion();
|
||||||
if (version != null)
|
if (version != null)
|
||||||
|
@ -86,22 +82,16 @@ public class AdempiereActivator implements BundleActivator, ServiceTrackerCustom
|
||||||
X_AD_Package_Imp pkg = q.first();
|
X_AD_Package_Imp pkg = q.first();
|
||||||
if (pkg == null) {
|
if (pkg == null) {
|
||||||
System.out.println("Installing " + getName() + " " + version + " ...");
|
System.out.println("Installing " + getName() + " " + version + " ...");
|
||||||
packIn(trxName);
|
packIn();
|
||||||
install();
|
install();
|
||||||
System.out.println(getName() + " " + version + " installed.");
|
System.out.println(getName() + " " + version + " installed.");
|
||||||
} else {
|
} else {
|
||||||
if (logger.isLoggable(Level.INFO)) logger.info(getName() + " " + version + " was installed: "
|
if (logger.isLoggable(Level.INFO)) logger.info(getName() + " " + version + " was installed: "
|
||||||
+ pkg.getCreated());
|
+ 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");
|
URL packout = context.getBundle().getEntry("/META-INF/2Pack.zip");
|
||||||
if (packout != null && service != null) {
|
if (packout != null && service != null) {
|
||||||
FileOutputStream zipstream = null;
|
FileOutputStream zipstream = null;
|
||||||
|
|
|
@ -34,7 +34,6 @@ import org.compiere.model.ServerStateChangeListener;
|
||||||
import org.compiere.model.X_AD_Package_Imp;
|
import org.compiere.model.X_AD_Package_Imp;
|
||||||
import org.compiere.util.CLogger;
|
import org.compiere.util.CLogger;
|
||||||
import org.compiere.util.Env;
|
import org.compiere.util.Env;
|
||||||
import org.compiere.util.Trx;
|
|
||||||
import org.compiere.util.Util;
|
import org.compiere.util.Util;
|
||||||
import org.osgi.framework.BundleActivator;
|
import org.osgi.framework.BundleActivator;
|
||||||
import org.osgi.framework.BundleContext;
|
import org.osgi.framework.BundleContext;
|
||||||
|
@ -88,8 +87,6 @@ public class Incremental2PackActivator implements BundleActivator, ServiceTracke
|
||||||
}
|
}
|
||||||
|
|
||||||
private void installPackage() {
|
private void installPackage() {
|
||||||
String trxName = Trx.createTrxName();
|
|
||||||
try {
|
|
||||||
// e.g. 1.0.0.qualifier, check only the "1.0.0" part
|
// e.g. 1.0.0.qualifier, check only the "1.0.0" part
|
||||||
String bundleVersionPart = getVersion();
|
String bundleVersionPart = getVersion();
|
||||||
String installedVersionPart = null;
|
String installedVersionPart = null;
|
||||||
|
@ -120,14 +117,8 @@ public class Incremental2PackActivator implements BundleActivator, ServiceTracke
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
packIn(trxName, installedVersionPart, bundleVersionPart);
|
packIn(installedVersionPart, bundleVersionPart);
|
||||||
afterPackIn();
|
afterPackIn();
|
||||||
Trx.get(trxName, false).commit();
|
|
||||||
} finally {
|
|
||||||
if (Trx.get(trxName, false) != null) {
|
|
||||||
Trx.get(trxName, false).close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class TwoPackEntry {
|
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>();
|
List<TwoPackEntry> list = new ArrayList<TwoPackEntry>();
|
||||||
|
|
||||||
//2Pack_1.0.0.zip, 2Pack_1.0.1.zip, etc
|
//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) {
|
for(TwoPackEntry entry : list) {
|
||||||
packIn(trxName, entry.url);
|
packIn(entry.url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -184,7 +175,7 @@ public class Incremental2PackActivator implements BundleActivator, ServiceTracke
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void packIn(String trxName, URL packout) {
|
protected void packIn(URL packout) {
|
||||||
if (packout != null && service != null) {
|
if (packout != null && service != null) {
|
||||||
String path = packout.getPath();
|
String path = packout.getPath();
|
||||||
String suffix = path.substring(path.lastIndexOf("_"));
|
String suffix = path.substring(path.lastIndexOf("_"));
|
||||||
|
|
Loading…
Reference in New Issue