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 fde187fe6b..c8b3144605 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 @@ -36,6 +36,7 @@ import org.osgi.framework.BundleActivator; 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; import org.osgi.util.tracker.ServiceTrackerCustomizer; @@ -50,6 +51,30 @@ public abstract class AbstractActivator implements BundleActivator, ServiceTrack private IProcessUI m_processUI = null; public static boolean isFrameworkCompletedSrart = false; + + @Override + public void start(BundleContext context) throws Exception { + this.context = context; + if (logger.isLoggable(Level.INFO)) logger.info(getName() + " " + getVersion() + " starting..."); + serviceTracker = new ServiceTracker(context, IDictionaryService.class.getName(), this); + serviceTracker.open(); + if (!isFrameworkCompletedSrart) + context.addFrameworkListener(this); + start(); + if (logger.isLoggable(Level.INFO)) logger.info(getName() + " " + getVersion() + " ready."); + } + + @Override + public void stop(BundleContext context) throws Exception { + stop(); + serviceTracker.close(); + context.removeFrameworkListener(this); + this.context = null; + if (logger.isLoggable(Level.INFO)) logger.info(context.getBundle().getSymbolicName() + " " + + context.getBundle().getHeaders().get("Bundle-Version") + + " stopped."); + } + protected boolean merge(File zipfile, String version) throws Exception { boolean success = false; @@ -197,13 +222,39 @@ public abstract class AbstractActivator implements BundleActivator, ServiceTrack } protected abstract void frameworkStarted(); + + /** + * call when bundle have been started ( after this.context have been set ) + */ + protected void start() { + }; + + /** + * call when bundle is stop ( before this.context is set to null ) + */ + protected void stop() { + } - protected void registryRunPackin() { - if (isFrameworkCompletedSrart) { + public String getVersion() { + return ""; + } + + @Override + public IDictionaryService addingService( + ServiceReference reference) { + service = context.getService(reference); + if (isFrameworkCompletedSrart) frameworkStarted (); - }else { - context.addFrameworkListener(this); - } + return null; } + @Override + public void modifiedService(ServiceReference reference, + IDictionaryService service) { + } + + @Override + public void removedService(ServiceReference reference, + IDictionaryService service) { + } } 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 638823f7f1..1943e4506b 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 @@ -7,7 +7,6 @@ import java.net.URL; import java.util.Properties; import java.util.logging.Level; -import org.adempiere.base.IDictionaryService; import org.adempiere.util.ServerContext; import org.compiere.Adempiere; import org.compiere.model.MSession; @@ -20,28 +19,16 @@ import org.compiere.util.CLogger; import org.compiere.util.Env; import org.osgi.framework.BundleContext; import org.osgi.framework.FrameworkEvent; -import org.osgi.framework.ServiceReference; -import org.osgi.util.tracker.ServiceTracker; 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..."); - serviceTracker = new ServiceTracker(context, IDictionaryService.class.getName(), this); - serviceTracker.open(); - start(); - if (logger.isLoggable(Level.INFO)) logger.info(getName() + " " + getVersion() + " ready."); - } - public String getName() { return context.getBundle().getSymbolicName(); } + @Override public String getVersion() { return (String) context.getBundle().getHeaders().get("Bundle-Version"); } @@ -143,44 +130,10 @@ public class AdempiereActivator extends AbstractActivator { protected void setContext(BundleContext context) { this.context = context; } - - @Override - public void stop(BundleContext context) throws Exception { - stop(); - serviceTracker.close(); - context.removeFrameworkListener(this); - this.context = null; - if (logger.isLoggable(Level.INFO)) logger.info(context.getBundle().getSymbolicName() + " " - + context.getBundle().getHeaders().get("Bundle-Version") - + " stopped."); - } protected void install() { }; - protected void start() { - }; - - protected void stop() { - } - - @Override - public IDictionaryService addingService( - ServiceReference reference) { - service = context.getService(reference); - return null; - } - - @Override - public void modifiedService(ServiceReference reference, - IDictionaryService service) { - } - - @Override - public void removedService(ServiceReference reference, - IDictionaryService service) { - } - protected void setupPackInContext() { Properties serverContext = new Properties(); serverContext.setProperty("#AD_Client_ID", "0"); 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 c445ece9d8..5bb74f5aad 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 @@ -25,7 +25,6 @@ import java.util.List; import java.util.Properties; import java.util.logging.Level; -import org.adempiere.base.IDictionaryService; import org.adempiere.util.ServerContext; import org.compiere.Adempiere; import org.compiere.model.MSession; @@ -38,8 +37,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.ServiceReference; -import org.osgi.util.tracker.ServiceTracker; /** * @@ -50,21 +47,11 @@ 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..."); - serviceTracker = new ServiceTracker(context, IDictionaryService.class.getName(), this); - serviceTracker.open(); - start(); - if (logger.isLoggable(Level.INFO)) logger.info(getName() + " " + getVersion() + " ready."); - } - public String getName() { return context.getBundle().getSymbolicName(); } + @Override public String getVersion() { String version = (String) context.getBundle().getHeaders().get("Bundle-Version"); // e.g. 1.0.0.qualifier, check only the "1.0.0" part @@ -261,50 +248,10 @@ public class Incremental2PackActivator extends AbstractActivator { protected void setContext(BundleContext context) { this.context = context; } - - @Override - public void stop(BundleContext context) throws Exception { - stop(); - serviceTracker.close(); - context.removeFrameworkListener(this); - this.context = null; - if (logger.isLoggable(Level.INFO)) logger.info(context.getBundle().getSymbolicName() + " " - + context.getBundle().getHeaders().get("Bundle-Version") - + " stopped."); - } protected void afterPackIn() { }; - /** - * call when bundle have been started ( after this.context have been set ) - */ - protected void start() { - }; - - /** - * call when bundle is stop ( before this.context is set to null ) - */ - protected void stop() { - } - - @Override - public IDictionaryService addingService( - ServiceReference reference) { - service = context.getService(reference); - return null; - } - - @Override - public void modifiedService(ServiceReference reference, - IDictionaryService service) { - } - - @Override - public void removedService(ServiceReference reference, - IDictionaryService service) { - } - protected void setupPackInContext() { Properties serverContext = new Properties(); serverContext.setProperty("#AD_Client_ID", "0"); 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 9cbb15c449..9008eda0e7 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 @@ -41,57 +41,14 @@ import org.compiere.util.AdempiereSystemError; import org.compiere.util.CLogger; import org.compiere.util.Env; import org.compiere.util.Util; -import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceReference; -import org.osgi.util.tracker.ServiceTracker; public class PackInApplicationActivator extends AbstractActivator{ protected final static CLogger logger = CLogger.getCLogger(PackInApplicationActivator.class.getName()); private List filesToProcess = new ArrayList<>(); private File currentFile; - - @Override - public void start(BundleContext context) throws Exception { - this.context = context; - if (logger.isLoggable(Level.INFO)) logger.info(getName() + " starting..."); - context.addFrameworkListener(this); - serviceTracker = new ServiceTracker(context, IDictionaryService.class.getName(), this); - serviceTracker.open(); - start(); - if (logger.isLoggable(Level.INFO)) - logger.info(getName() + " ready."); - } - - /** - * call when bundle have been started ( after this.context have been set ) - */ - protected void start() { - }; - - /** - * call when bundle is stop ( before this.context is set to null ) - */ - protected void stop() { - } - @Override - public void stop(BundleContext context) throws Exception { - stop(); - serviceTracker.close(); - context.removeFrameworkListener(this); - this.context = null; - if (logger.isLoggable(Level.INFO)) logger.info(context.getBundle().getSymbolicName() + " " - + context.getBundle().getHeaders().get("Bundle-Version") - + " stopped."); - } - - @Override - public IDictionaryService addingService(ServiceReference reference) { - service = context.getService(reference); - return null; - } - public void automaticPackin(int timeout, String folders, boolean fromService) { if (fromService) { //Initial delay - starting from service @@ -369,14 +326,6 @@ public class PackInApplicationActivator extends AbstractActivator{ .setOnlyActiveRecords(true); return q.getIDs(); } - - @Override - public void modifiedService(ServiceReference reference, IDictionaryService service) { - } - - @Override - public void removedService(ServiceReference reference, IDictionaryService service) { - } @Override public String getName() { 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 7f07ca6dff..028293e864 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 @@ -25,7 +25,6 @@ import java.util.List; import java.util.Properties; import java.util.logging.Level; -import org.adempiere.base.IDictionaryService; import org.adempiere.util.ServerContext; import org.compiere.Adempiere; import org.compiere.model.MSession; @@ -38,8 +37,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.ServiceReference; -import org.osgi.util.tracker.ServiceTracker; /** * @@ -50,17 +47,6 @@ public class Version2PackActivator extends AbstractActivator{ protected final static CLogger logger = CLogger.getCLogger(Version2PackActivator.class.getName()); - @Override - public void start(BundleContext context) throws Exception { - this.context = context; - if (logger.isLoggable(Level.INFO)) logger.info(getName() + " " + getVersion() + " starting..."); - context.addFrameworkListener(this); - serviceTracker = new ServiceTracker(context, IDictionaryService.class.getName(), this); - serviceTracker.open(); - start(); - if (logger.isLoggable(Level.INFO)) logger.info(getName() + " " + getVersion() + " ready."); - } - public String getName() { return context.getBundle().getSymbolicName(); } @@ -230,49 +216,9 @@ public class Version2PackActivator extends AbstractActivator{ this.context = context; } - @Override - public void stop(BundleContext context) throws Exception { - stop(); - serviceTracker.close(); - context.removeFrameworkListener(this); - this.context = null; - if (logger.isLoggable(Level.INFO)) logger.info(context.getBundle().getSymbolicName() + " " - + context.getBundle().getHeaders().get("Bundle-Version") - + " stopped."); - } - protected void afterPackIn() { }; - /** - * call when bundle have been started ( after this.context have been set ) - */ - protected void start() { - }; - - /** - * call when bundle is stop ( before this.context is set to null ) - */ - protected void stop() { - } - - @Override - public IDictionaryService addingService( - ServiceReference reference) { - service = context.getService(reference); - return null; - } - - @Override - public void modifiedService(ServiceReference reference, - IDictionaryService service) { - } - - @Override - public void removedService(ServiceReference reference, - IDictionaryService service) { - } - protected void setupPackInContext() { Properties serverContext = new Properties(); serverContext.setProperty("#AD_Client_ID", "0");