Save This Page
Home » apache-tomcat-6.0.16-src » org.apache » catalina » util » [javadoc | source]
    1   /*
    2    * Licensed to the Apache Software Foundation (ASF) under one or more
    3    * contributor license agreements.  See the NOTICE file distributed with
    4    * this work for additional information regarding copyright ownership.
    5    * The ASF licenses this file to You under the Apache License, Version 2.0
    6    * (the "License"); you may not use this file except in compliance with
    7    * the License.  You may obtain a copy of the License at
    8    *
    9    *      http://www.apache.org/licenses/LICENSE-2.0
   10    *
   11    * Unless required by applicable law or agreed to in writing, software
   12    * distributed under the License is distributed on an "AS IS" BASIS,
   13    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   14    * See the License for the specific language governing permissions and
   15    * limitations under the License.
   16    */
   17   
   18   
   19   package org.apache.catalina.util;
   20   
   21   
   22   import java.io.InputStream;
   23   import java.util.Properties;
   24   
   25   
   26   /**
   27    * Simple utility module to make it easy to plug in the server identifier
   28    * when integrating Tomcat.
   29    *
   30    * @author Craig R. McClanahan
   31    * @version $Revision: 467222 $ $Date: 2006-10-24 05:17:11 +0200 (mar., 24 oct. 2006) $
   32    */
   33   
   34   public class ServerInfo {
   35   
   36   
   37       // ------------------------------------------------------- Static Variables
   38   
   39   
   40       /**
   41        * The server information String with which we identify ourselves.
   42        */
   43       private static String serverInfo = null;
   44   
   45       /**
   46        * The server built String.
   47        */
   48       private static String serverBuilt = null;
   49   
   50       /**
   51        * The server's version number String.
   52        */
   53       private static String serverNumber = null;
   54   
   55       static {
   56   
   57           try {
   58               InputStream is = ServerInfo.class.getResourceAsStream
   59                   ("/org/apache/catalina/util/ServerInfo.properties");
   60               Properties props = new Properties();
   61               props.load(is);
   62               is.close();
   63               serverInfo = props.getProperty("server.info");
   64               serverBuilt = props.getProperty("server.built");
   65               serverNumber = props.getProperty("server.number");
   66           } catch (Throwable t) {
   67               ;
   68           }
   69           if (serverInfo == null)
   70               serverInfo = "Apache Tomcat";
   71           if (serverBuilt == null)
   72               serverBuilt = "unknown";
   73           if (serverNumber == null)
   74               serverNumber = "5.5.0.0";
   75           
   76       }
   77   
   78   
   79       // --------------------------------------------------------- Public Methods
   80   
   81   
   82       /**
   83        * Return the server identification for this version of Tomcat.
   84        */
   85       public static String getServerInfo() {
   86   
   87           return (serverInfo);
   88   
   89       }
   90   
   91       /**
   92        * Return the server built time for this version of Tomcat.
   93        */
   94       public static String getServerBuilt() {
   95   
   96           return (serverBuilt);
   97   
   98       }
   99   
  100       /**
  101        * Return the server's version number.
  102        */
  103       public static String getServerNumber() {
  104   
  105           return (serverNumber);
  106   
  107       }
  108   
  109       public static void main(String args[]) {
  110           System.out.println("Server version: " + getServerInfo());
  111           System.out.println("Server built:   " + getServerBuilt());
  112           System.out.println("Server number:  " + getServerNumber());
  113           System.out.println("OS Name:        " +
  114                              System.getProperty("os.name"));
  115           System.out.println("OS Version:     " +
  116                              System.getProperty("os.version"));
  117           System.out.println("Architecture:   " +
  118                              System.getProperty("os.arch"));
  119           System.out.println("JVM Version:    " +
  120                              System.getProperty("java.runtime.version"));
  121           System.out.println("JVM Vendor:     " +
  122                              System.getProperty("java.vm.vendor"));                        
  123       }
  124   
  125   }

Save This Page
Home » apache-tomcat-6.0.16-src » org.apache » catalina » util » [javadoc | source]