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 Changes Path 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 @@ xh.addRule( "ContextManager", xh.setProperties() ); setTagRules( xh ); addDefaultTags(cm, xh); + addTagRules( cm, xh ); setBackward( xh ); // load the config file(s) @@ -137,14 +137,14 @@ s="$TOMCAT_HOME" + s.substring( cm.getHome().length()); log( "Config=" + s); // 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); cm.log(sm.getString("tomcat.loading") + " " + f); } -*/ + } } @@ -161,6 +161,27 @@ } } + public void addTagRules( ContextManager cm, XmlMapper xh ) + throws TomcatException + { + Hashtable modules=(Hashtable)cm.getNote("modules"); + if( modules==null) return; + Enumeration keys=modules.keys(); + while( keys.hasMoreElements() ) { + String tag=(String)keys.nextElement(); + String classN=(String)modules.get( tag ); + + xh.addRule( tag , + xh.objectCreate( classN, null )); + xh.addRule( tag , + xh.setProperties()); + xh.addRule( tag, + xh.addChild( "addInterceptor", + "org.apache.tomcat.core.BaseInterceptor")); + } + } + + public static void setTagRules( XmlMapper xh ) { xh.addRule( "module", new XmlAction() { public void start(SaxContext ctx ) throws Exception { @@ -169,8 +190,9 @@ String name=attributes.getValue("name"); String classN=attributes.getValue("javaClass"); if( name==null || classN==null ) return; - XmlMapper mapper=ctx.getMapper(); - ServerXmlReader.addTag( mapper, name, classN ); + ContextManager cm=(ContextManager)ctx.currentObject(); + Hashtable modules=(Hashtable)cm.getNote("modules"); + modules.put( name, classN ); } }); } @@ -183,8 +205,8 @@ return; File f=new File( cm.getHome(), "/conf/modules.xml"); if( f.exists() ) { - // cm.setNote( "configFile", f.getAbsoluteFile()); - cm.setNote( "modules", new Hashtable()); + Hashtable modules=new Hashtable(); + cm.setNote( "modules", modules ); loadConfigFile( xh, f, cm ); // load module-*.xml Vector v = getUserConfigFiles(f); @@ -195,18 +217,6 @@ } } } - - // similar with ant's taskdef - public static void addTag( XmlMapper xh, String tag, String classN) { - xh.addRule( tag , - xh.objectCreate( classN, null )); - xh.addRule( tag , - xh.setProperties()); - xh.addRule( tag, - xh.addChild( "addInterceptor", - "org.apache.tomcat.core.BaseInterceptor")); - } - // -------------------- File utils -------------------- --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, email: [EMAIL PROTECTED]