1 /* |
|
2 * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. |
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
4 * |
|
5 * This code is free software; you can redistribute it and/or modify it |
|
6 * under the terms of the GNU General Public License version 2 only, as |
|
7 * published by the Free Software Foundation. Oracle designates this |
|
8 * particular file as subject to the "Classpath" exception as provided |
|
9 * by Oracle in the LICENSE file that accompanied this code. |
|
10 * |
|
11 * This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 * version 2 for more details (a copy is included in the LICENSE file that |
|
15 * accompanied this code). |
|
16 * |
|
17 * You should have received a copy of the GNU General Public License version |
|
18 * 2 along with this work; if not, write to the Free Software Foundation, |
|
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 * |
|
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
22 * or visit www.oracle.com if you need additional information or have any |
|
23 * questions. |
|
24 */ |
|
25 |
|
26 package sun.management.snmp.jvmmib; |
|
27 |
|
28 // |
|
29 // Generated by mibgen version 5.0 (06/02/03) when compiling JVM-MANAGEMENT-MIB in standard metadata mode. |
|
30 // |
|
31 |
|
32 // java imports |
|
33 // |
|
34 import java.io.Serializable; |
|
35 |
|
36 // jmx imports |
|
37 // |
|
38 import javax.management.MBeanServer; |
|
39 import com.sun.jmx.snmp.SnmpCounter; |
|
40 import com.sun.jmx.snmp.SnmpCounter64; |
|
41 import com.sun.jmx.snmp.SnmpGauge; |
|
42 import com.sun.jmx.snmp.SnmpInt; |
|
43 import com.sun.jmx.snmp.SnmpUnsignedInt; |
|
44 import com.sun.jmx.snmp.SnmpIpAddress; |
|
45 import com.sun.jmx.snmp.SnmpTimeticks; |
|
46 import com.sun.jmx.snmp.SnmpOpaque; |
|
47 import com.sun.jmx.snmp.SnmpString; |
|
48 import com.sun.jmx.snmp.SnmpStringFixed; |
|
49 import com.sun.jmx.snmp.SnmpOid; |
|
50 import com.sun.jmx.snmp.SnmpNull; |
|
51 import com.sun.jmx.snmp.SnmpValue; |
|
52 import com.sun.jmx.snmp.SnmpVarBind; |
|
53 import com.sun.jmx.snmp.SnmpStatusException; |
|
54 |
|
55 // jdmk imports |
|
56 // |
|
57 import com.sun.jmx.snmp.agent.SnmpMib; |
|
58 import com.sun.jmx.snmp.agent.SnmpMibGroup; |
|
59 import com.sun.jmx.snmp.agent.SnmpStandardObjectServer; |
|
60 import com.sun.jmx.snmp.agent.SnmpStandardMetaServer; |
|
61 import com.sun.jmx.snmp.agent.SnmpMibSubRequest; |
|
62 import com.sun.jmx.snmp.agent.SnmpMibTable; |
|
63 import com.sun.jmx.snmp.EnumRowStatus; |
|
64 import com.sun.jmx.snmp.SnmpDefinitions; |
|
65 |
|
66 /** |
|
67 * The class is used for representing SNMP metadata for the "JvmOS" group. |
|
68 * The group is defined with the following oid: 1.3.6.1.4.1.42.2.145.3.163.1.1.6. |
|
69 */ |
|
70 public class JvmOSMeta extends SnmpMibGroup |
|
71 implements Serializable, SnmpStandardMetaServer { |
|
72 |
|
73 static final long serialVersionUID = -2024138733580127133L; |
|
74 |
|
75 /** |
|
76 * Constructor for the metadata associated to "JvmOS". |
|
77 */ |
|
78 public JvmOSMeta(SnmpMib myMib, SnmpStandardObjectServer objserv) { |
|
79 objectserver = objserv; |
|
80 try { |
|
81 registerObject(4); |
|
82 registerObject(3); |
|
83 registerObject(2); |
|
84 registerObject(1); |
|
85 } catch (IllegalAccessException e) { |
|
86 throw new RuntimeException(e.getMessage()); |
|
87 } |
|
88 } |
|
89 |
|
90 /** |
|
91 * Get the value of a scalar variable |
|
92 */ |
|
93 public SnmpValue get(long var, Object data) |
|
94 throws SnmpStatusException { |
|
95 switch((int)var) { |
|
96 case 4: |
|
97 return new SnmpInt(node.getJvmOSProcessorCount()); |
|
98 |
|
99 case 3: |
|
100 return new SnmpString(node.getJvmOSVersion()); |
|
101 |
|
102 case 2: |
|
103 return new SnmpString(node.getJvmOSArch()); |
|
104 |
|
105 case 1: |
|
106 return new SnmpString(node.getJvmOSName()); |
|
107 |
|
108 default: |
|
109 break; |
|
110 } |
|
111 throw new SnmpStatusException(SnmpStatusException.noSuchObject); |
|
112 } |
|
113 |
|
114 /** |
|
115 * Set the value of a scalar variable |
|
116 */ |
|
117 public SnmpValue set(SnmpValue x, long var, Object data) |
|
118 throws SnmpStatusException { |
|
119 switch((int)var) { |
|
120 case 4: |
|
121 throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable); |
|
122 |
|
123 case 3: |
|
124 throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable); |
|
125 |
|
126 case 2: |
|
127 throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable); |
|
128 |
|
129 case 1: |
|
130 throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable); |
|
131 |
|
132 default: |
|
133 break; |
|
134 } |
|
135 throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable); |
|
136 } |
|
137 |
|
138 /** |
|
139 * Check the value of a scalar variable |
|
140 */ |
|
141 public void check(SnmpValue x, long var, Object data) |
|
142 throws SnmpStatusException { |
|
143 switch((int) var) { |
|
144 case 4: |
|
145 throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable); |
|
146 |
|
147 case 3: |
|
148 throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable); |
|
149 |
|
150 case 2: |
|
151 throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable); |
|
152 |
|
153 case 1: |
|
154 throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable); |
|
155 |
|
156 default: |
|
157 throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable); |
|
158 } |
|
159 } |
|
160 |
|
161 /** |
|
162 * Allow to bind the metadata description to a specific object. |
|
163 */ |
|
164 protected void setInstance(JvmOSMBean var) { |
|
165 node = var; |
|
166 } |
|
167 |
|
168 |
|
169 // ------------------------------------------------------------ |
|
170 // |
|
171 // Implements the "get" method defined in "SnmpMibGroup". |
|
172 // See the "SnmpMibGroup" Javadoc API for more details. |
|
173 // |
|
174 // ------------------------------------------------------------ |
|
175 |
|
176 public void get(SnmpMibSubRequest req, int depth) |
|
177 throws SnmpStatusException { |
|
178 objectserver.get(this,req,depth); |
|
179 } |
|
180 |
|
181 |
|
182 // ------------------------------------------------------------ |
|
183 // |
|
184 // Implements the "set" method defined in "SnmpMibGroup". |
|
185 // See the "SnmpMibGroup" Javadoc API for more details. |
|
186 // |
|
187 // ------------------------------------------------------------ |
|
188 |
|
189 public void set(SnmpMibSubRequest req, int depth) |
|
190 throws SnmpStatusException { |
|
191 objectserver.set(this,req,depth); |
|
192 } |
|
193 |
|
194 |
|
195 // ------------------------------------------------------------ |
|
196 // |
|
197 // Implements the "check" method defined in "SnmpMibGroup". |
|
198 // See the "SnmpMibGroup" Javadoc API for more details. |
|
199 // |
|
200 // ------------------------------------------------------------ |
|
201 |
|
202 public void check(SnmpMibSubRequest req, int depth) |
|
203 throws SnmpStatusException { |
|
204 objectserver.check(this,req,depth); |
|
205 } |
|
206 |
|
207 /** |
|
208 * Returns true if "arc" identifies a scalar object. |
|
209 */ |
|
210 public boolean isVariable(long arc) { |
|
211 |
|
212 switch((int)arc) { |
|
213 case 4: |
|
214 case 3: |
|
215 case 2: |
|
216 case 1: |
|
217 return true; |
|
218 default: |
|
219 break; |
|
220 } |
|
221 return false; |
|
222 } |
|
223 |
|
224 /** |
|
225 * Returns true if "arc" identifies a readable scalar object. |
|
226 */ |
|
227 public boolean isReadable(long arc) { |
|
228 |
|
229 switch((int)arc) { |
|
230 case 4: |
|
231 case 3: |
|
232 case 2: |
|
233 case 1: |
|
234 return true; |
|
235 default: |
|
236 break; |
|
237 } |
|
238 return false; |
|
239 } |
|
240 |
|
241 |
|
242 // ------------------------------------------------------------ |
|
243 // |
|
244 // Implements the "skipVariable" method defined in "SnmpMibGroup". |
|
245 // See the "SnmpMibGroup" Javadoc API for more details. |
|
246 // |
|
247 // ------------------------------------------------------------ |
|
248 |
|
249 public boolean skipVariable(long var, Object data, int pduVersion) { |
|
250 return super.skipVariable(var,data,pduVersion); |
|
251 } |
|
252 |
|
253 /** |
|
254 * Return the name of the attribute corresponding to the SNMP variable identified by "id". |
|
255 */ |
|
256 public String getAttributeName(long id) |
|
257 throws SnmpStatusException { |
|
258 switch((int)id) { |
|
259 case 4: |
|
260 return "JvmOSProcessorCount"; |
|
261 |
|
262 case 3: |
|
263 return "JvmOSVersion"; |
|
264 |
|
265 case 2: |
|
266 return "JvmOSArch"; |
|
267 |
|
268 case 1: |
|
269 return "JvmOSName"; |
|
270 |
|
271 default: |
|
272 break; |
|
273 } |
|
274 throw new SnmpStatusException(SnmpStatusException.noSuchObject); |
|
275 } |
|
276 |
|
277 /** |
|
278 * Returns true if "arc" identifies a table object. |
|
279 */ |
|
280 public boolean isTable(long arc) { |
|
281 |
|
282 switch((int)arc) { |
|
283 default: |
|
284 break; |
|
285 } |
|
286 return false; |
|
287 } |
|
288 |
|
289 /** |
|
290 * Returns the table object identified by "arc". |
|
291 */ |
|
292 public SnmpMibTable getTable(long arc) { |
|
293 return null; |
|
294 } |
|
295 |
|
296 /** |
|
297 * Register the group's SnmpMibTable objects with the meta-data. |
|
298 */ |
|
299 public void registerTableNodes(SnmpMib mib, MBeanServer server) { |
|
300 } |
|
301 |
|
302 protected JvmOSMBean node; |
|
303 protected SnmpStandardObjectServer objectserver = null; |
|
304 } |
|