svn commit: r1141285 - /ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/container/CatalinaContainer.java

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

svn commit: r1141285 - /ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/container/CatalinaContainer.java

doogie-3
Author: doogie
Date: Wed Jun 29 22:12:15 2011
New Revision: 1141285

URL: http://svn.apache.org/viewvc?rev=1141285&view=rev
Log:
OPTIMIZE: Reorder createContext(), so that virtual host stuff happens
first, before the context is created/configured.

Modified:
    ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/container/CatalinaContainer.java

Modified: ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/container/CatalinaContainer.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/container/CatalinaContainer.java?rev=1141285&r1=1141284&r2=1141285&view=diff
==============================================================================
--- ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/container/CatalinaContainer.java (original)
+++ ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/container/CatalinaContainer.java Wed Jun 29 22:12:15 2011
@@ -500,14 +500,37 @@ public class CatalinaContainer implement
     }
 
     protected Context createContext(ComponentConfig.WebappInfo appInfo) throws ContainerException {
-        // webapp settings
-        Map<String, String> initParameters = appInfo.getInitParameters();
-        List<String> virtualHosts = appInfo.getVirtualHosts();
         Engine engine = engines.get(appInfo.server);
         if (engine == null) {
             Debug.logWarning("Server with name [" + appInfo.server + "] not found; not mounting [" + appInfo.name + "]", module);
             return null;
         }
+        List<String> virtualHosts = appInfo.getVirtualHosts();
+        Host host;
+        if (UtilValidate.isEmpty(virtualHosts)) {
+            host = hosts.get(engine.getName() + "._DEFAULT");
+        } else {
+            // assume that the first virtual-host will be the default; additional virtual-hosts will be aliases
+            Iterator<String> vhi = virtualHosts.iterator();
+            String hostName = vhi.next();
+
+            boolean newHost = false;
+            host = hosts.get(engine.getName() + "." + hostName);
+            if (host == null) {
+                host = createHost(engine, hostName);
+                newHost = true;
+            }
+            while (vhi.hasNext()) {
+                host.addAlias(vhi.next());
+            }
+
+            if (newHost) {
+                hosts.put(engine.getName() + "." + hostName, host);
+            }
+        }
+
+        // webapp settings
+        Map<String, String> initParameters = appInfo.getInitParameters();
 
         // set the root location (make sure we set the paths correctly)
         String location = appInfo.componentConfig.getRootLocation() + appInfo.location;
@@ -589,28 +612,6 @@ public class CatalinaContainer implement
             context.addParameter(entry.getKey(), entry.getValue());
         }
 
-        Host host;
-        if (UtilValidate.isEmpty(virtualHosts)) {
-            host = hosts.get(engine.getName() + "._DEFAULT");
-        } else {
-            // assume that the first virtual-host will be the default; additional virtual-hosts will be aliases
-            Iterator<String> vhi = virtualHosts.iterator();
-            String hostName = vhi.next();
-
-            boolean newHost = false;
-            host = hosts.get(engine.getName() + "." + hostName);
-            if (host == null) {
-                host = createHost(engine, hostName);
-                newHost = true;
-            }
-            while (vhi.hasNext()) {
-                host.addAlias(vhi.next());
-            }
-
-            if (newHost) {
-                hosts.put(engine.getName() + "." + hostName, host);
-            }
-        }
         context.setRealm(host.getRealm());
         host.addChild(context);
         context.getMapper().setDefaultHostName(host.getName());