IDEMPIERE-3043 by synchronized. sometime, get list service will wrong
This commit is contained in:
parent
0a6ea1a3e5
commit
43212e22e2
|
@ -49,7 +49,8 @@ public abstract class AbstractActivator implements BundleActivator, ServiceTrack
|
||||||
private String trxName = null;
|
private String trxName = null;
|
||||||
private ProcessInfo m_processInfo = null;
|
private ProcessInfo m_processInfo = null;
|
||||||
private IProcessUI m_processUI = null;
|
private IProcessUI m_processUI = null;
|
||||||
public static boolean isFrameworkCompletedSrart = false;
|
private final static Object mutex = new Object();
|
||||||
|
private static boolean isFrameworkStarted = false;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -58,7 +59,7 @@ public abstract class AbstractActivator implements BundleActivator, ServiceTrack
|
||||||
if (logger.isLoggable(Level.INFO)) logger.info(getName() + " " + getVersion() + " starting...");
|
if (logger.isLoggable(Level.INFO)) logger.info(getName() + " " + getVersion() + " starting...");
|
||||||
serviceTracker = new ServiceTracker<IDictionaryService, IDictionaryService>(context, IDictionaryService.class.getName(), this);
|
serviceTracker = new ServiceTracker<IDictionaryService, IDictionaryService>(context, IDictionaryService.class.getName(), this);
|
||||||
serviceTracker.open();
|
serviceTracker.open();
|
||||||
if (!isFrameworkCompletedSrart)
|
if (!isFrameworkStarted())
|
||||||
context.addFrameworkListener(this);
|
context.addFrameworkListener(this);
|
||||||
start();
|
start();
|
||||||
if (logger.isLoggable(Level.INFO)) logger.info(getName() + " " + getVersion() + " ready.");
|
if (logger.isLoggable(Level.INFO)) logger.info(getName() + " " + getVersion() + " ready.");
|
||||||
|
@ -216,11 +217,19 @@ public abstract class AbstractActivator implements BundleActivator, ServiceTrack
|
||||||
@Override
|
@Override
|
||||||
public void frameworkEvent(FrameworkEvent event) {
|
public void frameworkEvent(FrameworkEvent event) {
|
||||||
if (event.getType() == FrameworkEvent.STARTLEVEL_CHANGED) {
|
if (event.getType() == FrameworkEvent.STARTLEVEL_CHANGED) {
|
||||||
isFrameworkCompletedSrart = true;
|
synchronized(mutex) {
|
||||||
frameworkStarted();
|
isFrameworkStarted = true;
|
||||||
|
frameworkStarted();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Boolean isFrameworkStarted() {
|
||||||
|
synchronized(mutex) {
|
||||||
|
return isFrameworkStarted;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected abstract void frameworkStarted();
|
protected abstract void frameworkStarted();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -243,7 +252,7 @@ public abstract class AbstractActivator implements BundleActivator, ServiceTrack
|
||||||
public IDictionaryService addingService(
|
public IDictionaryService addingService(
|
||||||
ServiceReference<IDictionaryService> reference) {
|
ServiceReference<IDictionaryService> reference) {
|
||||||
service = context.getService(reference);
|
service = context.getService(reference);
|
||||||
if (isFrameworkCompletedSrart)
|
if (isFrameworkStarted())
|
||||||
frameworkStarted ();
|
frameworkStarted ();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,6 @@ import java.util.Timer;
|
||||||
import java.util.TimerTask;
|
import java.util.TimerTask;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
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.MClient;
|
import org.compiere.model.MClient;
|
||||||
|
@ -41,7 +40,6 @@ import org.compiere.util.AdempiereSystemError;
|
||||||
import org.compiere.util.CLogger;
|
import org.compiere.util.CLogger;
|
||||||
import org.compiere.util.Env;
|
import org.compiere.util.Env;
|
||||||
import org.compiere.util.Util;
|
import org.compiere.util.Util;
|
||||||
import org.osgi.framework.ServiceReference;
|
|
||||||
|
|
||||||
public class PackInApplicationActivator extends AbstractActivator{
|
public class PackInApplicationActivator extends AbstractActivator{
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue