billbarker 01/12/10 19:52:35 Modified: jk/java/org/apache/ajp/tomcat4/config ApacheConfig.java BaseJkConfig.java IISConfig.java NSConfig.java Log: Fix the Alias mapping in "static by Apache" mode. Now the Alias directives are handled correctly, even for a Context that is declaired in the server.xml file. Also, a Context that is based in an un-expanded WAR file gets a forwardAll in all configurations. Based on suggestion from Incze Lajos [EMAIL PROTECTED] Revision Changes Path 1.2 +14 -18 jakarta-tomcat-connectors/jk/java/org/apache/ajp/tomcat4/config/ApacheConfig.java Index: ApacheConfig.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-connectors/jk/java/org/apache/ajp/tomcat4/config/ApacheConfig.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- ApacheConfig.java 2001/12/10 03:52:02 1.1 +++ ApacheConfig.java 2001/12/11 03:52:35 1.2 @@ -274,21 +274,6 @@ return new PrintWriter(new FileWriter(abJkConfig, append)); } - /** - executes the ApacheConfig interceptor. This method generates apache - configuration files for use with mod_jk. - <p> - @param <b>context</b> a Context object. - */ - public void executeContext(Context context, PrintWriter mod_jk){ - - if(context.getPath().length() > 0 || ! noRoot ) { - if( forwardAll ) - generateStupidMappings( context, mod_jk ); - else - generateContextMappings( context, mod_jk); - } - } // -------------------- Config sections -------------------- @@ -397,7 +382,7 @@ /** Forward all requests for a context to tomcat. The default. */ - private void generateStupidMappings(Context context, + protected void generateStupidMappings(Context context, PrintWriter mod_jk ) { String ctxPath = context.getPath(); @@ -436,7 +421,7 @@ // -------------------- Apache serves static mode -------------------- // This is not going to work for all apps. We fall back to stupid mode. - private void generateContextMappings(Context context, PrintWriter mod_jk ) + protected void generateContextMappings(Context context, PrintWriter mod_jk ) { String ctxPath = context.getPath(); Host vhost = getHost(context); @@ -463,7 +448,7 @@ String [] servletMaps = context.findServletMappings(); for(int ii=0; ii < servletMaps.length; ii++) { - addMapping( ctxPath+ servletMaps[ii] , mod_jk ); + addMapping( ctxPath, servletMaps[ii] , mod_jk ); } } @@ -486,6 +471,17 @@ if( debug > 0 ) log( "Adding map for " + fullPath ); mod_jk.println(indent + "JkMount " + fullPath + " " + jkWorker ); + return true; + } + /** Add a partially specified Appache mapping. + */ + protected boolean addMapping( String ctxP, String ext, PrintWriter mod_jk ) { + if( debug > 0 ) + log( "Adding map for " + ext ); + if(! ext.startsWith("/") ) + ext = "/" + ext; + if(ext.length() > 1) + mod_jk.println(indent + "JkMount " + ctxP + ext+ " " + jkWorker ); return true; } 1.2 +23 -6 jakarta-tomcat-connectors/jk/java/org/apache/ajp/tomcat4/config/BaseJkConfig.java Index: BaseJkConfig.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-connectors/jk/java/org/apache/ajp/tomcat4/config/BaseJkConfig.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- BaseJkConfig.java 2001/12/10 03:52:02 1.1 +++ BaseJkConfig.java 2001/12/11 03:52:35 1.2 @@ -120,7 +120,7 @@ @author Costin Manolache @author Larry Isaacs @author Bill Barker - @version $Revision: 1.1 $ + @version $Revision: 1.2 $ */ public class BaseJkConfig implements LifecycleListener { protected int debug=0; @@ -247,10 +247,26 @@ } generateVhostTail(hst, mod_jk); } - /** Generate configuration files. Override with method to generate - web server specific configuration. - */ - protected void executeContext(Context ctx, PrintWriter mod_jk) { + /** + executes the ApacheConfig interceptor. This method generates apache + configuration files for use with mod_jk. + <p> + @param <b>context</b> a Context object. + @param <b>mod_jk</b> Writer for output. + */ + public void executeContext(Context context, PrintWriter mod_jk){ + + if(context.getPath().length() > 0 || ! noRoot ) { + String docRoot = context.getServletContext().getRealPath("/"); + if( forwardAll || docRoot == null) + generateStupidMappings( context, mod_jk ); + else + generateContextMappings( context, mod_jk); + } + } + protected void generateStupidMappings(Context context, PrintWriter mod_jk){ + } + protected void generateContextMappings(Context context, PrintWriter mod_jk){ } /** Get the output Writer. Override with method to generate web server specific configuration. @@ -394,7 +410,8 @@ protected String getAbsoluteDocBase(Context context) { // Calculate the absolute path of the document base - String docBase = context.getDocBase(); + String docBase = context.getServletContext().getRealPath("/"); + docBase = docBase.substring(0,docBase.length()-1); if (!isAbsolute(docBase)){ docBase = tomcatHome + "/" + docBase; } 1.2 +8 -22 jakarta-tomcat-connectors/jk/java/org/apache/ajp/tomcat4/config/IISConfig.java Index: IISConfig.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-connectors/jk/java/org/apache/ajp/tomcat4/config/IISConfig.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- IISConfig.java 2001/12/10 03:52:02 1.1 +++ IISConfig.java 2001/12/11 03:52:35 1.2 @@ -201,23 +201,6 @@ return true; } - /** - executes the IISConfig interceptor. This method generates IIS - configuration files for use with isapi_redirect. If not - already set, this method will setConfigHome() to the value returned - from <i>cm.getHome()</i>. - <p> - @param <b>cm</b> a ContextManager object. - */ - public void executeContext(Context context, PrintWriter uri_worker) - { - if( forwardAll ) - generateStupidMappings( context, uri_worker ); - else - generateContextMappings( context, uri_worker ); - - } - // -------------------- Config sections -------------------- /** Writes the registry settings required by the IIS connector @@ -253,7 +236,7 @@ /** Forward all requests for a context to tomcat. The default. */ - private void generateStupidMappings(Context context, PrintWriter uri_worker ) + protected void generateStupidMappings(Context context, PrintWriter uri_worker ) { String ctxPath = context.getPath(); String nPath=("".equals(ctxPath)) ? "/" : ctxPath; @@ -276,7 +259,7 @@ uri_worker.println(nPath +"/*=$(default.worker)"); } - private void generateContextMappings(Context context, PrintWriter uri_worker ) + protected void generateContextMappings(Context context, PrintWriter uri_worker ) { String ctxPath = context.getPath(); String nPath=("".equals(ctxPath)) ? "/" : ctxPath; @@ -302,18 +285,21 @@ String [] servletMaps=context.findServletMappings(); for( int ii=0; ii < servletMaps.length ; ii++) { - addMapping( ctxPath + servletMaps[ii] , uri_worker ); + addMapping( ctxPath , servletMaps[ii] , uri_worker ); } } /** Add an IIS extension mapping. */ - protected boolean addExtensionMapping( String ctxPath, String ext, + protected boolean addMapping( String ctxPath, String ext, PrintWriter uri_worker ) { if( debug > 0 ) log( "Adding extension map for " + ctxPath + "/*." + ext ); - uri_worker.println(ctxPath + "/*." + ext + "=$(default.worker)"); + if(! ext.startsWith("/") ) + ext = "/" + ext; + if(ext.length() > 1) + uri_worker.println(ctxPath + "/*." + ext + "=$(default.worker)"); return true; } 1.2 +9 -21 jakarta-tomcat-connectors/jk/java/org/apache/ajp/tomcat4/config/NSConfig.java Index: NSConfig.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-connectors/jk/java/org/apache/ajp/tomcat4/config/NSConfig.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- NSConfig.java 2001/12/10 03:52:02 1.1 +++ NSConfig.java 2001/12/11 03:52:35 1.2 @@ -223,21 +223,6 @@ mod_jk.println("<Object name=default>"); return true; } - /** - executes the NSConfig interceptor. This method generates Netscape - configuration files for use with nsapi_redirect. If not - already set, this method will setConfigHome() to the value returned - from <i>cm.getHome()</i>. - <p> - @param <b>cm</b> a ContextManager object. - */ - public void executeContext(Context context, PrintWriter mod_jk) - { - if( forwardAll ) - generateStupidMappings( context, mod_jk ); - else - generateContextMappings( context, mod_jk ); - } private void generateNsapiHead(PrintWriter objfile) { @@ -293,7 +278,7 @@ /** Forward all requests for a context to tomcat. The default. */ - private void generateStupidMappings(Context context, PrintWriter objfile ) + protected void generateStupidMappings(Context context, PrintWriter objfile ) { String ctxPath = context.getPath(); String nPath=("".equals(ctxPath)) ? "/" : ctxPath; @@ -311,7 +296,7 @@ // -------------------- Netscape serves static mode -------------------- // This is not going to work for all apps. We fall back to stupid mode. - private void generateContextMappings(Context context, PrintWriter objfile ) + protected void generateContextMappings(Context context, PrintWriter objfile ) { String ctxPath = context.getPath(); String nPath=("".equals(ctxPath)) ? "/" : ctxPath; @@ -336,19 +321,22 @@ String [] servletMaps=context.findServletMappings(); for(int ii=0; ii < servletMaps.length; ii++) { - addMapping( ctxPath + servletMaps[ii] , objfile ); + addMapping( ctxPath , servletMaps[ii] , objfile ); } } /** Add a Netscape extension mapping. */ - protected boolean addExtensionMapping( String ctxPath, String ext, + protected boolean addMapping( String ctxPath, String ext, PrintWriter objfile ) { if( debug > 0 ) log( "Adding extension map for " + ctxPath + "/*." + ext ); - objfile.println("NameTrans fn=\"assign-name\" from=\"" + - ctxPath + "/*." + ext + "\" name=\"" + objectName + "\""); + if(! ext.startsWith("/") ) + ext = "/" + ext; + if(ext.length() > 1) + objfile.println("NameTrans fn=\"assign-name\" from=\"" + + ctxPath + ext + "\" name=\"" + objectName + "\""); return true; }
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>