01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17:
18: package org.apache.harmony.lang.management;
19:
20: import java.lang.management.OperatingSystemMXBean;
21:
22: /**
23: * Runtime type for {@link java.lang.management.OperatingSystemMXBean}.
24: *
25: * @since 1.5
26: */
27: public final class OperatingSystemMXBeanImpl extends DynamicMXBeanImpl
28: implements OperatingSystemMXBean {
29:
30: private static OperatingSystemMXBeanImpl instance = new OperatingSystemMXBeanImpl();
31:
32: /**
33: * Constructor intentionally private to prevent instantiation by others.
34: * Sets the metadata for this bean.
35: */
36: private OperatingSystemMXBeanImpl() {
37: setMBeanInfo(ManagementUtils
38: .getMBeanInfo(java.lang.management.OperatingSystemMXBean.class
39: .getName()));
40: }
41:
42: /**
43: * Singleton accessor method.
44: *
45: * @return the <code>OperatingSystemMXBeanImpl</code> singleton.
46: */
47: static OperatingSystemMXBeanImpl getInstance() {
48: return instance;
49: }
50:
51: /*
52: * (non-Javadoc)
53: *
54: * @see java.lang.management.OperatingSystemMXBean#getArch()
55: */
56: public String getArch() {
57: return System.getProperty("os.arch");
58: }
59:
60: /*
61: * (non-Javadoc)
62: *
63: * @see java.lang.management.OperatingSystemMXBean#getAvailableProcessors()
64: */
65: public int getAvailableProcessors() {
66: return Runtime.getRuntime().availableProcessors();
67: }
68:
69: /*
70: * (non-Javadoc)
71: *
72: * @see java.lang.management.OperatingSystemMXBean#getName()
73: */
74: public String getName() {
75: return System.getProperty("os.name");
76: }
77:
78: /*
79: * (non-Javadoc)
80: *
81: * @see java.lang.management.OperatingSystemMXBean#getVersion()
82: */
83: public String getVersion() {
84: return System.getProperty("os.version");
85: }
86: }
|