Skip to content


Improved: Rewrite ‘AbstractEngine#createLocationMap’ (OFBIZ-10810)
Browse files Browse the repository at this point in the history
This adds some documentation and uses the ‘forEach’ method instead of
a ‘for’ loop.

git-svn-id: 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
mthl committed Mar 2, 2019
1 parent 9833660 commit 7c5cebb
Showing 1 changed file with 13 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,32 +37,33 @@
public abstract class AbstractEngine implements GenericEngine {

public static final String module = AbstractEngine.class.getName();
/** Map containing aliases for service implementation locations. */
protected static final Map<String, String> locationMap = createLocationMap();

protected ServiceDispatcher dispatcher = null;
protected ServiceDispatcher dispatcher;

protected AbstractEngine(ServiceDispatcher dispatcher) {
this.dispatcher = dispatcher;

// creates the location alias map
* Instantiates the location map.
* @return an immutable location map.
protected static Map<String, String> createLocationMap() {
Map<String, String> tmpMap = new HashMap<>();

List<ServiceLocation> locationsList = null;
Map<String, String> tmp = new HashMap<>();
List<ServiceLocation> locations;
try {
locationsList = ServiceConfigUtil.getServiceEngine().getServiceLocations();
locations = ServiceConfigUtil.getServiceEngine().getServiceLocations();
} catch (GenericConfigException e) {
// FIXME: Refactor API so exceptions can be thrown and caught.
Debug.logError(e, module);
throw new RuntimeException(e.getMessage());
for (ServiceLocation e: locationsList) {
tmpMap.put(e.getName(), e.getLocation());

Debug.logInfo("Loaded Service Locations: " + tmpMap, module);
return Collections.unmodifiableMap(tmpMap);
locations.forEach(loc -> tmp.put(loc.getName(), loc.getLocation()));
Debug.logInfo("Loaded Service Locations: " + tmp, module);
return Collections.unmodifiableMap(tmp);

Expand Down

0 comments on commit 7c5cebb

Please sign in to comment.