You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by na...@apache.org on 2001/02/04 23:24:16 UTC

cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/modules/config ContextXmlReader.java ServerXmlReader.java

nacho       01/02/04 14:24:16

  Modified:    src/share/org/apache/tomcat/modules/config
                        ContextXmlReader.java ServerXmlReader.java
  Log:
  Problems with old configs and new config interceptors.
  
  Revision  Changes    Path
  1.2       +4 -4      jakarta-tomcat/src/share/org/apache/tomcat/modules/config/ContextXmlReader.java
  
  Index: ContextXmlReader.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/modules/config/ContextXmlReader.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ContextXmlReader.java	2001/02/01 06:22:08	1.1
  +++ ContextXmlReader.java	2001/02/04 22:24:16	1.2
  @@ -101,9 +101,10 @@
       public void engineInit(ContextManager cm)
   	throws TomcatException
       {
  +        configFile=(String)cm.getNote("configFile");
   	XmlMapper xh=new XmlMapper();
   	xh.setDebug( debug );
  -	// use the same tags for context-local modules 
  +	// use the same tags for context-local modules
   	ServerXmlReader.setTagRules( xh );
   	ServerXmlReader.addDefaultTags(cm, xh);
   	setContextRules( xh );
  @@ -114,9 +115,8 @@
   	if (configFile == null)
   	    configFile=DEFAULT_CONFIG;
   
  -	if( configFile.startsWith( "/" ) ) 
  -	    f=new File(configFile);
  -	else
  +        f=new File(configFile);
  +	if( !f.isAbsolute())
   	    f=new File( cm.getHome(), "/" + configFile);
   
   	if( f.exists() )
  
  
  
  1.3       +22 -18    jakarta-tomcat/src/share/org/apache/tomcat/modules/config/ServerXmlReader.java
  
  Index: ServerXmlReader.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/modules/config/ServerXmlReader.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ServerXmlReader.java	2001/02/02 01:27:42	1.2
  +++ ServerXmlReader.java	2001/02/04 22:24:16	1.3
  @@ -82,6 +82,7 @@
    * @author Costin Manolache
    */
   public class ServerXmlReader extends BaseInterceptor {
  +    int configFileNote;
       private static StringManager sm =
   	StringManager.getManager("org.apache.tomcat.resources");
   
  @@ -90,7 +91,7 @@
       }
   
       // -------------------- Properties --------------------
  -    String configFile=null;   
  +    String configFile=null;
       static final String DEFAULT_CONFIG="conf/server.xml";
   
       public void setConfig( String s ) {
  @@ -101,7 +102,7 @@
   	System.getProperties().put("tomcat.home", h);
       }
   
  -    // -------------------- Hooks -------------------- 
  +    // -------------------- Hooks --------------------
   
       /** When this module is added, it'll automatically load
        *  a configuration file and add all global modules.
  @@ -111,14 +112,13 @@
   	throws TomcatException
       {
   	if( this != module ) return;
  -
   	XmlMapper xh=new XmlMapper();
   	xh.setDebug( debug );
   	xh.addRule( "ContextManager", xh.setProperties() );
   	setTagRules( xh );
   	addDefaultTags(cm, xh);
   	setBackward( xh );
  -	
  +
   	// load the config file(s)
   	File f  = null;
   	if (configFile == null)
  @@ -129,14 +129,17 @@
   	    f=new File( cm.getHome(), File.separator + configFile);
   
   	if( f.exists() ){
  +            cm.setNote( "configFile", f.getAbsolutePath());
   	    loadConfigFile(xh,f,cm);
               // load server-*.xml
  -            Vector v = getUserConfigFiles(f);
  +/*            Vector v = getUserConfigFiles(f);
               for (Enumeration e = v.elements();
                    e.hasMoreElements() ; ) {
                   f = (File)e.nextElement();
                   loadConfigFile(xh,f,cm);
  +
               }
  +*/
           }
       }
   
  @@ -154,7 +157,7 @@
   	}
   	cm.log(sm.getString("tomcat.loaded") + " " + f);
       }
  -    
  +
       public static void setTagRules( XmlMapper xh ) {
   	xh.addRule( "module",  new XmlAction() {
   		public void end(SaxContext ctx ) throws Exception {
  @@ -169,20 +172,21 @@
   	    });
       }
   
  -    // read modules.xml, if any, and load taskdefs 
  +    // read modules.xml, if any, and load taskdefs
       public static  void addDefaultTags( ContextManager cm, XmlMapper xh)
   	throws TomcatException
       {
   	File f=new File( cm.getHome(), "/conf/modules.xml");
   	if( f.exists() ) {
  +            cm.setNote( "configFile", f.getAbsoluteFile());
   	    loadConfigFile( xh, f, cm );
  -	}
  -	// load server-*.xml
  -	Vector v = getUserConfigFiles(f);
  -	for (Enumeration e = v.elements();
  -	     e.hasMoreElements() ; ) {
  -	    f = (File)e.nextElement();
  -	    loadConfigFile(xh,f,cm);
  +            // load module-*.xml
  +            Vector v = getUserConfigFiles(f);
  +            for (Enumeration e = v.elements();
  +                 e.hasMoreElements() ; ) {
  +                f = (File)e.nextElement();
  +                loadConfigFile(xh,f,cm);
  +            }
   	}
       }
   
  @@ -196,7 +200,7 @@
   		    xh.addChild( "addInterceptor",
   				 "org.apache.tomcat.core.BaseInterceptor"));
       }
  -    
  +
   
       // -------------------- File utils --------------------
   
  @@ -206,8 +210,8 @@
   	String[] names = dir.list();
   
   	String masterName=master.getAbsolutePath();
  -	
  -	String base=FileUtil.getBase( masterName ) + "-";
  +
  +	String base=FileUtil.getBase(masterName) + "-";
   	String ext=FileUtil.getExtension( masterName );
   	
   	Vector v = new Vector();
  @@ -222,7 +226,7 @@
   	return v;
       }
   
  -    // -------------------- Backward compatibility -------------------- 
  +    // -------------------- Backward compatibility --------------------
   
       // Read old configuration formats
       private void setBackward( XmlMapper xh ) {