Return-Path: Delivered-To: apmail-jakarta-tomcat-dev-archive@apache.org Received: (qmail 35618 invoked from network); 26 Sep 2002 10:25:23 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 26 Sep 2002 10:25:23 -0000 Received: (qmail 25147 invoked by uid 97); 26 Sep 2002 10:26:02 -0000 Delivered-To: qmlist-jakarta-archive-tomcat-dev@jakarta.apache.org Received: (qmail 25125 invoked by uid 97); 26 Sep 2002 10:26:01 -0000 Mailing-List: contact tomcat-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Tomcat Developers List" Reply-To: "Tomcat Developers List" Delivered-To: mailing list tomcat-dev@jakarta.apache.org Received: (qmail 25104 invoked by uid 97); 26 Sep 2002 10:26:00 -0000 X-Antivirus: nagoya (v4218 created Aug 14 2002) Date: 26 Sep 2002 10:25:03 -0000 Message-ID: <20020926102503.2056.qmail@icarus.apache.org> From: remm@apache.org To: jakarta-tomcat-4.0-cvs@apache.org Subject: cvs commit: jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core LocalStrings.properties StandardContext.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N remm 2002/09/26 03:25:03 Modified: catalina/src/share/org/apache/catalina/core LocalStrings.properties StandardContext.java Log: - Fix bug 13015. - Refactor resources lifecycle handling (it should be clean this time). - Resources cannot be changed while Catalina is running. Revision Changes Path 1.46 +3 -0 jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/LocalStrings.properties Index: LocalStrings.properties =================================================================== RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/LocalStrings.properties,v retrieving revision 1.45 retrieving revision 1.46 diff -u -r1.45 -r1.46 --- LocalStrings.properties 20 Mar 2002 12:29:55 -0000 1.45 +++ LocalStrings.properties 26 Sep 2002 10:25:03 -0000 1.46 @@ -61,6 +61,9 @@ standardContext.reloadingCompleted=Reloading this Context is completed standardContext.reloadingFailed=Reloading this Context failed due to previous errors standardContext.reloadingStarted=Reloading this Context has started +standardContext.resources.started=Cannot change resources while context is started +standardContext.resourcesStart=Resources start failed: +standardContext.resourcesStop=Resources start failed: standardContext.securityConstraint.pattern=Invalid {0} in security constraint standardContext.servletMap.name=Servlet mapping specifies an unknown servlet name {0} standardContext.servletMap.pattern=Invalid {0} in servlet mapping 1.113 +93 -39 jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardContext.java Index: StandardContext.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardContext.java,v retrieving revision 1.112 retrieving revision 1.113 diff -u -r1.112 -r1.113 --- StandardContext.java 9 Sep 2002 14:39:37 -0000 1.112 +++ StandardContext.java 26 Sep 2002 10:25:03 -0000 1.113 @@ -488,6 +488,12 @@ protected boolean cachingAllowed = true; + /** + * Non proxied resources. + */ + protected DirContext webappResources = null; + + // ----------------------------------------------------- Context Properties @@ -1145,15 +1151,28 @@ */ public synchronized void setResources(DirContext resources) { + if (started) { + throw new IllegalStateException + (sm.getString("standardContext.resources.started")); + } + + DirContext oldResources = this.webappResources; + if (oldResources == resources) + return; + if (resources instanceof BaseDirContext) { ((BaseDirContext) resources).setCached(isCachingAllowed()); } if (resources instanceof FileDirContext) { filesystemBased = true; } - super.setResources(resources); - if (started) - postResources(); // As a servlet context attribute + this.webappResources = resources; + + // The proxied resources will be refreshed on start + this.resources = null; + + support.firePropertyChange("resources", oldResources, + this.webappResources); } @@ -3303,6 +3322,66 @@ /** + * Allocate resources, including proxy. + * Return true if initialization was successfull, + * or false otherwise. + */ + public boolean resourcesStart() { + + boolean ok = true; + + Hashtable env = new Hashtable(); + if (getParent() != null) + env.put(ProxyDirContext.HOST, getParent().getName()); + env.put(ProxyDirContext.CONTEXT, getName()); + + try { + ProxyDirContext proxyDirContext = + new ProxyDirContext(env, webappResources); + if (webappResources instanceof BaseDirContext) { + ((BaseDirContext) webappResources).setDocBase(getBasePath()); + ((BaseDirContext) webappResources).allocate(); + } + this.resources = proxyDirContext; + } catch (Throwable t) { + log(sm.getString("standardContext.resourcesStart", t)); + ok = false; + } + + return (ok); + + } + + + /** + * Deallocate resources and destroy proxy. + */ + public boolean resourcesStop() { + + boolean ok = true; + + try { + if (resources != null) { + if (resources instanceof Lifecycle) { + ((Lifecycle) resources).stop(); + } + if (webappResources instanceof BaseDirContext) { + ((BaseDirContext) webappResources).release(); + } + } + } catch (Throwable t) { + log(sm.getString("standardContext.resourcesStop", t)); + ok = false; + } + + this.resources = null; + + return (ok); + + } + + + /** * Load and initialize all servlets marked "load on startup" in the * web application deployment descriptor. * @@ -3376,7 +3455,7 @@ boolean ok = true; // Add missing components as necessary - if (getResources() == null) { // (1) Required by Loader + if (webappResources == null) { // (1) Required by Loader if (debug >= 1) log("Configuring default Resources"); try { @@ -3389,14 +3468,9 @@ ok = false; } } - if (ok && (resources instanceof ProxyDirContext)) { - DirContext dirContext = - ((ProxyDirContext) resources).getDirContext(); - if ((dirContext != null) - && (dirContext instanceof BaseDirContext)) { - ((BaseDirContext) dirContext).setDocBase(getBasePath()); - ((BaseDirContext) dirContext).allocate(); - } + if (ok) { + if (!resourcesStart()) + ok = false; } if (getLoader() == null) { // (2) Required by Manager if (getPrivileged()) { @@ -3622,29 +3696,9 @@ // Stop our application listeners listenerStop(); - // Stop our subordinate components, if any - if (resources != null) { - if (resources instanceof Lifecycle) { - ((Lifecycle) resources).stop(); - } else if (resources instanceof ProxyDirContext) { - DirContext dirContext = - ((ProxyDirContext) resources).getDirContext(); - if (dirContext != null) { - if (debug >= 1) { - log("Releasing document base " + docBase); - } - if (dirContext instanceof BaseDirContext) { - ((BaseDirContext) dirContext).release(); - if ((dirContext instanceof WARDirContext) - || (dirContext instanceof FileDirContext)) { - resources = null; - } - } else { - log("Cannot release " + resources); - } - } - } - } + // Stop resources + resourcesStop(); + if ((realm != null) && (realm instanceof Lifecycle)) { ((Lifecycle) realm).stop(); } -- To unsubscribe, e-mail: For additional commands, e-mail: