IDEMPIERE-3043 by synchronized. sometime, get list service will wrong

This commit is contained in:
Diego Ruiz 2019-11-13 14:55:29 +01:00
parent 0a6ea1a3e5
commit 43212e22e2
2 changed files with 14 additions and 7 deletions

View File

@ -49,7 +49,8 @@ public abstract class AbstractActivator implements BundleActivator, ServiceTrack
private String trxName = null;
private ProcessInfo m_processInfo = null;
private IProcessUI m_processUI = null;
public static boolean isFrameworkCompletedSrart = false;
private final static Object mutex = new Object();
private static boolean isFrameworkStarted = false;
@Override
@ -58,7 +59,7 @@ public abstract class AbstractActivator implements BundleActivator, ServiceTrack
if (logger.isLoggable(Level.INFO)) logger.info(getName() + " " + getVersion() + " starting...");
serviceTracker = new ServiceTracker<IDictionaryService, IDictionaryService>(context, IDictionaryService.class.getName(), this);
serviceTracker.open();
if (!isFrameworkCompletedSrart)
if (!isFrameworkStarted())
context.addFrameworkListener(this);
start();
if (logger.isLoggable(Level.INFO)) logger.info(getName() + " " + getVersion() + " ready.");
@ -216,11 +217,19 @@ public abstract class AbstractActivator implements BundleActivator, ServiceTrack
@Override
public void frameworkEvent(FrameworkEvent event) {
if (event.getType() == FrameworkEvent.STARTLEVEL_CHANGED) {
isFrameworkCompletedSrart = true;
frameworkStarted();
synchronized(mutex) {
isFrameworkStarted = true;
frameworkStarted();
}
}
}
public static Boolean isFrameworkStarted() {
synchronized(mutex) {
return isFrameworkStarted;
}
}
protected abstract void frameworkStarted();
/**
@ -243,7 +252,7 @@ public abstract class AbstractActivator implements BundleActivator, ServiceTrack
public IDictionaryService addingService(
ServiceReference<IDictionaryService> reference) {
service = context.getService(reference);
if (isFrameworkCompletedSrart)
if (isFrameworkStarted())
frameworkStarted ();
return null;
}

View File

@ -26,7 +26,6 @@ import java.util.Timer;
import java.util.TimerTask;
import java.util.logging.Level;
import org.adempiere.base.IDictionaryService;
import org.adempiere.util.ServerContext;
import org.compiere.Adempiere;
import org.compiere.model.MClient;
@ -41,7 +40,6 @@ import org.compiere.util.AdempiereSystemError;
import org.compiere.util.CLogger;
import org.compiere.util.Env;
import org.compiere.util.Util;
import org.osgi.framework.ServiceReference;
public class PackInApplicationActivator extends AbstractActivator{