| 1 | /* |
| 2 | Copyright (C) 2004 MySQL AB |
| 3 | |
| 4 | This program is free software; you can redistribute it and/or modify |
| 5 | it under the terms of the GNU General Public License version 2 as |
| 6 | published by the Free Software Foundation. |
| 7 | |
| 8 | This program is distributed in the hope that it will be useful, |
| 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | GNU General Public License for more details. |
| 12 | |
| 13 | You should have received a copy of the GNU General Public License |
| 14 | along with this program; if not, write to the Free Software |
| 15 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 16 | |
| 17 | */ |
| 18 | package com.mysql.management.util; |
| 19 | |
| 20 | import java.io.PrintWriter; |
| 21 | import java.util.ArrayList; |
| 22 | import java.util.Collection; |
| 23 | import java.util.Iterator; |
| 24 | import java.util.List; |
| 25 | |
| 26 | /** |
| 27 | * @author Eric Herman <eric@mysql.com> |
| 28 | * @version $Id: Platform.java,v 1.7 2005/07/27 23:41:27 eherman Exp $ |
| 29 | */ |
| 30 | public final class Platform { |
| 31 | public static final String OS_NAME = "os.name"; |
| 32 | |
| 33 | public static final String OS_ARCH = "os.arch"; |
| 34 | |
| 35 | PrintWriter writer; |
| 36 | |
| 37 | public Platform(PrintWriter writer) { |
| 38 | this.writer = writer; |
| 39 | } |
| 40 | |
| 41 | public void report() { |
| 42 | report(platformProps()); |
| 43 | } |
| 44 | |
| 45 | void report(Collection propertyKeys) { |
| 46 | for (Iterator iter = propertyKeys.iterator(); iter.hasNext();) { |
| 47 | String property = (String) iter.next(); |
| 48 | writer.print(property); |
| 49 | writer.print('='); |
| 50 | writer.println(System.getProperty(property)); |
| 51 | writer.flush(); |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | List platformProps() { |
| 56 | List list = new ArrayList(); |
| 57 | list.add("java.vm.vendor"); |
| 58 | list.add("java.vm.version"); |
| 59 | list.add(OS_NAME); |
| 60 | list.add(OS_ARCH); |
| 61 | list.add("os.version"); |
| 62 | return list; |
| 63 | } |
| 64 | |
| 65 | public static void main(String[] args) { |
| 66 | new Platform(new PrintWriter(System.out)).report(); |
| 67 | } |
| 68 | } |