From aa692e34ef4c0f763a08879ac2a4e2e9fe413c9f Mon Sep 17 00:00:00 2001 From: Adam Heath Date: Wed, 29 Jun 2011 22:12:08 +0000 Subject: [PATCH] OPTIMIZE: Rework part of createContext(), so that the host<->context connection happens in one place. git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1141284 13f79535-47bb-0310-9956-ffa450edef68 --- .../catalina/container/CatalinaContainer.java | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/framework/catalina/src/org/ofbiz/catalina/container/CatalinaContainer.java b/framework/catalina/src/org/ofbiz/catalina/container/CatalinaContainer.java index ba93560186..f89895d087 100644 --- a/framework/catalina/src/org/ofbiz/catalina/container/CatalinaContainer.java +++ b/framework/catalina/src/org/ofbiz/catalina/container/CatalinaContainer.java @@ -589,18 +589,16 @@ public class CatalinaContainer implements Container { context.addParameter(entry.getKey(), entry.getValue()); } + Host host; if (UtilValidate.isEmpty(virtualHosts)) { - Host host = hosts.get(engine.getName() + "._DEFAULT"); - context.setRealm(host.getRealm()); - host.addChild(context); - context.getMapper().setDefaultHostName(host.getName()); + host = hosts.get(engine.getName() + "._DEFAULT"); } else { // assume that the first virtual-host will be the default; additional virtual-hosts will be aliases Iterator vhi = virtualHosts.iterator(); String hostName = vhi.next(); boolean newHost = false; - Host host = hosts.get(engine.getName() + "." + hostName); + host = hosts.get(engine.getName() + "." + hostName); if (host == null) { host = createHost(engine, hostName); newHost = true; @@ -608,14 +606,14 @@ public class CatalinaContainer implements Container { while (vhi.hasNext()) { host.addAlias(vhi.next()); } - context.setRealm(host.getRealm()); - host.addChild(context); - context.getMapper().setDefaultHostName(host.getName()); if (newHost) { hosts.put(engine.getName() + "." + hostName, host); } } + context.setRealm(host.getRealm()); + host.addChild(context); + context.getMapper().setDefaultHostName(host.getName()); return context; }