KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > container > monitor > jvm > v15 > OperatingSystemInfoImpl


1 /***************************************************************************
2  * Copyright 2001-2003 The eXo Platform SARL All rights reserved. *
3  * Please look at license.txt in info directory for more license detail. *
4  **************************************************************************/

5 package org.exoplatform.container.monitor.jvm.v15;
6
7
8 import java.lang.management.* ;
9 import java.net.URL JavaDoc ;
10 import org.exoplatform.container.monitor.jvm.OperatingSystemInfo;
11 /**
12  * @author Tuan Nguyen (tuan08@users.sourceforge.net)
13  * @since Nov 8, 2004
14  * @version $Id$
15  */

16 public class OperatingSystemInfoImpl implements OperatingSystemInfo {
17   private OperatingSystemMXBean mxbean_ ;
18   
19   public OperatingSystemInfoImpl() {
20     mxbean_ = ManagementFactory.getOperatingSystemMXBean();
21   }
22   
23   public String JavaDoc getArch() { return mxbean_.getArch() ; }
24
25   public String JavaDoc getName() { return mxbean_.getName() ; }
26   
27   public String JavaDoc getVersion() { return mxbean_.getVersion() ;}
28   
29   public int getAvailableProcessors() { return mxbean_.getAvailableProcessors() ; }
30   
31   public URL JavaDoc createURL(String JavaDoc file) throws Exception JavaDoc {
32     return new URL JavaDoc("file:" + file) ;
33   }
34   
35   public String JavaDoc toString() {
36     StringBuilder JavaDoc b = new StringBuilder JavaDoc() ;
37     b.append("Operating System: ").append(getName()).append("\n") ;
38     b.append("Operating System Version : ").append(getVersion()).append("\n") ;
39     b.append("CPU Achitechure : ").append(getArch()).append("\n") ;
40     b.append("Number of Processors : ").append(getAvailableProcessors()).append("\n") ;
41     return b.toString() ;
42   }
43 }
Popular Tags