costin 01/03/07 17:09:53
Modified: src/share/org/apache/tomcat/modules/config
ContextXmlReader.java ServerXmlReader.java
src/share/org/apache/tomcat/modules/generators
StaticInterceptor.java
Log:
Added code to support ant properties in the config file.
This is not completed, but should work fine for global
modules.
This doesn't/shouldn't affect the code stability in any way - if you don't
use properties nothing will change in tomcat's behavior.
This should allow us to clean/clarify the paths and what's relative
to what, and provide more flexibility in the configuraton.
Revision Changes Path
1.7 +1 -1
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.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- ContextXmlReader.java 2001/02/27 17:09:37 1.6
+++ ContextXmlReader.java 2001/03/08 01:09:50 1.7
@@ -152,7 +152,7 @@
xh.setParent("setContextManager") );
// Virtual host support - if Context is inside a <Host>
- xh.addRule( "Host", xh.setVariable( "current_host", "name"));
+ xh.addRule( "Host", xh.setVar( "current_host", "name"));
xh.addRule( "Host", xh.setProperties());
xh.addRule( "Context", new XmlAction() {
1.8 +46 -0
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.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- ServerXmlReader.java 2001/02/27 17:09:37 1.7
+++ ServerXmlReader.java 2001/03/08 01:09:50 1.8
@@ -70,6 +70,7 @@
import org.apache.tomcat.core.*;
import org.apache.tomcat.modules.server.*;
import org.apache.tomcat.util.log.*;
+import org.apache.tomcat.util.IntrospectionUtils;
import org.xml.sax.*;
/**
@@ -115,6 +116,7 @@
XmlMapper xh=new XmlMapper();
xh.setDebug( debug );
xh.addRule( "ContextManager", xh.setProperties() );
+ setPropertiesRules( cm, xh );
setTagRules( xh );
addDefaultTags(cm, xh);
addTagRules( cm, xh );
@@ -161,6 +163,48 @@
}
}
+ static class CMPropertySource
+ implements IntrospectionUtils.PropertySource
+ {
+ ContextManager cm;
+
+ CMPropertySource( ContextManager cm ) {
+ this.cm=cm;
+ }
+
+ public String getProperty( String key ) {
+ if( "tomcat.home".equals( key ) ) {
+ return cm.getHome();
+ }
+ // XXX add other "predefined" properties
+ return cm.getProperty( key );
+ }
+ }
+
+ public void setPropertiesRules( ContextManager cm, XmlMapper xh )
+ throws TomcatException
+ {
+ CMPropertySource propS=new CMPropertySource( cm );
+ xh.setPropertySource( propS );
+
+ xh.addRule( "ContextManager/property", new XmlAction() {
+ public void start(SaxContext ctx ) throws Exception {
+ AttributeList attributes = ctx.getCurrentAttributes();
+ String name=attributes.getValue("name");
+ String value=attributes.getValue("value");
+ if( name==null || value==null ) return;
+ XmlMapper xm=ctx.getMapper();
+
+ ContextManager cm1=(ContextManager)ctx.currentObject();
+ // replace ${foo} in value
+ value=xm.replaceProperties( value );
+ if( cm1.getDebug() > 0 )
+ cm1.log("Setting " + name + "=" + value);
+ cm1.setProperty( name, value );
+ }
+ });
+ }
+
public void addTagRules( ContextManager cm, XmlMapper xh )
throws TomcatException
{
@@ -224,6 +268,7 @@
public static Vector getUserConfigFiles(File master) {
File dir = new File(master.getParent());
String[] names = dir.list();
+ // System.out.println("getUserConfigFiles " + dir );
String masterName=master.getAbsolutePath();
@@ -231,6 +276,7 @@
String ext=FileUtil.getExtension( masterName );
Vector v = new Vector();
+ if( names==null ) return v;
for (int i=0; i<names.length; ++i) {
if( names[i].startsWith( base )
&& ( ext==null || names[i].endsWith( ext )) ) {
1.6 +3 -1
jakarta-tomcat/src/share/org/apache/tomcat/modules/generators/StaticInterceptor.java
Index: StaticInterceptor.java
===================================================================
RCS file:
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/modules/generators/StaticInterceptor.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- StaticInterceptor.java 2001/02/20 03:16:52 1.5
+++ StaticInterceptor.java 2001/03/08 01:09:52 1.6
@@ -90,7 +90,7 @@
}
public void engineInit(ContextManager cm) throws TomcatException {
- super.engineInit( cm );
+ // if( debug>0 ) log("Engine init " );
try {
realFileNote = cm.getNoteId( ContextManager.REQUEST_NOTE,
@@ -104,6 +104,7 @@
public void contextInit( Context ctx)
throws TomcatException
{
+ //if( debug>0 ) log("Ctx init " + ctx );
FileHandler fileHandler=new FileHandler();
DirHandler dirHandler=new DirHandler();
fileHandler.setModule( this );
@@ -119,6 +120,7 @@
}
public int requestMap(Request req) {
+ // if( debug>0 ) log("Req map " + req);
if( req.getHandler() != null )
return 0;
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]