svn commit: r1624767 - in /ofbiz/trunk/framework/service/src/org/ofbiz/service/config/model: ServiceEngine.java ServiceLocation.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1624767 - in /ofbiz/trunk/framework/service/src/org/ofbiz/service/config/model: ServiceEngine.java ServiceLocation.java

jacopoc
Author: jacopoc
Date: Sat Sep 13 17:05:03 2014
New Revision: 1624767

URL: http://svn.apache.org/r1624767
Log:
Fixed the regression that Jacques introduced with the work on portOffset when the immutability of ServiceLocation was broken; now the class is thread-safe again.
However the portOffset code, before and after my fix, is really ugly and should be reverted completely: the "8080" and "1099" ports, that are configurable in OFBiz, are hardcoded in the portOffset code and so this code can only work when OFBiz is executed with the default ports.


Modified:
    ofbiz/trunk/framework/service/src/org/ofbiz/service/config/model/ServiceEngine.java
    ofbiz/trunk/framework/service/src/org/ofbiz/service/config/model/ServiceLocation.java

Modified: ofbiz/trunk/framework/service/src/org/ofbiz/service/config/model/ServiceEngine.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/org/ofbiz/service/config/model/ServiceEngine.java?rev=1624767&r1=1624766&r2=1624767&view=diff
==============================================================================
--- ofbiz/trunk/framework/service/src/org/ofbiz/service/config/model/ServiceEngine.java (original)
+++ ofbiz/trunk/framework/service/src/org/ofbiz/service/config/model/ServiceEngine.java Sat Sep 13 17:05:03 2014
@@ -87,17 +87,14 @@ public final class ServiceEngine {
         } else {
             List<ServiceLocation> serviceLocations = new ArrayList<ServiceLocation>(serviceLocationElementList.size());
             for (Element serviceLocationElement : serviceLocationElementList) {
-                serviceLocations.add(new ServiceLocation(serviceLocationElement));
-            }
-            for (ServiceLocation serviceLocation : serviceLocations) {
-                String location = serviceLocation.getLocation();
-                if (location.contains("localhost") &&  Start.getInstance().getConfig().portOffset != 0) {
+                String location = serviceLocationElement.getAttribute("location").intern();
+                if (location.contains("localhost") && Start.getInstance().getConfig().portOffset != 0) {
                     Integer port = 1099 + Start.getInstance().getConfig().portOffset;
                     location = location.replace("1099", port.toString());
                     port = 8080 + Start.getInstance().getConfig().portOffset;
                     location = location.replace("8080", port.toString());
-                    serviceLocation.setLocation(location);
-                }                    
+                }
+                serviceLocations.add(new ServiceLocation(serviceLocationElement, location));
             }
             this.serviceLocations = Collections.unmodifiableList(serviceLocations);
         }

Modified: ofbiz/trunk/framework/service/src/org/ofbiz/service/config/model/ServiceLocation.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/org/ofbiz/service/config/model/ServiceLocation.java?rev=1624767&r1=1624766&r2=1624767&view=diff
==============================================================================
--- ofbiz/trunk/framework/service/src/org/ofbiz/service/config/model/ServiceLocation.java (original)
+++ ofbiz/trunk/framework/service/src/org/ofbiz/service/config/model/ServiceLocation.java Sat Sep 13 17:05:03 2014
@@ -28,16 +28,15 @@ import org.w3c.dom.Element;
 @ThreadSafe
 public final class ServiceLocation {
 
-    private String location;
+    private final String location;
     private final String name;
 
-    ServiceLocation(Element serviceLocationElement) throws ServiceConfigException {
+    ServiceLocation(Element serviceLocationElement, String location) throws ServiceConfigException {
         String name = serviceLocationElement.getAttribute("name").intern();
         if (name.isEmpty()) {
             throw new ServiceConfigException("<service-location> element name attribute is empty");
         }
         this.name = name;
-        String location = serviceLocationElement.getAttribute("location").intern();
         if (location.isEmpty()) {
             throw new ServiceConfigException("<service-location> element location attribute is empty");
         }
@@ -48,10 +47,6 @@ public final class ServiceLocation {
         return location;
     }
 
-    public void setLocation(String location) {
-        this.location = location;
-    }
-
     public String getName() {
         return name;
     }