Filip Hanik - Dev Lists <devli...@hanik.com> wrote: >Commits like this, make it very difficult to trace down changes in the >SVN history.
If you configure your diff tool to ignore whitespace (viewvc does this by default) this particular commit shows as a no-op. That and speed, are the main reasons I use viewvc most of the time when investigating history. >I know both Mark and Konstantin are very keen on formatting, to the >point where it overrides the priority of tracing down changes. Some commits - like this one - are impossible to avoid when fixing errors such as using the wrong eol setting. The one off commit is better than the alternative that would see huge commits every time a different committee on a different OS checked in the file. That would make reviews of the commit email pretty much impossible. With an appropriately configured diff tool, pure whitespace commits are easily ignored and do not impact on one's ability to review the history. I find tracking back into 4.1.x and 5.5.x much harder due to the cvs era copies where no history was kept but there isn't much we can do about that. >I may be alone, but I'd prefer that we don't do this mega format entire >file for no apparent purpose commits anymore. It looks like we will have to agree to disagree on that point. Mark > >Filip > >On 10/15/2011 3:47 AM, kkoli...@apache.org wrote: >> Modified: >tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.java >> URL: >http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.java?rev=1183612&r1=1183611&r2=1183612&view=diff >> >============================================================================== >> --- tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.java >(original) >> +++ tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.java >Sat Oct 15 09:47:39 2011 >> @@ -1,2514 +1,2514 @@ >> -/* >> - * Licensed to the Apache Software Foundation (ASF) under one or >more >> - * contributor license agreements. See the NOTICE file distributed >with >> - * this work for additional information regarding copyright >ownership. >> - * The ASF licenses this file to You under the Apache License, >Version 2.0 >> - * (the "License"); you may not use this file except in compliance >with >> - * the License. You may obtain a copy of the License at >> - * >> - * http://www.apache.org/licenses/LICENSE-2.0 >> - * >> - * Unless required by applicable law or agreed to in writing, >software >> - * distributed under the License is distributed on an "AS IS" BASIS, >> - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or >implied. >> - * See the License for the specific language governing permissions >and >> - * limitations under the License. >> - */ >> - >> - >> -package org.apache.catalina.startup; >> - >> - >> -import java.io.BufferedReader; >> -import java.io.File; >> -import java.io.FileInputStream; >> -import java.io.FileNotFoundException; >> -import java.io.IOException; >> -import java.io.InputStream; >> -import java.io.InputStreamReader; >> -import java.io.UnsupportedEncodingException; >> -import java.net.JarURLConnection; >> -import java.net.MalformedURLException; >> -import java.net.URI; >> -import java.net.URISyntaxException; >> -import java.net.URL; >> -import java.net.URLConnection; >> -import java.util.ArrayList; >> -import java.util.Enumeration; >> -import java.util.HashMap; >> -import java.util.HashSet; >> -import java.util.LinkedHashMap; >> -import java.util.LinkedHashSet; >> -import java.util.List; >> -import java.util.Locale; >> -import java.util.Map; >> -import java.util.Properties; >> -import java.util.Set; >> -import java.util.concurrent.ConcurrentHashMap; >> - >> -import javax.servlet.ServletContainerInitializer; >> -import javax.servlet.ServletContext; >> -import javax.servlet.annotation.HandlesTypes; >> - >> -import org.apache.catalina.Authenticator; >> -import org.apache.catalina.Container; >> -import org.apache.catalina.Context; >> -import org.apache.catalina.Engine; >> -import org.apache.catalina.Globals; >> -import org.apache.catalina.Host; >> -import org.apache.catalina.Lifecycle; >> -import org.apache.catalina.LifecycleEvent; >> -import org.apache.catalina.LifecycleListener; >> -import org.apache.catalina.Pipeline; >> -import org.apache.catalina.Server; >> -import org.apache.catalina.Service; >> -import org.apache.catalina.Valve; >> -import org.apache.catalina.Wrapper; >> -import org.apache.catalina.core.ContainerBase; >> -import org.apache.catalina.core.StandardContext; >> -import org.apache.catalina.core.StandardEngine; >> -import org.apache.catalina.core.StandardHost; >> -import org.apache.catalina.deploy.ErrorPage; >> -import org.apache.catalina.deploy.FilterDef; >> -import org.apache.catalina.deploy.FilterMap; >> -import org.apache.catalina.deploy.LoginConfig; >> -import org.apache.catalina.deploy.SecurityConstraint; >> -import org.apache.catalina.deploy.ServletDef; >> -import org.apache.catalina.deploy.WebXml; >> -import org.apache.catalina.util.ContextName; >> -import org.apache.juli.logging.Log; >> -import org.apache.juli.logging.LogFactory; >> -import org.apache.naming.resources.DirContextURLConnection; >> -import org.apache.naming.resources.ResourceAttributes; >> -import org.apache.tomcat.JarScanner; >> -import org.apache.tomcat.JarScannerCallback; >> -import org.apache.tomcat.util.ExceptionUtils; >> -import org.apache.tomcat.util.bcel.classfile.AnnotationElementValue; >> -import org.apache.tomcat.util.bcel.classfile.AnnotationEntry; >> -import org.apache.tomcat.util.bcel.classfile.ArrayElementValue; >> -import org.apache.tomcat.util.bcel.classfile.ClassFormatException; >> -import org.apache.tomcat.util.bcel.classfile.ClassParser; >> -import org.apache.tomcat.util.bcel.classfile.ElementValue; >> -import org.apache.tomcat.util.bcel.classfile.ElementValuePair; >> -import org.apache.tomcat.util.bcel.classfile.JavaClass; >> -import org.apache.tomcat.util.digester.Digester; >> -import org.apache.tomcat.util.digester.RuleSet; >> -import org.apache.tomcat.util.res.StringManager; >> -import org.apache.tomcat.util.scan.Jar; >> -import org.apache.tomcat.util.scan.JarFactory; >> -import org.xml.sax.InputSource; >> -import org.xml.sax.SAXParseException; >> - >> -/** >> - * Startup event listener for a<b>Context</b> that configures the >properties >> - * of that Context, and the associated defined servlets. >> - * >> - * @author Craig R. McClanahan >> - * @author Jean-Francois Arcand >> - * @version $Id$ >> - */ >> - >> -public class ContextConfig >> - implements LifecycleListener { >> - >> - private static final Log log = LogFactory.getLog( >ContextConfig.class ); >> - >> - private static final String SCI_LOCATION = >> - >"META-INF/services/javax.servlet.ServletContainerInitializer"; >> - >> - >> - /** >> - * The string resources for this package. >> - */ >> - protected static final StringManager sm = >> - StringManager.getManager(Constants.Package); >> - >> - >> - protected static final LoginConfig DUMMY_LOGIN_CONFIG = >> - new LoginConfig("NONE", null, null, null); >> - >> - /** >> - * The<code>Digester</code> we will use to process web >application >> - * context files. >> - */ >> - protected static Digester contextDigester = null; >> - >> - >> - /** >> - * The set of Authenticators that we know how to configure. The >key is >> - * the name of the implemented authentication method, and the >value is >> - * the fully qualified Java class name of the corresponding >Valve. >> - */ >> - protected static Properties authenticators = null; >> - >> - >> - /** >> - * The<code>Digester</code>s available to process web deployment >descriptor >> - * files. >> - */ >> - protected static Digester[] webDigesters = new Digester[4]; >> - >> - >> - /** >> - * The<code>Digester</code>s available to process web fragment >deployment >> - * descriptor files. >> - */ >> - protected static Digester[] webFragmentDigesters = new >Digester[4]; >> - >> - >> - /** >> - * The<code>Rule</code>s used to parse the web.xml >> - */ >> - protected static WebRuleSet webRuleSet = new WebRuleSet(false); >> - >> - >> - /** >> - * The<code>Rule</code>s used to parse the web-fragment.xml >> - */ >> - protected static WebRuleSet webFragmentRuleSet = new >WebRuleSet(true); >> - >> - >> - /** >> - * Deployment count. >> - */ >> - protected static long deploymentCount = 0L; >> - >> - >> - /** >> - * Cache of default web.xml fragments per Host >> - */ >> - protected static final Map<Host,DefaultWebXmlCacheEntry> >hostWebXmlCache = >> - new ConcurrentHashMap<Host,DefaultWebXmlCacheEntry>(); >> - >> - >> - // ----------------------------------------------------- >Instance Variables >> - /** >> - * Custom mappings of login methods to authenticators >> - */ >> - protected Map<String,Authenticator> customAuthenticators; >> - >> - >> - /** >> - * The Context we are associated with. >> - */ >> - protected Context context = null; >> - >> - >> - /** >> - * The default web application's context file location. >> - */ >> - protected String defaultContextXml = null; >> - >> - >> - /** >> - * The default web application's deployment descriptor location. >> - */ >> - protected String defaultWebXml = null; >> - >> - >> - /** >> - * Track any fatal errors during startup configuration >processing. >> - */ >> - protected boolean ok = false; >> - >> - >> - /** >> - * Original docBase. >> - */ >> - protected String originalDocBase = null; >> - >> - >> - /** >> - * Map of ServletContainerInitializer to classes they expressed >interest in. >> - */ >> - protected Map<ServletContainerInitializer, Set<Class<?>>> >initializerClassMap = >> - new LinkedHashMap<ServletContainerInitializer, >Set<Class<?>>>(); >> - >> - /** >> - * Map of Types to ServletContainerInitializer that are >interested in those >> - * types. >> - */ >> - protected Map<Class<?>, Set<ServletContainerInitializer>> >typeInitializerMap = >> - new HashMap<Class<?>, Set<ServletContainerInitializer>>(); >> - >> - /** >> - * The<code>Digester</code> we will use to process web >application >> - * deployment descriptor files. >> - */ >> - protected Digester webDigester = null; >> - >> - /** >> - * The<code>Digester</code> we will use to process web fragment >> - * deployment descriptor files. >> - */ >> - protected Digester webFragmentDigester = null; >> - >> - >> - // ------------------------------------------------------------- >Properties >> - /** >> - * Return the location of the default deployment descriptor >> - */ >> - public String getDefaultWebXml() { >> - if( defaultWebXml == null ) { >> - defaultWebXml=Constants.DefaultWebXml; >> - } >> - >> - return (this.defaultWebXml); >> - >> - } >> - >> - >> - /** >> - * Set the location of the default deployment descriptor >> - * >> - * @param path Absolute/relative path to the default web.xml >> - */ >> - public void setDefaultWebXml(String path) { >> - >> - this.defaultWebXml = path; >> - >> - } >> - >> - >> - /** >> - * Return the location of the default context file >> - */ >> - public String getDefaultContextXml() { >> - if( defaultContextXml == null ) { >> - defaultContextXml=Constants.DefaultContextXml; >> - } >> - >> - return (this.defaultContextXml); >> - >> - } >> - >> - >> - /** >> - * Set the location of the default context file >> - * >> - * @param path Absolute/relative path to the default context.xml >> - */ >> - public void setDefaultContextXml(String path) { >> - >> - this.defaultContextXml = path; >> - >> - } >> - >> - >> - /** >> - * Sets custom mappings of login methods to authenticators. >> - * >> - * @param customAuthenticators Custom mappings of login methods >to >> - * authenticators >> - */ >> - public void setCustomAuthenticators( >> - Map<String,Authenticator> customAuthenticators) { >> - this.customAuthenticators = customAuthenticators; >> - } >> - >> - >> - // --------------------------------------------------------- >Public Methods >> - >> - >> - /** >> - * Process events for an associated Context. >> - * >> - * @param event The lifecycle event that has occurred >> - */ >> - @Override >> - public void lifecycleEvent(LifecycleEvent event) { >> - >> - // Identify the context we are associated with >> - try { >> - context = (Context) event.getLifecycle(); >> - } catch (ClassCastException e) { >> - log.error(sm.getString("contextConfig.cce", >event.getLifecycle()), e); >> - return; >> - } >> - >> - // Process the event that has occurred >> - if (event.getType().equals(Lifecycle.CONFIGURE_START_EVENT)) >{ >> - configureStart(); >> - } else if >(event.getType().equals(Lifecycle.BEFORE_START_EVENT)) { >> - beforeStart(); >> - } else if >(event.getType().equals(Lifecycle.AFTER_START_EVENT)) { >> - // Restore docBase for management tools >> - if (originalDocBase != null) { >> - String docBase = context.getDocBase(); >> - context.setDocBase(originalDocBase); >> - originalDocBase = docBase; >> - } >> - } else if >(event.getType().equals(Lifecycle.CONFIGURE_STOP_EVENT)) { >> - if (originalDocBase != null) { >> - String docBase = context.getDocBase(); >> - context.setDocBase(originalDocBase); >> - originalDocBase = docBase; >> - } >> - configureStop(); >> - } else if >(event.getType().equals(Lifecycle.AFTER_INIT_EVENT)) { >> - init(); >> - } else if >(event.getType().equals(Lifecycle.AFTER_DESTROY_EVENT)) { >> - destroy(); >> - } >> - >> - } >> - >> - >> - // -------------------------------------------------------- >protected Methods >> - >> - >> - /** >> - * Process the application classes annotations, if it exists. >> - */ >> - protected void applicationAnnotationsConfig() { >> - >> - long t1=System.currentTimeMillis(); >> - >> - WebAnnotationSet.loadApplicationAnnotations(context); >> - >> - long t2=System.currentTimeMillis(); >> - if (context instanceof StandardContext) { >> - ((StandardContext) context).setStartupTime(t2-t1+ >> - ((StandardContext) context).getStartupTime()); >> - } >> - } >> - >> - >> - /** >> - * Set up an Authenticator automatically if required, and one >has not >> - * already been configured. >> - */ >> - protected synchronized void authenticatorConfig() { >> - >> - LoginConfig loginConfig = context.getLoginConfig(); >> - >> - SecurityConstraint constraints[] = >context.findConstraints(); >> - if (context.getIgnoreAnnotations()&& >> - (constraints == null || constraints.length ==0)&& >> - !context.getPreemptiveAuthentication()) { >> - return; >> - } else { >> - if (loginConfig == null) { >> - // Not metadata-complete or security constraints >present, need >> - // an authenticator to support @ServletSecurity >annotations >> - // and/or constraints >> - loginConfig = DUMMY_LOGIN_CONFIG; >> - context.setLoginConfig(loginConfig); >> - } >> - } >> - >> - // Has an authenticator been configured already? >> - if (context.getAuthenticator() != null) >> - return; >> - >> - if (!(context instanceof ContainerBase)) { >> - return; // Cannot install a Valve even if it would >be needed >> - } >> - >> - // Has a Realm been configured for us to authenticate >against? >> - if (context.getRealm() == null) { >> - log.error(sm.getString("contextConfig.missingRealm")); >> - ok = false; >> - return; >> - } >> - >> - /* >> - * First check to see if there is a custom mapping for the >login >> - * method. If so, use it. Otherwise, check if there is a >mapping in >> - * org/apache/catalina/startup/Authenticators.properties. >> - */ >> - Valve authenticator = null; >> - if (customAuthenticators != null) { >> - authenticator = (Valve) >> - >customAuthenticators.get(loginConfig.getAuthMethod()); >> - } >> - if (authenticator == null) { >> - // Load our mapping properties if necessary >> - if (authenticators == null) { >> - try { >> - InputStream >is=this.getClass().getClassLoader().getResourceAsStream("org/apache/catalina/startup/Authenticators.properties"); >> - if( is!=null ) { >> - authenticators = new Properties(); >> - authenticators.load(is); >> - } else { >> - log.error(sm.getString( >> - >"contextConfig.authenticatorResources")); >> - ok=false; >> - return; >> - } >> - } catch (IOException e) { >> - log.error(sm.getString( >> - >"contextConfig.authenticatorResources"), e); >> - ok = false; >> - return; >> - } >> - } >> - >> - // Identify the class name of the Valve we should >configure >> - String authenticatorName = null; >> - authenticatorName = >> - >authenticators.getProperty(loginConfig.getAuthMethod()); >> - if (authenticatorName == null) { >> - >log.error(sm.getString("contextConfig.authenticatorMissing", >> - loginConfig.getAuthMethod())); >> - ok = false; >> - return; >> - } >> - >> - // Instantiate and install an Authenticator of the >requested class >> - try { >> - Class<?> authenticatorClass = >Class.forName(authenticatorName); >> - authenticator = (Valve) >authenticatorClass.newInstance(); >> - } catch (Throwable t) { >> - ExceptionUtils.handleThrowable(t); >> - log.error(sm.getString( >> - >"contextConfig.authenticatorInstantiate", >> - authenticatorName), >> - t); >> - ok = false; >> - } >> - } >> - >> - if (authenticator != null&& context instanceof >ContainerBase) { >> - Pipeline pipeline = ((ContainerBase) >context).getPipeline(); >> - if (pipeline != null) { >> - ((ContainerBase) >context).getPipeline().addValve(authenticator); >> - if (log.isDebugEnabled()) { >> - log.debug(sm.getString( >> - >"contextConfig.authenticatorConfigured", >> - loginConfig.getAuthMethod())); >> - } >> - } >> - } >> - >> - } >> - >> - >> - /** >> - * Create (if necessary) and return a Digester configured to >process the >> - * web application deployment descriptor (web.xml). >> - */ >> - public void createWebXmlDigester(boolean namespaceAware, >> - boolean validation) { >> - >> - if (!namespaceAware&& !validation) { >> - if (webDigesters[0] == null) { >> - webDigesters[0] = >DigesterFactory.newDigester(validation, >> - namespaceAware, webRuleSet); >> - webFragmentDigesters[0] = >DigesterFactory.newDigester(validation, >> - namespaceAware, webFragmentRuleSet); >> - webDigesters[0].getParser(); >> - webFragmentDigesters[0].getParser(); >> - } >> - webDigester = webDigesters[0]; >> - webFragmentDigester = webFragmentDigesters[0]; >> - >> - } else if (!namespaceAware&& validation) { >> - if (webDigesters[1] == null) { >> - webDigesters[1] = >DigesterFactory.newDigester(validation, >> - namespaceAware, webRuleSet); >> - webFragmentDigesters[1] = >DigesterFactory.newDigester(validation, >> - namespaceAware, webFragmentRuleSet); >> - webDigesters[1].getParser(); >> - webFragmentDigesters[1].getParser(); >> - } >> - webDigester = webDigesters[1]; >> - webFragmentDigester = webFragmentDigesters[1]; >> - >> - } else if (namespaceAware&& !validation) { >> - if (webDigesters[2] == null) { >> - webDigesters[2] = >DigesterFactory.newDigester(validation, >> - namespaceAware, webRuleSet); >> - webFragmentDigesters[2] = >DigesterFactory.newDigester(validation, >> - namespaceAware, webFragmentRuleSet); >> - webDigesters[2].getParser(); >> - webFragmentDigesters[2].getParser(); >> - } >> - webDigester = webDigesters[2]; >> - webFragmentDigester = webFragmentDigesters[2]; >> - >> - } else { >> - if (webDigesters[3] == null) { >> - webDigesters[3] = >DigesterFactory.newDigester(validation, >> - namespaceAware, webRuleSet); >> - webFragmentDigesters[3] = >DigesterFactory.newDigester(validation, >> - namespaceAware, webFragmentRuleSet); >> - webDigesters[3].getParser(); >> - webFragmentDigesters[3].getParser(); >> - } >> - webDigester = webDigesters[3]; >> - webFragmentDigester = webFragmentDigesters[3]; >> - } >> - } >> - >> - >> - /** >> - * Create (if necessary) and return a Digester configured to >process the >> - * context configuration descriptor for an application. >> - */ >> - protected Digester createContextDigester() { >> - Digester digester = new Digester(); >> - digester.setValidating(false); >> - digester.setRulesValidation(true); >> - HashMap<Class<?>, List<String>> fakeAttributes = >> - new HashMap<Class<?>, List<String>>(); >> - ArrayList<String> attrs = new ArrayList<String>(); >> - attrs.add("className"); >> - fakeAttributes.put(Object.class, attrs); >> - digester.setFakeAttributes(fakeAttributes); >> - RuleSet contextRuleSet = new ContextRuleSet("", false); >> - digester.addRuleSet(contextRuleSet); >> - RuleSet namingRuleSet = new NamingRuleSet("Context/"); >> - digester.addRuleSet(namingRuleSet); >> - return digester; >> - } >> - >> - >> - protected String getBaseDir() { >> - Container engineC=context.getParent().getParent(); >> - if( engineC instanceof StandardEngine ) { >> - return ((StandardEngine)engineC).getBaseDir(); >> - } >> - return System.getProperty(Globals.CATALINA_BASE_PROP); >> - } >> - >> - >> - /** >> - * Process the default configuration file, if it exists. >> - */ >> - protected void contextConfig() { >> - >> - // Open the default context.xml file, if it exists >> - if( defaultContextXml==null&& context instanceof >StandardContext ) { >> - defaultContextXml = >((StandardContext)context).getDefaultContextXml(); >> - } >> - // set the default if we don't have any overrides >> - if( defaultContextXml==null ) getDefaultContextXml(); >> - >> - if (!context.getOverride()) { >> - File defaultContextFile = new File(defaultContextXml); >> - if (!defaultContextFile.isAbsolute()) { >> - defaultContextFile =new File(getBaseDir(), >defaultContextXml); >> - } >> - if (defaultContextFile.exists()) { >> - try { >> - URL defaultContextUrl = >defaultContextFile.toURI().toURL(); >> - processContextConfig(defaultContextUrl); >> - } catch (MalformedURLException e) { >> - log.error(sm.getString( >> - "contextConfig.badUrl", >defaultContextFile), e); >> - } >> - } >> - >> - File hostContextFile = new File(getConfigBase(), >> - getHostConfigPath(Constants.HostContextXml)); >> - if (hostContextFile.exists()) { >> - try { >> - URL hostContextUrl = >hostContextFile.toURI().toURL(); >> - processContextConfig(hostContextUrl); >> - } catch (MalformedURLException e) { >> - log.error(sm.getString( >> - "contextConfig.badUrl", >hostContextFile), e); >> - } >> - } >> - } >> - if (context.getConfigFile() != null) >> - processContextConfig(context.getConfigFile()); >> - >> - } >> - >> - >> - /** >> - * Process a context.xml. >> - */ >> - protected void processContextConfig(URL contextXml) { >> - >> - if (log.isDebugEnabled()) >> - log.debug("Processing context [" + context.getName() >> - + "] configuration file [" + contextXml + "]"); >> - >> - InputSource source = null; >> - InputStream stream = null; >> - >> - try { >> - source = new InputSource(contextXml.toString()); >> - stream = contextXml.openStream(); >> - >> - // Add as watched resource so that cascade reload occurs >if a default >> - // config file is modified/added/removed >> - if ("file".equals(contextXml.getProtocol())) { >> - context.addWatchedResource( >> - (new >File(contextXml.toURI())).getAbsolutePath()); >> - } >> - } catch (Exception e) { >> - log.error(sm.getString("contextConfig.contextMissing", >> - contextXml) , e); >> - } >> - >> - if (source == null) >> - return; >> - synchronized (contextDigester) { >> - try { >> - source.setByteStream(stream); >> - >contextDigester.setClassLoader(this.getClass().getClassLoader()); >> - contextDigester.setUseContextClassLoader(false); >> - contextDigester.push(context.getParent()); >> - contextDigester.push(context); >> - XmlErrorHandler errorHandler = new >XmlErrorHandler(); >> - contextDigester.setErrorHandler(errorHandler); >> - contextDigester.parse(source); >> - if (errorHandler.getWarnings().size()> 0 || >> - errorHandler.getErrors().size()> 0) { >> - errorHandler.logFindings(log, >contextXml.toString()); >> - ok = false; >> - } >> - if (log.isDebugEnabled()) >> - log.debug("Successfully processed context [" + >context.getName() >> - + "] configuration file [" + contextXml >+ "]"); >> - } catch (SAXParseException e) { >> - log.error(sm.getString("contextConfig.contextParse", >> - context.getName()), e); >> - >log.error(sm.getString("contextConfig.defaultPosition", >> - "" + e.getLineNumber(), >> - "" + e.getColumnNumber())); >> - ok = false; >> - } catch (Exception e) { >> - log.error(sm.getString("contextConfig.contextParse", >> - context.getName()), e); >> - ok = false; >> - } finally { >> - contextDigester.reset(); >> - try { >> - if (stream != null) { >> - stream.close(); >> - } >> - } catch (IOException e) { >> - >log.error(sm.getString("contextConfig.contextClose"), e); >> - } >> - } >> - } >> - } >> - >> - >> - /** >> - * Adjust docBase. >> - */ >> - protected void fixDocBase() >> - throws IOException { >> - >> - Host host = (Host) context.getParent(); >> - File appBase = host.getAppBaseFile(); >> - >> - String docBase = context.getDocBase(); >> - if (docBase == null) { >> - // Trying to guess the docBase according to the path >> - String path = context.getPath(); >> - if (path == null) { >> - return; >> - } >> - ContextName cn = new ContextName(path, >context.getWebappVersion()); >> - docBase = cn.getBaseName(); >> - } >> - >> - File file = new File(docBase); >> - if (!file.isAbsolute()) { >> - docBase = (new File(appBase, docBase)).getPath(); >> - } else { >> - docBase = file.getCanonicalPath(); >> - } >> - file = new File(docBase); >> - String origDocBase = docBase; >> - >> - ContextName cn = new ContextName(context.getPath(), >> - context.getWebappVersion()); >> - String pathName = cn.getBaseName(); >> - >> - boolean unpackWARs = true; >> - if (host instanceof StandardHost) { >> - unpackWARs = ((StandardHost) host).isUnpackWARs()&& >> - ((StandardContext) context).getUnpackWAR()&& >> - >(docBase.startsWith(host.getAppBaseFile().getPath())); >> - } >> - >> - if (docBase.toLowerCase(Locale.ENGLISH).endsWith(".war")&& >!file.isDirectory()&& unpackWARs) { >> - URL war = new URL("jar:" + (new >File(docBase)).toURI().toURL() + "!/"); >> - docBase = ExpandWar.expand(host, war, pathName); >> - file = new File(docBase); >> - docBase = file.getCanonicalPath(); >> - if (context instanceof StandardContext) { >> - ((StandardContext) >context).setOriginalDocBase(origDocBase); >> - } >> - } else if >(docBase.toLowerCase(Locale.ENGLISH).endsWith(".war")&& >> - !file.isDirectory()&& !unpackWARs) { >> - URL war = >> - new URL("jar:" + (new File >(docBase)).toURI().toURL() + "!/"); >> - ExpandWar.validate(host, war, pathName); >> - } else { >> - File docDir = new File(docBase); >> - if (!docDir.exists()) { >> - File warFile = new File(docBase + ".war"); >> - if (warFile.exists()) { >> - URL war = >> - new URL("jar:" + warFile.toURI().toURL() + >"!/"); >> - if (unpackWARs) { >> - docBase = ExpandWar.expand(host, war, >pathName); >> - file = new File(docBase); >> - docBase = file.getCanonicalPath(); >> - } else { >> - docBase = warFile.getCanonicalPath(); >> - ExpandWar.validate(host, war, pathName); >> - } >> - } >> - if (context instanceof StandardContext) { >> - ((StandardContext) >context).setOriginalDocBase(origDocBase); >> - } >> - } >> - } >> - >> - if (docBase.startsWith(appBase.getPath() + >File.separatorChar)) { >> - docBase = docBase.substring(appBase.getPath().length()); >> - docBase = docBase.replace(File.separatorChar, '/'); >> - if (docBase.startsWith("/")) { >> - docBase = docBase.substring(1); >> - } >> - } else { >> - docBase = docBase.replace(File.separatorChar, '/'); >> - } >> - >> - context.setDocBase(docBase); >> - >> - } >> - >> - >> - protected void antiLocking() { >> - >> - if ((context instanceof StandardContext) >> -&& ((StandardContext) context).getAntiResourceLocking()) { >> - >> - Host host = (Host) context.getParent(); >> - String docBase = context.getDocBase(); >> - if (docBase == null) >> - return; >> - if (originalDocBase == null) { >> - originalDocBase = docBase; >> - } else { >> - docBase = originalDocBase; >> - } >> - File docBaseFile = new File(docBase); >> - if (!docBaseFile.isAbsolute()) { >> - docBaseFile = new File(host.getAppBaseFile(), >docBase); >> - } >> - >> - String path = context.getPath(); >> - if (path == null) { >> - return; >> - } >> - ContextName cn = new ContextName(path, >context.getWebappVersion()); >> - docBase = cn.getBaseName(); >> - >> - File file = null; >> - if --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org