diff --git a/org.adempiere.plugin.utils/src/org/adempiere/plugin/utils/AbstractActivator.java b/org.adempiere.plugin.utils/src/org/adempiere/plugin/utils/AbstractActivator.java index 908f27549d..fde187fe6b 100644 --- a/org.adempiere.plugin.utils/src/org/adempiere/plugin/utils/AbstractActivator.java +++ b/org.adempiere.plugin.utils/src/org/adempiere/plugin/utils/AbstractActivator.java @@ -34,10 +34,12 @@ import org.compiere.util.Env; import org.compiere.util.Trx; import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; +import org.osgi.framework.FrameworkEvent; +import org.osgi.framework.FrameworkListener; import org.osgi.util.tracker.ServiceTracker; import org.osgi.util.tracker.ServiceTrackerCustomizer; -public abstract class AbstractActivator implements BundleActivator, ServiceTrackerCustomizer { +public abstract class AbstractActivator implements BundleActivator, ServiceTrackerCustomizer, FrameworkListener{ protected final static CLogger logger = CLogger.getCLogger(AbstractActivator.class.getName()); protected BundleContext context; @@ -46,7 +48,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; + protected boolean merge(File zipfile, String version) throws Exception { boolean success = false; @@ -184,5 +187,23 @@ public abstract class AbstractActivator implements BundleActivator, ServiceTrack if (m_processInfo != null) m_processInfo.setSummary(msg); } + + @Override + public void frameworkEvent(FrameworkEvent event) { + if (event.getType() == FrameworkEvent.STARTLEVEL_CHANGED) { + isFrameworkCompletedSrart = true; + frameworkStarted(); + } + } + + protected abstract void frameworkStarted(); + + protected void registryRunPackin() { + if (isFrameworkCompletedSrart) { + frameworkStarted (); + }else { + context.addFrameworkListener(this); + } + } } diff --git a/org.adempiere.plugin.utils/src/org/adempiere/plugin/utils/AdempiereActivator.java b/org.adempiere.plugin.utils/src/org/adempiere/plugin/utils/AdempiereActivator.java index 3680b17b91..638823f7f1 100644 --- a/org.adempiere.plugin.utils/src/org/adempiere/plugin/utils/AdempiereActivator.java +++ b/org.adempiere.plugin.utils/src/org/adempiere/plugin/utils/AdempiereActivator.java @@ -20,19 +20,18 @@ import org.compiere.util.CLogger; import org.compiere.util.Env; import org.osgi.framework.BundleContext; import org.osgi.framework.FrameworkEvent; -import org.osgi.framework.FrameworkListener; import org.osgi.framework.ServiceReference; import org.osgi.util.tracker.ServiceTracker; -public class AdempiereActivator extends AbstractActivator implements FrameworkListener { +public class AdempiereActivator extends AbstractActivator { protected final static CLogger logger = CLogger.getCLogger(AdempiereActivator.class.getName()); @Override public void start(BundleContext context) throws Exception { this.context = context; + registryRunPackin (); if (logger.isLoggable(Level.INFO)) logger.info(getName() + " " + getVersion() + " starting..."); - context.addFrameworkListener(this); serviceTracker = new ServiceTracker(context, IDictionaryService.class.getName(), this); serviceTracker.open(); start(); @@ -195,7 +194,7 @@ public class AdempiereActivator extends AbstractActivator implements FrameworkLi } } - private void frameworkStarted() { + protected void frameworkStarted() { if (service != null) { if (Adempiere.getThreadPoolExecutor() != null) { Adempiere.getThreadPoolExecutor().execute(new Runnable() { diff --git a/org.adempiere.plugin.utils/src/org/adempiere/plugin/utils/Incremental2PackActivator.java b/org.adempiere.plugin.utils/src/org/adempiere/plugin/utils/Incremental2PackActivator.java index 378b43acc3..c445ece9d8 100644 --- a/org.adempiere.plugin.utils/src/org/adempiere/plugin/utils/Incremental2PackActivator.java +++ b/org.adempiere.plugin.utils/src/org/adempiere/plugin/utils/Incremental2PackActivator.java @@ -38,8 +38,6 @@ import org.compiere.util.CLogger; import org.compiere.util.Env; import org.compiere.util.Trx; import org.osgi.framework.BundleContext; -import org.osgi.framework.FrameworkEvent; -import org.osgi.framework.FrameworkListener; import org.osgi.framework.ServiceReference; import org.osgi.util.tracker.ServiceTracker; @@ -48,15 +46,15 @@ import org.osgi.util.tracker.ServiceTracker; * @author hengsin * */ -public class Incremental2PackActivator extends AbstractActivator implements FrameworkListener { +public class Incremental2PackActivator extends AbstractActivator { protected final static CLogger logger = CLogger.getCLogger(Incremental2PackActivator.class.getName()); @Override public void start(BundleContext context) throws Exception { this.context = context; + registryRunPackin (); if (logger.isLoggable(Level.INFO)) logger.info(getName() + " " + getVersion() + " starting..."); - context.addFrameworkListener(this); serviceTracker = new ServiceTracker(context, IDictionaryService.class.getName(), this); serviceTracker.open(); start(); @@ -312,15 +310,9 @@ public class Incremental2PackActivator extends AbstractActivator implements Fram serverContext.setProperty("#AD_Client_ID", "0"); ServerContext.setCurrentInstance(serverContext); }; - - @Override - public void frameworkEvent(FrameworkEvent event) { - if (event.getType() == FrameworkEvent.STARTLEVEL_CHANGED) { - frameworkStarted(); - } - } - private void frameworkStarted() { + @Override + protected void frameworkStarted() { if (service != null) { if (Adempiere.getThreadPoolExecutor() != null) { Adempiere.getThreadPoolExecutor().execute(new Runnable() { diff --git a/org.adempiere.plugin.utils/src/org/adempiere/plugin/utils/PackInApplicationActivator.java b/org.adempiere.plugin.utils/src/org/adempiere/plugin/utils/PackInApplicationActivator.java index c7dab23879..9cbb15c449 100644 --- a/org.adempiere.plugin.utils/src/org/adempiere/plugin/utils/PackInApplicationActivator.java +++ b/org.adempiere.plugin.utils/src/org/adempiere/plugin/utils/PackInApplicationActivator.java @@ -42,12 +42,10 @@ import org.compiere.util.CLogger; import org.compiere.util.Env; import org.compiere.util.Util; import org.osgi.framework.BundleContext; -import org.osgi.framework.FrameworkEvent; -import org.osgi.framework.FrameworkListener; import org.osgi.framework.ServiceReference; import org.osgi.util.tracker.ServiceTracker; -public class PackInApplicationActivator extends AbstractActivator implements FrameworkListener { +public class PackInApplicationActivator extends AbstractActivator{ protected final static CLogger logger = CLogger.getCLogger(PackInApplicationActivator.class.getName()); private List filesToProcess = new ArrayList<>(); @@ -395,13 +393,7 @@ public class PackInApplicationActivator extends AbstractActivator implements Fra } @Override - public void frameworkEvent(FrameworkEvent event) { - if (event.getType() == FrameworkEvent.STARTLEVEL_CHANGED) { - frameworkStarted(); - } - } - - private void frameworkStarted() { + protected void frameworkStarted() { if (service != null) { if (Adempiere.getThreadPoolExecutor() != null) { Adempiere.getThreadPoolExecutor().execute(new Runnable() { diff --git a/org.adempiere.plugin.utils/src/org/adempiere/plugin/utils/Version2PackActivator.java b/org.adempiere.plugin.utils/src/org/adempiere/plugin/utils/Version2PackActivator.java index 588923a29c..7f07ca6dff 100644 --- a/org.adempiere.plugin.utils/src/org/adempiere/plugin/utils/Version2PackActivator.java +++ b/org.adempiere.plugin.utils/src/org/adempiere/plugin/utils/Version2PackActivator.java @@ -38,8 +38,6 @@ import org.compiere.util.CLogger; import org.compiere.util.Env; import org.compiere.util.Util; import org.osgi.framework.BundleContext; -import org.osgi.framework.FrameworkEvent; -import org.osgi.framework.FrameworkListener; import org.osgi.framework.ServiceReference; import org.osgi.util.tracker.ServiceTracker; @@ -48,7 +46,7 @@ import org.osgi.util.tracker.ServiceTracker; * @author hengsin * */ -public class Version2PackActivator extends AbstractActivator implements FrameworkListener { +public class Version2PackActivator extends AbstractActivator{ protected final static CLogger logger = CLogger.getCLogger(Version2PackActivator.class.getName()); @@ -280,15 +278,9 @@ public class Version2PackActivator extends AbstractActivator implements Framewor serverContext.setProperty("#AD_Client_ID", "0"); ServerContext.setCurrentInstance(serverContext); }; - - @Override - public void frameworkEvent(FrameworkEvent event) { - if (event.getType() == FrameworkEvent.STARTLEVEL_CHANGED) { - frameworkStarted(); - } - } - private void frameworkStarted() { + @Override + protected void frameworkStarted() { if (service != null) { if (Adempiere.getThreadPoolExecutor() != null) { Adempiere.getThreadPoolExecutor().execute(new Runnable() {