Return-Path: Delivered-To: apmail-jakarta-tomcat-dev-archive@apache.org Received: (qmail 35955 invoked from network); 5 Apr 2003 03:56:13 -0000 Received: from exchange.sun.com (192.18.33.10) by daedalus.apache.org with SMTP; 5 Apr 2003 03:56:13 -0000 Received: (qmail 13667 invoked by uid 97); 5 Apr 2003 03:58:12 -0000 Delivered-To: qmlist-jakarta-archive-tomcat-dev@nagoya.betaversion.org Received: (qmail 13660 invoked from network); 5 Apr 2003 03:58:12 -0000 Received: from daedalus.apache.org (HELO apache.org) (208.185.179.12) by nagoya.betaversion.org with SMTP; 5 Apr 2003 03:58:12 -0000 Received: (qmail 35042 invoked by uid 500); 5 Apr 2003 03:56:04 -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 35024 invoked by uid 500); 5 Apr 2003 03:56:03 -0000 Received: (qmail 35020 invoked from network); 5 Apr 2003 03:56:03 -0000 Received: from icarus.apache.org (208.185.179.13) by daedalus.apache.org with SMTP; 5 Apr 2003 03:56:03 -0000 Received: (qmail 24527 invoked by uid 1052); 5 Apr 2003 03:56:07 -0000 Date: 5 Apr 2003 03:56:07 -0000 Message-ID: <20030405035607.24526.qmail@icarus.apache.org> From: costin@apache.org To: jakarta-tomcat-catalina-cvs@apache.org Subject: cvs commit: jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core 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 costin 2003/04/04 19:56:07 Modified: catalina/src/share/org/apache/catalina/core StandardContext.java Log: Few more fixes - Amy, that should solve reloading problems ( at least it does for me ). I'm not sure if we do reset everything completely - that's what I'm experimenting with the new method. What needs to happen after stop() is similar with the recycle() in request - no trace of the old context and config should remain. unregister deals with the mapper. Doing few dozens restarts and looking at memory use will probably help Revision Changes Path 1.33 +85 -54 jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/StandardContext.java Index: StandardContext.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/StandardContext.java,v retrieving revision 1.32 retrieving revision 1.33 diff -u -r1.32 -r1.33 --- StandardContext.java 25 Mar 2003 17:55:59 -0000 1.32 +++ StandardContext.java 5 Apr 2003 03:56:07 -0000 1.33 @@ -83,6 +83,8 @@ import javax.management.ObjectName; import javax.management.MBeanServer; import javax.management.MalformedObjectNameException; +import javax.management.InstanceNotFoundException; +import javax.management.MBeanRegistrationException; import org.apache.naming.ContextBindings; import org.apache.naming.resources.BaseDirContext; import org.apache.naming.resources.FileDirContext; @@ -4023,6 +4025,44 @@ } + /** + * Stop this Context component. Experimental, please ignore. + * + * @exception LifecycleException if a shutdown error occurs + */ + public synchronized void stopNew() throws LifecycleException { + // Mark this application as unavailable while we shut down + setAvailable(false); + + // Binding thread + ClassLoader oldCCL = bindThread(); + + try { + // Stop our filters + filterStop(); + + // Finalize our character set mapper + setCharsetMapper(null); + + // Stop our application listeners + listenerStop(); + + // Stop resources + resourcesStop(); + + super.stop(); + } finally { + + // Unbinding thread + unbindThread(oldCCL); + + } + + // Reset application context + context = null; + + wrappers = new ArrayList(); + } /** * Stop this Context component. @@ -4116,11 +4156,18 @@ context = null; wrappers = new ArrayList(); + + // This object will no longer be visible or used. + try { + resetContext(); + } catch( Exception ex ) { + log.error( "Error reseting context " + this + " " + ex, ex ); + } // Notify our interested LifecycleListeners lifecycle.fireLifecycleEvent(AFTER_STOP_EVENT, null); - + if (log.isDebugEnabled()) log.debug("Stopping complete"); } @@ -4139,42 +4186,17 @@ */ public void destroy() throws Exception { super.destroy(); - - + } + + private void resetContext() throws Exception, MBeanRegistrationException { // Restore the original state ( pre reading web.xml in start ) // If you extend this - override this method and make sure to clean up children=new HashMap(); - - StandardContext repl=new StandardContext(); - // All configurable options - repl.setAltDDName(altDDName); - repl.setCachingAllowed(cachingAllowed); - repl.setCharsetMapperClass(mapperClass); - repl.setConfigFile(configFile); - repl.setCookies(cookies); - repl.setCrossContext(crossContext); - repl.setDefaultWebXml(defaultWebXml); - //repl.setDistributable(distributable); // this is from web.xml - repl.setDocBase(docBase); - repl.setJ2EEApplication(j2EEApplication); - repl.setJ2EEServer(j2EEServer); - repl.setLazy(lazy); - repl.setMapperClass(mapperClass); - repl.setName(name); - repl.setOverride(override); - repl.setPath(getPath()); - repl.setPrivileged(privileged); - repl.setReloadable(reloadable); - repl.setReplaceWelcomeFiles(replaceWelcomeFiles); - repl.setSessionTimeout(sessionTimeout); - repl.setUseNaming(useNaming); - repl.setWrapperClass(wrapperClass); - repl.setWorkDir(workDir); - repl.setSwallowOutput(swallowOutput); - - if( oname != null ) - mserver.unregisterMBean(oname); - Registry.getRegistry().registerComponent(repl, oname, null); + log.info("resetContext " + oname + " " + mserver); + if( oname != null ) { + Registry.getRegistry().unregisterComponent(oname); + } + Registry.getRegistry().registerComponent(this, oname, null); } @@ -4761,31 +4783,39 @@ return result; } + public ObjectName createObjectName(String domain, ObjectName parentName) + throws MalformedObjectNameException + { + String onameStr; + StandardHost ctx=(StandardHost)getParent(); + + String pathName=getName(); + String hostName=getParent().getName(); + String name= "//" + ((hostName==null)? "DEFAULT" : hostName) + + (("".equals(pathName))?"/":pathName ); + + String suffix=",J2EEApplication=" + + getJ2EEApplication() + ",J2EEServer=" + + getJ2EEServer(); + + onameStr="j2eeType=WebModule,name=" + name + suffix; + if( log.isDebugEnabled()) + log.debug("Registering " + onameStr + " for " + oname); + + ObjectName oname=new ObjectName(ctx.getDomain()+ ":" + onameStr); + return oname; + } + private void registerJMX() { - String onameStr=null; try { + StandardHost ctx=(StandardHost)getParent(); if( oname==null || oname.getKeyProperty("j2eeType")==null ) { - StandardHost ctx=(StandardHost)parent; - String pathName=getName(); - String hostName=getParent().getName(); - String name= "//" + ((hostName==null)? "DEFAULT" : hostName) + - (("".equals(pathName))?"/":pathName ); - - String suffix=",J2EEApplication=" + - getJ2EEApplication() + ",J2EEServer=" + - getJ2EEServer(); - - onameStr="j2eeType=WebModule,name=" + name + suffix; - if( log.isDebugEnabled()) - log.debug("Registering " + onameStr + " for " + oname); - - ObjectName oname=new ObjectName(ctx.getDomain()+ ":" + onameStr); + oname=createObjectName(ctx.getDomain(), ctx.getObjectName()); log.debug("Checking for " + oname ); if(! Registry.getRegistry().getMBeanServer().isRegistered(oname)) { - Registry.getRegistry().registerComponent(this, - ctx.getDomain(), - "StandardContext", onameStr); + controller=oname; + Registry.getRegistry().registerComponent(this,oname, null); } } for( Iterator it=wrappers.iterator(); it.hasNext() ; ) { @@ -4795,7 +4825,7 @@ } } catch( Exception ex ) { log.info("Error registering ctx with jmx " + this + " " + - onameStr + " " + ex.toString(), ex ); + oname + " " + ex.toString(), ex ); } } @@ -4847,6 +4877,7 @@ ContextConfig config = new ContextConfig(); this.addLifecycleListener(config); + log.debug( "AddChild " + parentName + " " + this); mserver.invoke(parentName, "addChild", new Object[] { this }, new String[] {"org.apache.catalina.Container"}); } --------------------------------------------------------------------- To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org