IDEMPIERE-3043 by synchronized. sometime, get list service will wrong
This commit is contained in:
parent
f26db68e2b
commit
f2ca30d27b
|
@ -19,10 +19,12 @@ import org.compiere.util.AdempiereSystemError;
|
|||
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 {
|
||||
public class AdempiereActivator extends AbstractActivator implements FrameworkListener {
|
||||
|
||||
protected final static CLogger logger = CLogger.getCLogger(AdempiereActivator.class.getName());
|
||||
|
||||
|
@ -30,6 +32,7 @@ public class AdempiereActivator extends AbstractActivator {
|
|||
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();
|
||||
|
@ -146,6 +149,7 @@ public class AdempiereActivator extends AbstractActivator {
|
|||
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")
|
||||
|
@ -165,6 +169,34 @@ public class AdempiereActivator extends AbstractActivator {
|
|||
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() {
|
||||
Properties serverContext = new Properties();
|
||||
serverContext.setProperty("#AD_Client_ID", "0");
|
||||
ServerContext.setCurrentInstance(serverContext);
|
||||
};
|
||||
|
||||
@Override
|
||||
public void frameworkEvent(FrameworkEvent event) {
|
||||
if (event.getType() == FrameworkEvent.STARTED) {
|
||||
frameworkStarted();
|
||||
}
|
||||
}
|
||||
|
||||
private void frameworkStarted() {
|
||||
if (service != null) {
|
||||
if (Adempiere.getThreadPoolExecutor() != null) {
|
||||
Adempiere.getThreadPoolExecutor().execute(new Runnable() {
|
||||
@Override
|
||||
|
@ -200,22 +232,6 @@ public class AdempiereActivator extends AbstractActivator {
|
|||
}
|
||||
});
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modifiedService(ServiceReference<IDictionaryService> reference,
|
||||
IDictionaryService service) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removedService(ServiceReference<IDictionaryService> reference,
|
||||
IDictionaryService service) {
|
||||
}
|
||||
|
||||
protected void setupPackInContext() {
|
||||
Properties serverContext = new Properties();
|
||||
serverContext.setProperty("#AD_Client_ID", "0");
|
||||
ServerContext.setCurrentInstance(serverContext);
|
||||
};
|
||||
}
|
||||
|
|
|
@ -38,6 +38,8 @@ 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;
|
||||
|
||||
|
@ -46,7 +48,7 @@ import org.osgi.util.tracker.ServiceTracker;
|
|||
* @author hengsin
|
||||
*
|
||||
*/
|
||||
public class Incremental2PackActivator extends AbstractActivator {
|
||||
public class Incremental2PackActivator extends AbstractActivator implements FrameworkListener {
|
||||
|
||||
protected final static CLogger logger = CLogger.getCLogger(Incremental2PackActivator.class.getName());
|
||||
|
||||
|
@ -54,6 +56,7 @@ public class Incremental2PackActivator extends AbstractActivator {
|
|||
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();
|
||||
|
@ -265,6 +268,7 @@ public class Incremental2PackActivator extends AbstractActivator {
|
|||
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")
|
||||
|
@ -290,6 +294,34 @@ public class Incremental2PackActivator extends AbstractActivator {
|
|||
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() {
|
||||
Properties serverContext = new Properties();
|
||||
serverContext.setProperty("#AD_Client_ID", "0");
|
||||
ServerContext.setCurrentInstance(serverContext);
|
||||
};
|
||||
|
||||
@Override
|
||||
public void frameworkEvent(FrameworkEvent event) {
|
||||
if (event.getType() == FrameworkEvent.STARTED) {
|
||||
frameworkStarted();
|
||||
}
|
||||
}
|
||||
|
||||
private void frameworkStarted() {
|
||||
if (service != null) {
|
||||
if (Adempiere.getThreadPoolExecutor() != null) {
|
||||
Adempiere.getThreadPoolExecutor().execute(new Runnable() {
|
||||
@Override
|
||||
|
@ -325,22 +357,6 @@ public class Incremental2PackActivator extends AbstractActivator {
|
|||
}
|
||||
});
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modifiedService(ServiceReference<IDictionaryService> reference,
|
||||
IDictionaryService service) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removedService(ServiceReference<IDictionaryService> reference,
|
||||
IDictionaryService service) {
|
||||
}
|
||||
|
||||
protected void setupPackInContext() {
|
||||
Properties serverContext = new Properties();
|
||||
serverContext.setProperty("#AD_Client_ID", "0");
|
||||
ServerContext.setCurrentInstance(serverContext);
|
||||
};
|
||||
}
|
||||
|
|
|
@ -42,10 +42,12 @@ 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 {
|
||||
public class PackInApplicationActivator extends AbstractActivator implements FrameworkListener {
|
||||
|
||||
protected final static CLogger logger = CLogger.getCLogger(PackInApplicationActivator.class.getName());
|
||||
private List<File> filesToProcess = new ArrayList<>();
|
||||
|
@ -55,6 +57,7 @@ public class PackInApplicationActivator extends AbstractActivator {
|
|||
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();
|
||||
|
@ -78,6 +81,7 @@ public class PackInApplicationActivator extends AbstractActivator {
|
|||
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")
|
||||
|
@ -87,27 +91,6 @@ public class PackInApplicationActivator extends AbstractActivator {
|
|||
@Override
|
||||
public IDictionaryService addingService(ServiceReference<IDictionaryService> reference) {
|
||||
service = context.getService(reference);
|
||||
if (Adempiere.getThreadPoolExecutor() != null) {
|
||||
Adempiere.getThreadPoolExecutor().execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
int timeout = MSysConfig.getIntValue(MSysConfig.AUTOMATIC_PACKIN_INITIAL_DELAY, 120) * 1000;
|
||||
String folders = MSysConfig.getValue(MSysConfig.AUTOMATIC_PACKIN_FOLDERS);
|
||||
automaticPackin(timeout, folders, true);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
Adempiere.addServerStateChangeListener(new ServerStateChangeListener() {
|
||||
@Override
|
||||
public void stateChange(ServerStateChangeEvent event) {
|
||||
if (event.getEventType() == ServerStateChangeEvent.SERVER_START && service != null) {
|
||||
int timeout = MSysConfig.getIntValue(MSysConfig.AUTOMATIC_PACKIN_INITIAL_DELAY, 120) * 1000;
|
||||
String folders = MSysConfig.getValue(MSysConfig.AUTOMATIC_PACKIN_FOLDERS);
|
||||
automaticPackin(timeout, folders, true);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -411,4 +394,37 @@ public class PackInApplicationActivator extends AbstractActivator {
|
|||
ServerContext.setCurrentInstance(serverContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void frameworkEvent(FrameworkEvent event) {
|
||||
if (event.getType() == FrameworkEvent.STARTED) {
|
||||
frameworkStarted();
|
||||
}
|
||||
}
|
||||
|
||||
private void frameworkStarted() {
|
||||
if (service != null) {
|
||||
if (Adempiere.getThreadPoolExecutor() != null) {
|
||||
Adempiere.getThreadPoolExecutor().execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
int timeout = MSysConfig.getIntValue(MSysConfig.AUTOMATIC_PACKIN_INITIAL_DELAY, 120) * 1000;
|
||||
String folders = MSysConfig.getValue(MSysConfig.AUTOMATIC_PACKIN_FOLDERS);
|
||||
automaticPackin(timeout, folders, true);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
Adempiere.addServerStateChangeListener(new ServerStateChangeListener() {
|
||||
@Override
|
||||
public void stateChange(ServerStateChangeEvent event) {
|
||||
if (event.getEventType() == ServerStateChangeEvent.SERVER_START && service != null) {
|
||||
int timeout = MSysConfig.getIntValue(MSysConfig.AUTOMATIC_PACKIN_INITIAL_DELAY, 120) * 1000;
|
||||
String folders = MSysConfig.getValue(MSysConfig.AUTOMATIC_PACKIN_FOLDERS);
|
||||
automaticPackin(timeout, folders, true);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -38,6 +38,8 @@ 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;
|
||||
|
||||
|
@ -46,7 +48,7 @@ import org.osgi.util.tracker.ServiceTracker;
|
|||
* @author hengsin
|
||||
*
|
||||
*/
|
||||
public class Version2PackActivator extends AbstractActivator {
|
||||
public class Version2PackActivator extends AbstractActivator implements FrameworkListener {
|
||||
|
||||
protected final static CLogger logger = CLogger.getCLogger(Version2PackActivator.class.getName());
|
||||
|
||||
|
@ -54,6 +56,7 @@ public class Version2PackActivator extends AbstractActivator {
|
|||
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();
|
||||
|
@ -233,6 +236,7 @@ public class Version2PackActivator extends AbstractActivator {
|
|||
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")
|
||||
|
@ -258,6 +262,34 @@ public class Version2PackActivator extends AbstractActivator {
|
|||
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() {
|
||||
Properties serverContext = new Properties();
|
||||
serverContext.setProperty("#AD_Client_ID", "0");
|
||||
ServerContext.setCurrentInstance(serverContext);
|
||||
};
|
||||
|
||||
@Override
|
||||
public void frameworkEvent(FrameworkEvent event) {
|
||||
if (event.getType() == FrameworkEvent.STARTED) {
|
||||
frameworkStarted();
|
||||
}
|
||||
}
|
||||
|
||||
private void frameworkStarted() {
|
||||
if (service != null) {
|
||||
if (Adempiere.getThreadPoolExecutor() != null) {
|
||||
Adempiere.getThreadPoolExecutor().execute(new Runnable() {
|
||||
@Override
|
||||
|
@ -293,22 +325,6 @@ public class Version2PackActivator extends AbstractActivator {
|
|||
}
|
||||
});
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modifiedService(ServiceReference<IDictionaryService> reference,
|
||||
IDictionaryService service) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removedService(ServiceReference<IDictionaryService> reference,
|
||||
IDictionaryService service) {
|
||||
}
|
||||
|
||||
protected void setupPackInContext() {
|
||||
Properties serverContext = new Properties();
|
||||
serverContext.setProperty("#AD_Client_ID", "0");
|
||||
ServerContext.setCurrentInstance(serverContext);
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue