IDEMPIERE-3043: fix for bundle install after framework complete run
remove duplicate code, call install 2pack when IDictionaryService exists
This commit is contained in:
parent
42b22108e9
commit
0a6ea1a3e5
|
@ -36,6 +36,7 @@ import org.osgi.framework.BundleActivator;
|
||||||
import org.osgi.framework.BundleContext;
|
import org.osgi.framework.BundleContext;
|
||||||
import org.osgi.framework.FrameworkEvent;
|
import org.osgi.framework.FrameworkEvent;
|
||||||
import org.osgi.framework.FrameworkListener;
|
import org.osgi.framework.FrameworkListener;
|
||||||
|
import org.osgi.framework.ServiceReference;
|
||||||
import org.osgi.util.tracker.ServiceTracker;
|
import org.osgi.util.tracker.ServiceTracker;
|
||||||
import org.osgi.util.tracker.ServiceTrackerCustomizer;
|
import org.osgi.util.tracker.ServiceTrackerCustomizer;
|
||||||
|
|
||||||
|
@ -50,6 +51,30 @@ public abstract class AbstractActivator implements BundleActivator, ServiceTrack
|
||||||
private IProcessUI m_processUI = null;
|
private IProcessUI m_processUI = null;
|
||||||
public static boolean isFrameworkCompletedSrart = false;
|
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<IDictionaryService, IDictionaryService>(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 {
|
protected boolean merge(File zipfile, String version) throws Exception {
|
||||||
boolean success = false;
|
boolean success = false;
|
||||||
|
|
||||||
|
@ -198,12 +223,38 @@ public abstract class AbstractActivator implements BundleActivator, ServiceTrack
|
||||||
|
|
||||||
protected abstract void frameworkStarted();
|
protected abstract void frameworkStarted();
|
||||||
|
|
||||||
protected void registryRunPackin() {
|
/**
|
||||||
if (isFrameworkCompletedSrart) {
|
* call when bundle have been started ( after this.context have been set )
|
||||||
frameworkStarted ();
|
*/
|
||||||
}else {
|
protected void start() {
|
||||||
context.addFrameworkListener(this);
|
};
|
||||||
}
|
|
||||||
|
/**
|
||||||
|
* call when bundle is stop ( before this.context is set to null )
|
||||||
|
*/
|
||||||
|
protected void stop() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getVersion() {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IDictionaryService addingService(
|
||||||
|
ServiceReference<IDictionaryService> reference) {
|
||||||
|
service = context.getService(reference);
|
||||||
|
if (isFrameworkCompletedSrart)
|
||||||
|
frameworkStarted ();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void modifiedService(ServiceReference<IDictionaryService> reference,
|
||||||
|
IDictionaryService service) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removedService(ServiceReference<IDictionaryService> reference,
|
||||||
|
IDictionaryService service) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,6 @@ import java.net.URL;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
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.MSession;
|
import org.compiere.model.MSession;
|
||||||
|
@ -20,28 +19,16 @@ import org.compiere.util.CLogger;
|
||||||
import org.compiere.util.Env;
|
import org.compiere.util.Env;
|
||||||
import org.osgi.framework.BundleContext;
|
import org.osgi.framework.BundleContext;
|
||||||
import org.osgi.framework.FrameworkEvent;
|
import org.osgi.framework.FrameworkEvent;
|
||||||
import org.osgi.framework.ServiceReference;
|
|
||||||
import org.osgi.util.tracker.ServiceTracker;
|
|
||||||
|
|
||||||
public class AdempiereActivator extends AbstractActivator {
|
public class AdempiereActivator extends AbstractActivator {
|
||||||
|
|
||||||
protected final static CLogger logger = CLogger.getCLogger(AdempiereActivator.class.getName());
|
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<IDictionaryService, IDictionaryService>(context, IDictionaryService.class.getName(), this);
|
|
||||||
serviceTracker.open();
|
|
||||||
start();
|
|
||||||
if (logger.isLoggable(Level.INFO)) logger.info(getName() + " " + getVersion() + " ready.");
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return context.getBundle().getSymbolicName();
|
return context.getBundle().getSymbolicName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getVersion() {
|
public String getVersion() {
|
||||||
return (String) context.getBundle().getHeaders().get("Bundle-Version");
|
return (String) context.getBundle().getHeaders().get("Bundle-Version");
|
||||||
}
|
}
|
||||||
|
@ -144,43 +131,9 @@ public class AdempiereActivator extends AbstractActivator {
|
||||||
this.context = 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 install() {
|
||||||
};
|
};
|
||||||
|
|
||||||
protected void start() {
|
|
||||||
};
|
|
||||||
|
|
||||||
protected void stop() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IDictionaryService addingService(
|
|
||||||
ServiceReference<IDictionaryService> reference) {
|
|
||||||
service = context.getService(reference);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void modifiedService(ServiceReference<IDictionaryService> reference,
|
|
||||||
IDictionaryService service) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void removedService(ServiceReference<IDictionaryService> reference,
|
|
||||||
IDictionaryService service) {
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void setupPackInContext() {
|
protected void setupPackInContext() {
|
||||||
Properties serverContext = new Properties();
|
Properties serverContext = new Properties();
|
||||||
serverContext.setProperty("#AD_Client_ID", "0");
|
serverContext.setProperty("#AD_Client_ID", "0");
|
||||||
|
|
|
@ -25,7 +25,6 @@ import java.util.List;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
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.MSession;
|
import org.compiere.model.MSession;
|
||||||
|
@ -38,8 +37,6 @@ import org.compiere.util.CLogger;
|
||||||
import org.compiere.util.Env;
|
import org.compiere.util.Env;
|
||||||
import org.compiere.util.Trx;
|
import org.compiere.util.Trx;
|
||||||
import org.osgi.framework.BundleContext;
|
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());
|
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<IDictionaryService, IDictionaryService>(context, IDictionaryService.class.getName(), this);
|
|
||||||
serviceTracker.open();
|
|
||||||
start();
|
|
||||||
if (logger.isLoggable(Level.INFO)) logger.info(getName() + " " + getVersion() + " ready.");
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return context.getBundle().getSymbolicName();
|
return context.getBundle().getSymbolicName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getVersion() {
|
public String getVersion() {
|
||||||
String version = (String) context.getBundle().getHeaders().get("Bundle-Version");
|
String version = (String) context.getBundle().getHeaders().get("Bundle-Version");
|
||||||
// e.g. 1.0.0.qualifier, check only the "1.0.0" part
|
// e.g. 1.0.0.qualifier, check only the "1.0.0" part
|
||||||
|
@ -262,49 +249,9 @@ public class Incremental2PackActivator extends AbstractActivator {
|
||||||
this.context = 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() {
|
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<IDictionaryService> reference) {
|
|
||||||
service = context.getService(reference);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void modifiedService(ServiceReference<IDictionaryService> reference,
|
|
||||||
IDictionaryService service) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void removedService(ServiceReference<IDictionaryService> reference,
|
|
||||||
IDictionaryService service) {
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void setupPackInContext() {
|
protected void setupPackInContext() {
|
||||||
Properties serverContext = new Properties();
|
Properties serverContext = new Properties();
|
||||||
serverContext.setProperty("#AD_Client_ID", "0");
|
serverContext.setProperty("#AD_Client_ID", "0");
|
||||||
|
|
|
@ -41,9 +41,7 @@ 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.BundleContext;
|
|
||||||
import org.osgi.framework.ServiceReference;
|
import org.osgi.framework.ServiceReference;
|
||||||
import org.osgi.util.tracker.ServiceTracker;
|
|
||||||
|
|
||||||
public class PackInApplicationActivator extends AbstractActivator{
|
public class PackInApplicationActivator extends AbstractActivator{
|
||||||
|
|
||||||
|
@ -51,47 +49,6 @@ public class PackInApplicationActivator extends AbstractActivator{
|
||||||
private List<File> filesToProcess = new ArrayList<>();
|
private List<File> filesToProcess = new ArrayList<>();
|
||||||
private File currentFile;
|
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<IDictionaryService, IDictionaryService>(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<IDictionaryService> reference) {
|
|
||||||
service = context.getService(reference);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void automaticPackin(int timeout, String folders, boolean fromService) {
|
public void automaticPackin(int timeout, String folders, boolean fromService) {
|
||||||
if (fromService) {
|
if (fromService) {
|
||||||
//Initial delay - starting from service
|
//Initial delay - starting from service
|
||||||
|
@ -370,14 +327,6 @@ public class PackInApplicationActivator extends AbstractActivator{
|
||||||
return q.getIDs();
|
return q.getIDs();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void modifiedService(ServiceReference<IDictionaryService> reference, IDictionaryService service) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void removedService(ServiceReference<IDictionaryService> reference, IDictionaryService service) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
if (currentFile != null)
|
if (currentFile != null)
|
||||||
|
|
|
@ -25,7 +25,6 @@ import java.util.List;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
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.MSession;
|
import org.compiere.model.MSession;
|
||||||
|
@ -38,8 +37,6 @@ 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.BundleContext;
|
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());
|
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<IDictionaryService, IDictionaryService>(context, IDictionaryService.class.getName(), this);
|
|
||||||
serviceTracker.open();
|
|
||||||
start();
|
|
||||||
if (logger.isLoggable(Level.INFO)) logger.info(getName() + " " + getVersion() + " ready.");
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return context.getBundle().getSymbolicName();
|
return context.getBundle().getSymbolicName();
|
||||||
}
|
}
|
||||||
|
@ -230,49 +216,9 @@ public class Version2PackActivator extends AbstractActivator{
|
||||||
this.context = 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() {
|
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<IDictionaryService> reference) {
|
|
||||||
service = context.getService(reference);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void modifiedService(ServiceReference<IDictionaryService> reference,
|
|
||||||
IDictionaryService service) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void removedService(ServiceReference<IDictionaryService> reference,
|
|
||||||
IDictionaryService service) {
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void setupPackInContext() {
|
protected void setupPackInContext() {
|
||||||
Properties serverContext = new Properties();
|
Properties serverContext = new Properties();
|
||||||
serverContext.setProperty("#AD_Client_ID", "0");
|
serverContext.setProperty("#AD_Client_ID", "0");
|
||||||
|
|
Loading…
Reference in New Issue