IDEMPIERE-734 autostarting plug-ins causes a lot of errors if 2Pack/AdempiereActivator is used.
This commit is contained in:
parent
e30bded686
commit
969ba70fe1
|
@ -148,8 +148,6 @@ public class PackIn {
|
||||||
IDFinder.clearIDCache();
|
IDFinder.clearIDCache();
|
||||||
importDetails = new ArrayList<X_AD_Package_Imp_Detail>();
|
importDetails = new ArrayList<X_AD_Package_Imp_Detail>();
|
||||||
|
|
||||||
System.setProperty("javax.xml.parsers.SAXParserFactory",
|
|
||||||
"org.apache.xerces.jaxp.SAXParserFactoryImpl");
|
|
||||||
PackInHandler handler = new PackInHandler();
|
PackInHandler handler = new PackInHandler();
|
||||||
PIPOContext context = new PIPOContext();
|
PIPOContext context = new PIPOContext();
|
||||||
context.trx = Trx.get(trxName, true);
|
context.trx = Trx.get(trxName, true);
|
||||||
|
|
|
@ -11,6 +11,8 @@ import org.adempiere.base.IDictionaryService;
|
||||||
import org.adempiere.util.ServerContext;
|
import org.adempiere.util.ServerContext;
|
||||||
import org.compiere.Adempiere;
|
import org.compiere.Adempiere;
|
||||||
import org.compiere.model.Query;
|
import org.compiere.model.Query;
|
||||||
|
import org.compiere.model.ServerStateChangeEvent;
|
||||||
|
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;
|
||||||
|
@ -114,8 +116,8 @@ public class AdempiereActivator implements BundleActivator, ServiceTrackerCustom
|
||||||
}
|
}
|
||||||
// call 2pack
|
// call 2pack
|
||||||
service.merge(context, zipfile);
|
service.merge(context, zipfile);
|
||||||
} catch (Exception e) {
|
} catch (Throwable e) {
|
||||||
logger.log(Level.SEVERE, "Error on Dictionary service", e);
|
logger.log(Level.SEVERE, "Pack in failed.", e);
|
||||||
}
|
}
|
||||||
finally{
|
finally{
|
||||||
if (zipstream != null) {
|
if (zipstream != null) {
|
||||||
|
@ -158,18 +160,35 @@ public class AdempiereActivator implements BundleActivator, ServiceTrackerCustom
|
||||||
public IDictionaryService addingService(
|
public IDictionaryService addingService(
|
||||||
ServiceReference<IDictionaryService> reference) {
|
ServiceReference<IDictionaryService> reference) {
|
||||||
service = context.getService(reference);
|
service = context.getService(reference);
|
||||||
Adempiere.getThreadPoolExecutor().execute(new Runnable() {
|
if (Adempiere.getThreadPoolExecutor() != null) {
|
||||||
@Override
|
Adempiere.getThreadPoolExecutor().execute(new Runnable() {
|
||||||
public void run() {
|
@Override
|
||||||
setupPackInContext();
|
public void run() {
|
||||||
try {
|
try {
|
||||||
installPackage();
|
setupPackInContext();
|
||||||
} finally {
|
installPackage();
|
||||||
ServerContext.dispose();
|
} finally {
|
||||||
service = null;
|
ServerContext.dispose();
|
||||||
|
service = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
});
|
} else {
|
||||||
|
Adempiere.addServerStateChangeListener(new ServerStateChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void stateChange(ServerStateChangeEvent event) {
|
||||||
|
if (event.getEventType() == ServerStateChangeEvent.SERVER_START && service != null) {
|
||||||
|
try {
|
||||||
|
setupPackInContext();
|
||||||
|
installPackage();
|
||||||
|
} finally {
|
||||||
|
ServerContext.dispose();
|
||||||
|
service = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue