IDEMPIERE-734 autostarting plug-ins causes a lot of errors if 2Pack/AdempiereActivator is used.

This commit is contained in:
Heng Sin Low 2013-03-19 15:33:02 +08:00
parent e30bded686
commit 969ba70fe1
2 changed files with 32 additions and 15 deletions

View File

@ -148,8 +148,6 @@ public class PackIn {
IDFinder.clearIDCache();
importDetails = new ArrayList<X_AD_Package_Imp_Detail>();
System.setProperty("javax.xml.parsers.SAXParserFactory",
"org.apache.xerces.jaxp.SAXParserFactoryImpl");
PackInHandler handler = new PackInHandler();
PIPOContext context = new PIPOContext();
context.trx = Trx.get(trxName, true);

View File

@ -11,6 +11,8 @@ import org.adempiere.base.IDictionaryService;
import org.adempiere.util.ServerContext;
import org.compiere.Adempiere;
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.util.CLogger;
import org.compiere.util.Env;
@ -114,8 +116,8 @@ public class AdempiereActivator implements BundleActivator, ServiceTrackerCustom
}
// call 2pack
service.merge(context, zipfile);
} catch (Exception e) {
logger.log(Level.SEVERE, "Error on Dictionary service", e);
} catch (Throwable e) {
logger.log(Level.SEVERE, "Pack in failed.", e);
}
finally{
if (zipstream != null) {
@ -158,18 +160,35 @@ public class AdempiereActivator implements BundleActivator, ServiceTrackerCustom
public IDictionaryService addingService(
ServiceReference<IDictionaryService> reference) {
service = context.getService(reference);
Adempiere.getThreadPoolExecutor().execute(new Runnable() {
@Override
public void run() {
setupPackInContext();
try {
installPackage();
} finally {
ServerContext.dispose();
service = null;
if (Adempiere.getThreadPoolExecutor() != null) {
Adempiere.getThreadPoolExecutor().execute(new Runnable() {
@Override
public void run() {
try {
setupPackInContext();
installPackage();
} finally {
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;
}