KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > diagnostics > collect > SystemInfoCollector


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23 package com.sun.enterprise.diagnostics.collect;
24
25 import com.sun.enterprise.diagnostics.Data;
26 import com.sun.enterprise.diagnostics.DiagnosticException;
27 /**
28  * Generic class to collect System Information.
29  * @author Manisha Umbarje
30  */

31 public class SystemInfoCollector implements Collector {
32
33     private String JavaDoc destFolder = null;
34     /** Creates a new instance of SystemInfoCollector */
35     public SystemInfoCollector(String JavaDoc destFolder) {
36         this.destFolder = destFolder;
37     }
38     
39     /**
40      * Capture information
41      * @ throw DiagnosticException
42      */

43     public Data capture() throws DiagnosticException {
44         Data systemInfo = null;
45         Collector systemInfoCollector = null;
46             String JavaDoc osName = System.getProperty("os.name");
47             osName = osName.toUpperCase();
48
49             if (osName.indexOf("WIN") >= 0) {
50                 systemInfoCollector = new WindowsSystemInfoCollector(destFolder);
51             }
52             else if (osName.indexOf("SUNOS") >= 0) {
53                 systemInfoCollector = new SolarisSystemInfoCollector(destFolder);
54             } else if (osName.indexOf("LINUX") >= 0) {
55                 systemInfoCollector = new LinuxSystemInfoCollector(destFolder);
56             }
57
58         if(systemInfoCollector !=null){
59             systemInfo = systemInfoCollector.capture();
60         }
61         return systemInfo;
62     }
63 }
64
Popular Tags