You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ar...@apache.org on 2016/07/05 13:45:14 UTC
svn commit: r1751470 - in
/ofbiz/trunk/framework/service/src/org/ofbiz/service: DispatchContext.java
config/ServiceConfigUtil.java eca/ServiceEcaUtil.java
group/ServiceGroupReader.java job/JobPoller.java
Author: arunpatidar
Date: Tue Jul 5 13:45:14 2016
New Revision: 1751470
URL: http://svn.apache.org/viewvc?rev=1751470&view=rev
Log:
Applied patch from jira issue - OFBIZ-7684 - Enforce noninstantiability to ServiceConfigUtil class. Thanks Rahul Singh and Rishi Solanki for your contribution.
Modified:
ofbiz/trunk/framework/service/src/org/ofbiz/service/DispatchContext.java
ofbiz/trunk/framework/service/src/org/ofbiz/service/config/ServiceConfigUtil.java
ofbiz/trunk/framework/service/src/org/ofbiz/service/eca/ServiceEcaUtil.java
ofbiz/trunk/framework/service/src/org/ofbiz/service/group/ServiceGroupReader.java
ofbiz/trunk/framework/service/src/org/ofbiz/service/job/JobPoller.java
Modified: ofbiz/trunk/framework/service/src/org/ofbiz/service/DispatchContext.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/org/ofbiz/service/DispatchContext.java?rev=1751470&r1=1751469&r2=1751470&view=diff
==============================================================================
--- ofbiz/trunk/framework/service/src/org/ofbiz/service/DispatchContext.java (original)
+++ ofbiz/trunk/framework/service/src/org/ofbiz/service/DispatchContext.java Tue Jul 5 13:45:14 2016
@@ -256,7 +256,7 @@ public class DispatchContext implements
throw new RuntimeException(e.getMessage());
}
for (GlobalServices globalServices : globalServicesList) {
- ResourceHandler handler = new MainResourceHandler(ServiceConfigUtil.SERVICE_ENGINE_XML_FILENAME, globalServices.getLoader(), globalServices.getLocation());
+ ResourceHandler handler = new MainResourceHandler(ServiceConfigUtil.getServiceEngineXmlFileName(), globalServices.getLoader(), globalServices.getLocation());
futures.add(ExecutionPool.GLOBAL_FORK_JOIN.submit(createServiceReaderCallable(handler)));
}
Modified: ofbiz/trunk/framework/service/src/org/ofbiz/service/config/ServiceConfigUtil.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/org/ofbiz/service/config/ServiceConfigUtil.java?rev=1751470&r1=1751469&r2=1751470&view=diff
==============================================================================
--- ofbiz/trunk/framework/service/src/org/ofbiz/service/config/ServiceConfigUtil.java (original)
+++ ofbiz/trunk/framework/service/src/org/ofbiz/service/config/ServiceConfigUtil.java Tue Jul 5 13:45:14 2016
@@ -46,12 +46,14 @@ import org.w3c.dom.Element;
public final class ServiceConfigUtil {
public static final String module = ServiceConfigUtil.class.getName();
- public static final String engine = "default";
- public static final String SERVICE_ENGINE_XML_FILENAME = "serviceengine.xml";
+ private static final String engine = "default";
+ private static final String SERVICE_ENGINE_XML_FILENAME = "serviceengine.xml";
// Keep the ServiceConfig instance in a cache - so the configuration can be reloaded at run-time. There will be only one ServiceConfig instance in the cache.
private static final UtilCache<String, ServiceConfig> serviceConfigCache = UtilCache.createUtilCache("service.ServiceConfig", 0, 0, false);
private static final List<ServiceConfigListener> configListeners = new CopyOnWriteArrayList<ServiceConfigListener>();
+ private ServiceConfigUtil() {}
+
/**
* Returns the specified parameter value from the specified engine, or <code>null</code>
* if the engine or parameter are not found.
@@ -131,4 +133,12 @@ public final class ServiceConfigUtil {
Assert.notNull("listener", listener);
configListeners.add(listener);
}
+
+ public static String getEngine() {
+ return engine;
+ }
+
+ public static String getServiceEngineXmlFileName() {
+ return SERVICE_ENGINE_XML_FILENAME;
+ }
}
Modified: ofbiz/trunk/framework/service/src/org/ofbiz/service/eca/ServiceEcaUtil.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/org/ofbiz/service/eca/ServiceEcaUtil.java?rev=1751470&r1=1751469&r2=1751470&view=diff
==============================================================================
--- ofbiz/trunk/framework/service/src/org/ofbiz/service/eca/ServiceEcaUtil.java (original)
+++ ofbiz/trunk/framework/service/src/org/ofbiz/service/eca/ServiceEcaUtil.java Tue Jul 5 13:45:14 2016
@@ -76,7 +76,7 @@ public final class ServiceEcaUtil {
throw new RuntimeException(e.getMessage());
}
for (ServiceEcas serviceEcas : serviceEcasList) {
- ResourceHandler handler = new MainResourceHandler(ServiceConfigUtil.SERVICE_ENGINE_XML_FILENAME, serviceEcas.getLoader(), serviceEcas.getLocation());
+ ResourceHandler handler = new MainResourceHandler(ServiceConfigUtil.getServiceEngineXmlFileName(), serviceEcas.getLoader(), serviceEcas.getLocation());
futures.add(ExecutionPool.GLOBAL_FORK_JOIN.submit(createEcaLoaderCallable(handler)));
}
Modified: ofbiz/trunk/framework/service/src/org/ofbiz/service/group/ServiceGroupReader.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/org/ofbiz/service/group/ServiceGroupReader.java?rev=1751470&r1=1751469&r2=1751470&view=diff
==============================================================================
--- ofbiz/trunk/framework/service/src/org/ofbiz/service/group/ServiceGroupReader.java (original)
+++ ofbiz/trunk/framework/service/src/org/ofbiz/service/group/ServiceGroupReader.java Tue Jul 5 13:45:14 2016
@@ -52,7 +52,7 @@ public class ServiceGroupReader {
throw new RuntimeException(e.getMessage());
}
for (ServiceGroups serviceGroup : serviceGroupsList) {
- ResourceHandler handler = new MainResourceHandler(ServiceConfigUtil.SERVICE_ENGINE_XML_FILENAME, serviceGroup.getLoader(), serviceGroup.getLocation());
+ ResourceHandler handler = new MainResourceHandler(ServiceConfigUtil.getServiceEngineXmlFileName(), serviceGroup.getLoader(), serviceGroup.getLocation());
addGroupDefinitions(handler);
}
Modified: ofbiz/trunk/framework/service/src/org/ofbiz/service/job/JobPoller.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/org/ofbiz/service/job/JobPoller.java?rev=1751470&r1=1751469&r2=1751470&view=diff
==============================================================================
--- ofbiz/trunk/framework/service/src/org/ofbiz/service/job/JobPoller.java (original)
+++ ofbiz/trunk/framework/service/src/org/ofbiz/service/job/JobPoller.java Tue Jul 5 13:45:14 2016
@@ -62,7 +62,7 @@ public final class JobPoller implements
private static ThreadPoolExecutor createThreadPoolExecutor() {
try {
- ThreadPool threadPool = ServiceConfigUtil.getServiceEngine(ServiceConfigUtil.engine).getThreadPool();
+ ThreadPool threadPool = ServiceConfigUtil.getServiceEngine(ServiceConfigUtil.getEngine()).getThreadPool();
return new ThreadPoolExecutor(threadPool.getMinThreads(), threadPool.getMaxThreads(), threadPool.getTtl(),
TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>(threadPool.getJobs()), new JobInvokerThreadFactory(), new ThreadPoolExecutor.AbortPolicy());
} catch (GenericConfigException e) {
@@ -74,7 +74,7 @@ public final class JobPoller implements
private static int pollWaitTime() {
try {
- ThreadPool threadPool = ServiceConfigUtil.getServiceEngine(ServiceConfigUtil.engine).getThreadPool();
+ ThreadPool threadPool = ServiceConfigUtil.getServiceEngine(ServiceConfigUtil.getEngine()).getThreadPool();
return threadPool.getPollDbMillis();
} catch (GenericConfigException e) {
Debug.logError(e, "Exception thrown while getting <thread-pool> model, using default <thread-pool> values: ", module);
@@ -144,7 +144,7 @@ public final class JobPoller implements
@Override
public void onServiceConfigChange(ServiceConfig serviceConfig) {
if (!executor.isShutdown()) {
- ThreadPool threadPool = serviceConfig.getServiceEngine(ServiceConfigUtil.engine).getThreadPool();
+ ThreadPool threadPool = serviceConfig.getServiceEngine(ServiceConfigUtil.getEngine()).getThreadPool();
executor.setCorePoolSize(threadPool.getMinThreads());
executor.setMaximumPoolSize(threadPool.getMaxThreads());
executor.setKeepAliveTime(threadPool.getTtl(), TimeUnit.MILLISECONDS);