Skip to content

Commit

Permalink
Improved: ‘ServiceDispatcher’ is not meant to be extended
Browse files Browse the repository at this point in the history
(OFBIZ-11032)

This makes the ‘ServiceDispatcher’ class final and replaces the
‘protected’ modifier with ‘private’ for all the fields and methods in
this class.

Thanks Girish Vasmatkar, Jacques Le Roux and Suraj Khurana for the
review.


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1859938 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
mthl committed May 25, 2019
1 parent 410a67a commit 79edce6
Showing 1 changed file with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,29 +64,29 @@
* The global service dispatcher. This is the "engine" part of the
* Service Engine.
*/
public class ServiceDispatcher {
public final class ServiceDispatcher {

public static final String module = ServiceDispatcher.class.getName();
public static final int lruLogSize = 200;
public static final int LOCK_RETRIES = 3;

protected static final Map<RunningService, ServiceDispatcher> runLog = new ConcurrentLinkedHashMap.Builder<RunningService, ServiceDispatcher>().maximumWeightedCapacity(lruLogSize).build();
private static final Map<RunningService, ServiceDispatcher> runLog = new ConcurrentLinkedHashMap.Builder<RunningService, ServiceDispatcher>().maximumWeightedCapacity(lruLogSize).build();
private static ConcurrentHashMap<String, ServiceDispatcher> dispatchers = new ConcurrentHashMap<>();
// FIXME: These fields are not thread-safe. They are modified by EntityDataLoadContainer.
// We need a better design - like have this class query EntityDataLoadContainer if data is being loaded.
private static boolean enableJM = true;
private static boolean enableJMS = UtilProperties.getPropertyAsBoolean("service", "enableJMS", true);
private static boolean enableSvcs = true;

protected Delegator delegator = null;
protected GenericEngineFactory factory = null;
protected Security security = null;
protected Map<String, DispatchContext> localContext = new HashMap<>();
protected Map<String, List<GenericServiceCallback>> callbacks = new HashMap<>();
protected JobManager jm = null;
protected JmsListenerFactory jlf = null;
private Delegator delegator = null;
private GenericEngineFactory factory = null;
private Security security = null;
private Map<String, DispatchContext> localContext = new HashMap<>();
private Map<String, List<GenericServiceCallback>> callbacks = new HashMap<>();
private JobManager jm = null;
private JmsListenerFactory jlf = null;

protected ServiceDispatcher(Delegator delegator, boolean enableJM, boolean enableJMS) {
private ServiceDispatcher(Delegator delegator, boolean enableJM, boolean enableJMS) {
factory = new GenericEngineFactory(this);
ServiceGroupReader.readConfig();
ServiceEcaUtil.readConfig();
Expand Down Expand Up @@ -132,7 +132,7 @@ protected ServiceDispatcher(Delegator delegator, boolean enableJM, boolean enabl
}
}

protected ServiceDispatcher(Delegator delegator) {
private ServiceDispatcher(Delegator delegator) {
this(delegator, enableJM, enableJMS);
}

Expand Down Expand Up @@ -880,7 +880,7 @@ public boolean containsContext(String name) {
return localContext.containsKey(name);
}

protected void shutdown() throws GenericServiceException {
private void shutdown() throws GenericServiceException {
Debug.logImportant("Shutting down the service engine...", module);
if (jlf != null) {
// shutdown JMS listeners
Expand Down

0 comments on commit 79edce6

Please sign in to comment.