tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From billbar...@apache.org
Subject cvs commit: jakarta-tomcat-connectors/jk/java/org/apache/jk/server JkMain.java
Date Sun, 10 Oct 2004 23:43:21 GMT
billbarker    2004/10/10 16:43:20

  Modified:    jk/java/org/apache/jk/server JkMain.java
  Log:
  Make the 'jk2.properties' file entirely optional.
  
  By default, no properties file is read.  Configuration should be done on the Connector element.
 To get the previous behavior, you need to have:
    <Connector protocol="AJP/1.3" propertiesFile="conf/jk2.properties" />
  
  Revision  Changes    Path
  1.47      +44 -24    jakarta-tomcat-connectors/jk/java/org/apache/jk/server/JkMain.java
  
  Index: JkMain.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/java/org/apache/jk/server/JkMain.java,v
  retrieving revision 1.46
  retrieving revision 1.47
  diff -u -r1.46 -r1.47
  --- JkMain.java	24 Feb 2004 08:48:41 -0000	1.46
  +++ JkMain.java	10 Oct 2004 23:43:20 -0000	1.47
  @@ -115,7 +115,7 @@
               }
               System.setProperty("java.protocol.handler.pkgs", value);
           } catch(Exception ex ) {
  -            ex.printStackTrace();
  +            log.info("Error adding SSL Protocol Handler",ex);
           }
       }
   
  @@ -126,10 +126,8 @@
        */
       public void setPropertiesFile( String p  ) {
           propFile=p;
  -        try {
  -            props.load( new FileInputStream(propFile) );
  -        } catch(IOException ex ){
  -            ex.printStackTrace();
  +        if( started ) {
  +            loadPropertiesFile();
           }
       }
   
  @@ -147,6 +145,9 @@
           if( "jkHome".equals( n ) ) {
               setJkHome( v );
           } 
  +        if( "propertiesFile".equals( n ) ) {
  +            setPropertiesFile( v );
  +        }
           props.put( n, v );
           if( started ) {
               processProperty( n, v );
  @@ -248,23 +249,10 @@
           if( home==null ) {
               log.info( "Can't find home, jk2.properties not loaded");
           }
  -        if( home != null ) {
  -            File hF=new File(home);
  -            File conf=new File( home, "conf" );
  -            if( ! conf.exists() )
  -                conf=new File( home, "etc" );
  +        if(log.isDebugEnabled())
  +            log.debug("Starting Jk2, base dir= " + home  );
  +        loadPropertiesFile();
   
  -            propsF=new File( conf, "jk2.properties" );
  -            
  -            if( propsF.exists() ) {
  -                log.debug("Starting Jk2, base dir= " + home + " conf=" + propsF );
  -                setPropertiesFile( propsF.getAbsolutePath());
  -            } else {
  -                log.debug("Starting Jk2, base dir= " + home );
  -                if( log.isDebugEnabled() )
  -                    log.debug( "No properties file found " + propsF );
  -            }
  -        }
           String initHTTPS = (String)props.get("class.initHTTPS");
           if("true".equalsIgnoreCase(initHTTPS)) {
               initHTTPSUrls();
  @@ -435,22 +423,54 @@
               jkMain.init();
               jkMain.start();
           } catch( Exception ex ) {
  -            ex.printStackTrace();
  +            log.warn("Error running",ex);
           }
       }
   
       // -------------------- Private methods --------------------
   
  +
  +    private boolean checkPropertiesFile() {
  +        if(propFile == null) {
  +            return false;
  +        }
  +        propsF = new File(propFile);
  +        if(!propsF.isAbsolute()) {
  +            String home = getWorkerEnv().getJkHome();
  +            if( home == null ) {
  +                return false;
  +            }
  +            propsF = new File(home, propFile);
  +        }
  +        return propsF.exists();
  +    }
  +            
  +    private void loadPropertiesFile() {
  +        if(!checkPropertiesFile()) {
  +            return;
  +        }
  +
  +        try {
  +            props.load( new FileInputStream(propsF) );
  +        } catch(IOException ex ){
  +            log.warn("Unable to load properties from "+propsF,ex);
  +        }
  +    }
  +
       public  void saveProperties() {
           if( !saveProperties) return;
           
  +        if(propsF == null) {
  +            log.warn("No properties file specified. Unable to save");
  +            return;
  +        }
           // Temp - to check if it works
  -        String outFile=propFile + ".save";
  +        File outFile= new File(propsF.getParentFile(), propsF.getName()+".save");
           log.debug("Saving properties " + outFile );
           try {
               props.save( new FileOutputStream(outFile), "AUTOMATICALLY GENERATED" );
           } catch(IOException ex ){
  -            ex.printStackTrace();
  +            log.warn("Unable to save to "+outFile,ex);
           }
       }
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Mime
View raw message