tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shac...@locus.apache.org
Subject cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/task ApacheConfig.java
Date Thu, 01 Jun 2000 13:46:46 GMT
shachor     00/06/01 06:46:46

  Modified:    src/share/org/apache/tomcat/task ApacheConfig.java
  Log:
  Create auto apache configuration for mod_jk and IIS uri to worker
  
  Revision  Changes    Path
  1.9       +133 -21   jakarta-tomcat/src/share/org/apache/tomcat/task/ApacheConfig.java
  
  Index: ApacheConfig.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/task/ApacheConfig.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- ApacheConfig.java	2000/04/25 17:54:31	1.8
  +++ ApacheConfig.java	2000/06/01 13:46:46	1.9
  @@ -55,7 +55,7 @@
    *
    * [Additional notices, if required by prior licensing conditions]
    *
  - */ 
  + */
   package org.apache.tomcat.task;
   
   import org.apache.tomcat.core.*;
  @@ -73,40 +73,68 @@
    */
   public class ApacheConfig  { // implements XXX
       // XXX maybe conf/
  -    public static final String APACHE_CONFIG="/conf/tomcat-apache.conf";
  -    
  +    public static final String APACHE_CONFIG  = "/conf/tomcat-apache.conf";
  +    public static final String MOD_JK_CONFIG  = "/conf/mod_jk.conf";
  +    public static final String WORKERS_CONFIG = "/conf/workers.properties";
  +    public static final String URL_WORKERS_MAP_CONFIG = "/conf/uriworkermap.properties";
  +    public static final String JK_LOG_LOCATION = "/log/mod_jk.log";
  +
       public ApacheConfig() {
       }
   
       String findApache() {
   	return null;
       }
  -    
  +
       public void execute(ContextManager cm) throws TomcatException {
   	try {
  -	    String tomcatHome= cm.getHome();
  -	    String apacheHome=findApache();
  -	    
  +	    String tomcatHome = cm.getHome();
  +	    String apacheHome = findApache();
  +
   	    //System.out.println("Tomcat home= " + tomcatHome);
  -	    
  -	    FileWriter configW=new FileWriter( tomcatHome + APACHE_CONFIG);
  -	    PrintWriter pw=new PrintWriter( configW );
   
  +	    FileWriter configW=new FileWriter(tomcatHome + APACHE_CONFIG);
  +	    PrintWriter pw=new PrintWriter(configW);
  +        PrintWriter mod_jk = new PrintWriter(new FileWriter(tomcatHome + MOD_JK_CONFIG));
  +        PrintWriter uri_worker = new PrintWriter(new FileWriter(tomcatHome + URL_WORKERS_MAP_CONFIG));
       
  +
  +        uri_worker.println("###################################################################");
	    
  +        uri_worker.println("# Auto generated configuration. Dated: " +  new Date());
  +        uri_worker.println("###################################################################");
	    
  +        uri_worker.println();
  +
  +        mod_jk.println("###################################################################");
  +        mod_jk.println("# Auto generated configuration. Dated: " +  new Date());
  +        mod_jk.println("###################################################################");
  +        mod_jk.println();
  +        
  +        mod_jk.println("#");
  +        mod_jk.println("# The following line instructs Apache to load the jk module");
  +        mod_jk.println("#");
   	    if( System.getProperty( "os.name" ).toLowerCase().indexOf("windows") >= 0 ) {
   		pw.println("LoadModule jserv_module modules/ApacheModuleJServ.dll");
  +                mod_jk.println("LoadModule jk_module modules/mod_jk.dll");
  +                mod_jk.println();                
  +                mod_jk.println("JkWorkersFile \"" + new File(tomcatHome, WORKERS_CONFIG).toString().replace('\\',
'/') + "\"");
  +                mod_jk.println("JkWorkersFile \"" + new File(tomcatHome, JK_LOG_LOCATION).toString().replace('\\',
'/') + "\"");
   	    } else {
   		// XXX XXX change it to mod_jserv_${os.name}.so, put all so in tomcat
   		// home
   		pw.println("LoadModule jserv_module libexec/mod_jserv.so");
  +                mod_jk.println("LoadModule jk_module libexec/mod_jk.so");
  +                mod_jk.println();                                
  +                mod_jk.println("JkWorkersFile " + new File(tomcatHome, WORKERS_CONFIG));
  +                mod_jk.println("JkWorkersFile " + new File(tomcatHome, JK_LOG_LOCATION));
   	    }
   
  +
   	    pw.println("ApJServManual on");
   	    pw.println("ApJServDefaultProtocol ajpv12");
   	    pw.println("ApJServSecretKey DISABLED");
   	    pw.println("ApJServMountCopy on");
   	    pw.println("ApJServLogLevel notice");
   	    pw.println();
  -	    
  +
   	    // XXX read it from ContextManager
   	    pw.println("ApJServDefaultPort 8007");
   	    pw.println();
  @@ -115,20 +143,42 @@
   	    pw.println("AddHandler jserv-servlet .jsp");
   	    pw.println();
   
  -	    // Set up contexts 
  +        mod_jk.println();
  +        mod_jk.println("#");        
  +        mod_jk.println("# Log level to be used by mod_jk");
  +        mod_jk.println("#");        
  +        mod_jk.println("JkLogLevel error");
  +	    mod_jk.println();
  +
  +        mod_jk.println("#");        
  +        mod_jk.println("# Root context mounts for Tomcat");
  +        mod_jk.println("#");        
  +        mod_jk.println("JkMount /*.jsp ajp12");
  +        mod_jk.println("JkMount /servlet/* ajp12");
  +        mod_jk.println();
  +
  +        uri_worker.println("#");        
  +        uri_worker.println("# Root context mounts for Tomcat");
  +        uri_worker.println("#");        
  +		uri_worker.println("/servlet/*=ajp12");
  +		uri_worker.println("/*.jsp=ajp12"); 
  +        uri_worker.println();            
  +
  +
  +	    // Set up contexts
   	    // XXX deal with Virtual host configuration !!!!
   	    Enumeration enum = cm.getContexts();
   	    while (enum.hasMoreElements()) {
   		Context context = (Context)enum.nextElement();
  -		String path=context.getPath();
  -		String vhost=context.getHost();
  +		String path  = context.getPath();
  +		String vhost = context.getHost();
   
   		if( vhost != null ) {
   		    // Generate Apache VirtualHost section for this host
   		    // You'll have to do it manually right now
  -		    // XXX 
  +		    // XXX
   		    continue;
  -		} 
  +		}
   		if( path.length() > 1) {
   
   		    // It's not the root context
  @@ -145,7 +195,7 @@
   		    pw.println("<Directory \"" + docBase + "\">");
   		    pw.println("    Options Indexes FollowSymLinks");
   		    pw.println("</Directory>");
  -		    
  +
   		    // Dynamic /servet pages go to Tomcat
   		    pw.println("ApJServMount " + path +"/servlet" + " " + path);
   
  @@ -156,6 +206,65 @@
   		    pw.println("</Location>");
   		    pw.println();
   
  +
  +		    // Static files will be served by Apache
  +            mod_jk.println("#########################################################");
	    
  +            mod_jk.println("# Auto configuration for the " + path + " context starts.");
  +            mod_jk.println("#########################################################");
	    
  +            mod_jk.println();
  +            
  +            mod_jk.println("#");		    
  +            mod_jk.println("# The following line makes apache aware of the location of
the " + path + " context");
  +            mod_jk.println("#");                        
  +		    mod_jk.println("Alias " + path + " \"" + docBase + "\"");
  +		    mod_jk.println("<Directory \"" + docBase + "\">");
  +		    mod_jk.println("    Options Indexes FollowSymLinks");
  +		    mod_jk.println("</Directory>");
  +            mod_jk.println();            
  +
  +		    // Dynamic /servet pages go to Tomcat
  +            mod_jk.println("#");		    
  +            mod_jk.println("# The following line mounts all JSP files and the /servlet/
uri to tomcat");
  +            mod_jk.println("#");                        
  +		    mod_jk.println("JkMount " + path +"/servlet ajp12");
  +		    mod_jk.println("JkMount " + path +"/*.jsp ajp12");
  +
  +
  +		    // Deny serving any files from WEB-INF
  +            mod_jk.println();            
  +            mod_jk.println("#");		    
  +            mod_jk.println("# The following line prohibits users from directly access WEB-INF");
  +            mod_jk.println("#");                        
  +		    mod_jk.println("<Location \"" + path + "/WEB-INF/\">");
  +		    mod_jk.println("    AllowOverride None");
  +		    mod_jk.println("    deny from all");
  +		    mod_jk.println("</Location>");
  +		    mod_jk.println();
  +
  +            mod_jk.println("#######################################################");
	    
  +            mod_jk.println("# Auto configuration for the " + path + " context ends.");
  +            mod_jk.println("#######################################################");
	    
  +            mod_jk.println();
  +
  +            // Static files will be served by Apache
  +            uri_worker.println("#########################################################");
	    
  +            uri_worker.println("# Auto configuration for the " + path + " context starts.");
  +            uri_worker.println("#########################################################");
	    
  +            uri_worker.println();
  +            
  +
  +            uri_worker.println("#");		    
  +            uri_worker.println("# The following line mounts all JSP file and the /servlet/
uri to tomcat");
  +            uri_worker.println("#");                        
  +		    uri_worker.println(path +"/servlet/*=ajp12");
  +		    uri_worker.println(path +"/*.jsp=ajp12"); 
  +            uri_worker.println();            
  +
  +            uri_worker.println("#######################################################");
	    
  +            uri_worker.println("# Auto configuration for the " + path + " context ends.");
  +            uri_worker.println("#######################################################");
	    
  +            uri_worker.println();
  +
   		    // SetHandler broken in jserv ( no zone is sent )
   		    // 		    pw.println("<Location " + path + "/servlet/ >");
   		    // 		    pw.println("    AllowOverride None");
  @@ -169,11 +278,11 @@
   			pw.println("    AllowOverride None");
   			pw.println("   AuthName \"restricted \"");
   			pw.println("    AuthType Basic");
  -			pw.println("    AuthUserFile conf/users");	    
  +			pw.println("    AuthUserFile conf/users");
   			pw.println("    require valid-user");
   			pw.println("</Location>");
   		    }
  -				    
  +
   		    // SetHandler broken in jserv ( no zone is sent )
   		    // 		    pw.println("<Location " + path + " >");
   		    // 		    pw.println("    AllowOverride None");
  @@ -185,7 +294,7 @@
   
   		    // XXX mime types - AddEncoding, AddLanguage, TypesConfig
   
  -		    
  +
   		} else {
   		    // the root context
   		    // XXX use a non-conflicting name
  @@ -195,13 +304,16 @@
   	    }
   
   	    pw.close();
  +	    mod_jk.close();
  +	    uri_worker.close();
  +	        
   	} catch( Exception ex ) {
   	    //	    ex.printStackTrace();
   	    //throw new TomcatException( "Error generating Apache config", ex );
   	    System.out.println("Error generating automatic apache configuration " + ex);
   	    ex.printStackTrace(System.out);
   	}
  -	    
  +
       }
   
   }
  
  
  

Mime
View raw message