tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lar...@apache.org
Subject cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/modules/config ApacheConfig.java
Date Thu, 16 Aug 2001 05:22:41 GMT
larryi      01/08/15 22:22:41

  Modified:    src/share/org/apache/tomcat/modules/config ApacheConfig.java
  Log:
  Update to avoid writing duplicate NameVirtualHost directives.  Also,
  if the context's host name is an ip address, or a host ip address is specified,
  then that address is used for the NameVirtualHost and <VirtualHost>
  directives.
  
  Added generation of NameVirtualHost to generateContextMappings().
  
  Revision  Changes    Path
  1.25      +32 -8     jakarta-tomcat/src/share/org/apache/tomcat/modules/config/ApacheConfig.java
  
  Index: ApacheConfig.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/modules/config/ApacheConfig.java,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- ApacheConfig.java	2001/08/16 00:27:07	1.24
  +++ ApacheConfig.java	2001/08/16 05:22:41	1.25
  @@ -1,4 +1,4 @@
  -/* $Id: ApacheConfig.java,v 1.24 2001/08/16 00:27:07 costin Exp $
  +/* $Id: ApacheConfig.java,v 1.25 2001/08/16 05:22:41 larryi Exp $
    * ====================================================================
    *
    * The Apache Software License, Version 1.1
  @@ -146,7 +146,7 @@
       @author Costin Manolache
       @author Larry Isaacs
       @author Mel Martinez
  -	@version $Revision: 1.24 $ $Date: 2001/08/16 00:27:07 $
  +	@version $Revision: 1.25 $ $Date: 2001/08/16 05:22:41 $
    */
   public class ApacheConfig  extends BaseJkConfig { 
       
  @@ -182,6 +182,8 @@
       private String sslSessionIndicator="SSL_SESSION_ID";
       private String sslCipherIndicator="SSL_CIPHER";
       private String sslCertsIndicator="SSL_CLIENT_CERT";
  +
  +    Hashtable NamedVirtualHosts=null;
       
       public ApacheConfig() {
       }
  @@ -254,7 +256,7 @@
       */
       protected void initProperties(ContextManager cm) {
           super.initProperties(cm);
  -	
  +
   	jkConfig=FileUtil.getConfigFile( jkConfig, configHome, MOD_JK_CONFIG);
   	workersConfig=FileUtil.getConfigFile( workersConfig, configHome,
   				     WORKERS_CONFIG);
  @@ -280,6 +282,8 @@
   	    initProperties(cm);
   	    initProtocol(cm);
   
  +            NamedVirtualHosts = new Hashtable();  
  +
   	    StringBuffer sb=new StringBuffer();
       	    PrintWriter mod_jk = new PrintWriter(new FileWriter(jkConfig));
       	    log("Generating apache mod_jk config = "+jkConfig );
  @@ -402,8 +406,10 @@
               return;
           } 
   	if( vhost != null ) {
  -	    generateNameVirtualHost(mod_jk );
  -	    mod_jk.println("<VirtualHost *>");
  +            String vhostip = getVirtualHostAddress(vhost,
  +                                            context.getHostAddress());
  +	    generateNameVirtualHost(mod_jk, vhostip);
  +	    mod_jk.println("<VirtualHost "+ vhostip + ">");
   	    mod_jk.println("    ServerName " + vhost );
   	    Enumeration aliases=context.getHostAliases();
   	    if( aliases.hasMoreElements() ) {
  @@ -426,13 +432,17 @@
   	    mod_jk.println(indent + "JkMount " +  nPath + "/* " + jkProto );
   	if( vhost != null ) {
   	    mod_jk.println("</VirtualHost>");
  +            mod_jk.println();
   	    indent="";
   	}
       }    
   
       
  -    private void generateNameVirtualHost( PrintWriter mod_jk ) {
  -	mod_jk.println("NameVirtualHost *");
  +    private void generateNameVirtualHost( PrintWriter mod_jk, String ip ) {
  +        if( !NamedVirtualHosts.containsKey(ip) ) {
  +            mod_jk.println("NameVirtualHost " + ip + "");
  +            NamedVirtualHosts.put(ip,ip);
  +        }
       }
       
       // -------------------- Apache serves static mode --------------------
  @@ -454,7 +464,10 @@
   		       " ####################" );
           mod_jk.println();
   	if( vhost != null ) {
  -	    mod_jk.println("<VirtualHost *>");
  +            String vhostip = getVirtualHostAddress(vhost,
  +                                            context.getHostAddress());
  +	    generateNameVirtualHost(mod_jk, vhostip);
  +	    mod_jk.println("<VirtualHost " + vhostip + ">");
   	    mod_jk.println("    ServerName " + vhost );
   	    Enumeration aliases=context.getHostAliases();
   	    if( aliases.hasMoreElements() ) {
  @@ -614,4 +627,15 @@
   	}
           return docBase;
       }
  +
  +    private String getVirtualHostAddress(String vhost, String vhostip) {
  +        if( vhostip == null ) {
  +            if ( vhost != null && vhost.length() > 0 && Character.isDigit(vhost.charAt(0))
)
  +                vhostip=vhost;
  +            else
  +                vhostip="*";
  +        }
  +        return vhostip;
  +    }
  +
   }
  
  
  

Mime
View raw message