001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017:
018: package org.apache.catalina.util;
019:
020: import java.io.InputStream;
021: import java.util.Properties;
022:
023: /**
024: * Simple utility module to make it easy to plug in the server identifier
025: * when integrating Tomcat.
026: *
027: * @author Craig R. McClanahan
028: * @version $Revision: 467222 $ $Date: 2006-10-24 05:17:11 +0200 (mar., 24 oct. 2006) $
029: */
030:
031: public class ServerInfo {
032:
033: // ------------------------------------------------------- Static Variables
034:
035: /**
036: * The server information String with which we identify ourselves.
037: */
038: private static String serverInfo = null;
039:
040: /**
041: * The server built String.
042: */
043: private static String serverBuilt = null;
044:
045: /**
046: * The server's version number String.
047: */
048: private static String serverNumber = null;
049:
050: static {
051:
052: try {
053: InputStream is = ServerInfo.class
054: .getResourceAsStream("/org/apache/catalina/util/ServerInfo.properties");
055: Properties props = new Properties();
056: props.load(is);
057: is.close();
058: serverInfo = props.getProperty("server.info");
059: serverBuilt = props.getProperty("server.built");
060: serverNumber = props.getProperty("server.number");
061: } catch (Throwable t) {
062: ;
063: }
064: if (serverInfo == null)
065: serverInfo = "Apache Tomcat";
066: if (serverBuilt == null)
067: serverBuilt = "unknown";
068: if (serverNumber == null)
069: serverNumber = "5.5.0.0";
070:
071: }
072:
073: // --------------------------------------------------------- Public Methods
074:
075: /**
076: * Return the server identification for this version of Tomcat.
077: */
078: public static String getServerInfo() {
079:
080: return (serverInfo);
081:
082: }
083:
084: /**
085: * Return the server built time for this version of Tomcat.
086: */
087: public static String getServerBuilt() {
088:
089: return (serverBuilt);
090:
091: }
092:
093: /**
094: * Return the server's version number.
095: */
096: public static String getServerNumber() {
097:
098: return (serverNumber);
099:
100: }
101:
102: public static void main(String args[]) {
103: System.out.println("Server version: " + getServerInfo());
104: System.out.println("Server built: " + getServerBuilt());
105: System.out.println("Server number: " + getServerNumber());
106: System.out.println("OS Name: "
107: + System.getProperty("os.name"));
108: System.out.println("OS Version: "
109: + System.getProperty("os.version"));
110: System.out.println("Architecture: "
111: + System.getProperty("os.arch"));
112: System.out.println("JVM Version: "
113: + System.getProperty("java.runtime.version"));
114: System.out.println("JVM Vendor: "
115: + System.getProperty("java.vm.vendor"));
116: }
117:
118: }
|