1 4 package com.tc.aspectwerkz.env; 5 6 import java.io.PrintStream ; 7 import java.lang.reflect.Method ; 8 9 public class EnvironmentDetector { 10 11 private final PrintStream m_stream; 12 13 public EnvironmentDetector(PrintStream s) { 14 m_stream = s; 15 } 16 17 public void printTomcatInfo() { 18 String info; 19 try { 20 Class serverInfo = Class.forName( 22 "org.apache.catalina.util.ServerInfo", 23 true, 24 EnvironmentDetector.class.getClassLoader() 25 ); 26 Method getServerInfo = serverInfo.getMethod("getServerInfo", new Class []{}); 27 info = (String )getServerInfo.invoke(null, new Object []{}); 28 } catch (Throwable e) { 29 return; 31 } 32 m_stream.println("Tomcat Version:\t" + info); 33 } 34 35 public void printJavaInfo() { 36 m_stream.println("JVM Vendor:\t\t" + System.getProperty("java.vendor").toUpperCase()); 37 m_stream.println("JVM Version:\t\tto" + System.getProperty("java.version").toUpperCase()); 38 } 39 40 public void printOSInfo() { 41 m_stream.println("OS Arch:\t\t" + System.getProperty("os.arch").toUpperCase()); 42 m_stream.println("OS Name:\t\t" + System.getProperty("os.name").toUpperCase()); 43 m_stream.println("OS Version:\t\t" + System.getProperty("os.version").toUpperCase()); 44 } 45 46 public void printEnv() { 47 EnvironmentDetector detector = new EnvironmentDetector(m_stream); 48 m_stream.println("----------------------------------"); 49 detector.printOSInfo(); 50 detector.printJavaInfo(); 51 detector.printTomcatInfo(); 52 } 53 54 public static void main(String [] args) { 55 new EnvironmentDetector(System.out).printEnv(); 56 } 57 } | Popular Tags |