cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/modules/config ContextXmlReader.java ServerXmlReader.java
costin 01/02/27 09:09:40 Modified:src/share/org/apache/tomcat/modules/config ContextXmlReader.java ServerXmlReader.java Log: Small change in reading module definitions. All modules will be read and saved in a CM note ( by ServerXmlReader ). Any module needing module definition can use the note ( instead of reading again modules.xml ). ( modules.xml contains ant-like taskdefs, associating a tag name with a class name implementing BaseInterceptor - not Task :-) Other information can be added to modules.xml ( and be processed by a tool like /admin ). Revision ChangesPath 1.6 +17 -46 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.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- ContextXmlReader.java 2001/02/20 03:16:51 1.5 +++ ContextXmlReader.java 2001/02/27 17:09:37 1.6 @@ -108,8 +108,7 @@ xh.setDebug( debug ); // use the same tags for context-local modules - setTagRules( xh ); - addDefaultTags(cm, xh); + addTagRules(cm, xh); setContextRules( xh ); setBackward( xh ); @@ -211,54 +210,26 @@ } // - -public static void setTagRules( XmlMapper xh ) { - xh.addRule( "module", new XmlAction() { - public void start(SaxContext ctx ) throws Exception { - Object elem=ctx.currentObject(); - AttributeList attributes = ctx.getCurrentAttributes(); - String name=attributes.getValue("name"); - String classN=attributes.getValue("javaClass"); - if( name==null || classN==null ) return; - XmlMapper mapper=ctx.getMapper(); - ContextXmlReader.addTag( mapper, name, classN ); - } - }); -} -// read modules.xml, if any, and load taskdefs -public static void addDefaultTags( ContextManager cm, - XmlMapper xh) +public void addTagRules( ContextManager cm, XmlMapper xh ) throws TomcatException { - File f=new File( cm.getHome(), "/conf/modules.xml"); - if( f.exists() ) { - //cm.setNote( "configFile", f.getAbsoluteFile()); - // cm.setNote( "modules", new Hashtable()); - ServerXmlReader.loadConfigFile( xh, f, cm ); -// load module-*.xml -Vector v = ServerXmlReader.getUserConfigFiles(f); -for (Enumeration e = v.elements(); - e.hasMoreElements() ; ) { -f = (File)e.nextElement(); -ServerXmlReader.loadConfigFile(xh,f,cm); -} + Hashtable modules=(Hashtable)cm.getNote("modules"); + if( modules==null) return; + Enumeration keys=modules.keys(); + while( keys.hasMoreElements() ) { + String name=(String)keys.nextElement(); + String classN=(String)modules.get( name ); + + String tag="Context" + "/" + name; + xh.addRule( tag , + xh.objectCreate( classN, null )); + xh.addRule( tag , + xh.setProperties()); + xh.addRule( tag, + xh.addChild( "addInterceptor", + "org.apache.tomcat.core.BaseInterceptor")); } } - -// similar with ant's taskdef -public static void addTag( XmlMapper xh, String tag, String classN) { - - tag="Context" + "/" + tag; - xh.addRule( tag , - xh.objectCreate( classN, null )); - xh.addRule( tag , - xh.setProperties()); - xh.addRule( tag, - xh.addChild( "addInterceptor", - "org.apache.tomcat.core.BaseInterceptor")); -} - - } 1.7 +29 -19 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.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- ServerXmlReader.java 2001/02/20 03:16:52 1.6 +++ ServerXmlReader.java 2001/02/27 17:09:37 1.7 @@ -83,7 +83,6 @@ * @author Costin Manolache */ public class ServerXmlReader extends BaseInterceptor { -int configFileNote; private static StringManager sm = StringManager.getManager("org.apache.tomcat.resources"); @@ -118,6 +117,7 @@
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 ChangesPath 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 +