J. Duke | 319a3b9 | 2007-12-01 00:00:00 +0000 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2003-2004 Sun Microsystems, Inc. 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. Sun designates this |
| 8 | * particular file as subject to the "Classpath" exception as provided |
| 9 | * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
| 22 | * CA 95054 USA or visit www.sun.com if you need additional information or |
| 23 | * have any 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 | /** |
| 74 | * Constructor for the metadata associated to "JvmOS". |
| 75 | */ |
| 76 | public JvmOSMeta(SnmpMib myMib, SnmpStandardObjectServer objserv) { |
| 77 | objectserver = objserv; |
| 78 | try { |
| 79 | registerObject(4); |
| 80 | registerObject(3); |
| 81 | registerObject(2); |
| 82 | registerObject(1); |
| 83 | } catch (IllegalAccessException e) { |
| 84 | throw new RuntimeException(e.getMessage()); |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | /** |
| 89 | * Get the value of a scalar variable |
| 90 | */ |
| 91 | public SnmpValue get(long var, Object data) |
| 92 | throws SnmpStatusException { |
| 93 | switch((int)var) { |
| 94 | case 4: |
| 95 | return new SnmpInt(node.getJvmOSProcessorCount()); |
| 96 | |
| 97 | case 3: |
| 98 | return new SnmpString(node.getJvmOSVersion()); |
| 99 | |
| 100 | case 2: |
| 101 | return new SnmpString(node.getJvmOSArch()); |
| 102 | |
| 103 | case 1: |
| 104 | return new SnmpString(node.getJvmOSName()); |
| 105 | |
| 106 | default: |
| 107 | break; |
| 108 | } |
| 109 | throw new SnmpStatusException(SnmpStatusException.noSuchObject); |
| 110 | } |
| 111 | |
| 112 | /** |
| 113 | * Set the value of a scalar variable |
| 114 | */ |
| 115 | public SnmpValue set(SnmpValue x, long var, Object data) |
| 116 | throws SnmpStatusException { |
| 117 | switch((int)var) { |
| 118 | case 4: |
| 119 | throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable); |
| 120 | |
| 121 | case 3: |
| 122 | throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable); |
| 123 | |
| 124 | case 2: |
| 125 | throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable); |
| 126 | |
| 127 | case 1: |
| 128 | throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable); |
| 129 | |
| 130 | default: |
| 131 | break; |
| 132 | } |
| 133 | throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable); |
| 134 | } |
| 135 | |
| 136 | /** |
| 137 | * Check the value of a scalar variable |
| 138 | */ |
| 139 | public void check(SnmpValue x, long var, Object data) |
| 140 | throws SnmpStatusException { |
| 141 | switch((int) var) { |
| 142 | case 4: |
| 143 | throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable); |
| 144 | |
| 145 | case 3: |
| 146 | throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable); |
| 147 | |
| 148 | case 2: |
| 149 | throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable); |
| 150 | |
| 151 | case 1: |
| 152 | throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable); |
| 153 | |
| 154 | default: |
| 155 | throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable); |
| 156 | } |
| 157 | } |
| 158 | |
| 159 | /** |
| 160 | * Allow to bind the metadata description to a specific object. |
| 161 | */ |
| 162 | protected void setInstance(JvmOSMBean var) { |
| 163 | node = var; |
| 164 | } |
| 165 | |
| 166 | |
| 167 | // ------------------------------------------------------------ |
| 168 | // |
| 169 | // Implements the "get" method defined in "SnmpMibGroup". |
| 170 | // See the "SnmpMibGroup" Javadoc API for more details. |
| 171 | // |
| 172 | // ------------------------------------------------------------ |
| 173 | |
| 174 | public void get(SnmpMibSubRequest req, int depth) |
| 175 | throws SnmpStatusException { |
| 176 | objectserver.get(this,req,depth); |
| 177 | } |
| 178 | |
| 179 | |
| 180 | // ------------------------------------------------------------ |
| 181 | // |
| 182 | // Implements the "set" method defined in "SnmpMibGroup". |
| 183 | // See the "SnmpMibGroup" Javadoc API for more details. |
| 184 | // |
| 185 | // ------------------------------------------------------------ |
| 186 | |
| 187 | public void set(SnmpMibSubRequest req, int depth) |
| 188 | throws SnmpStatusException { |
| 189 | objectserver.set(this,req,depth); |
| 190 | } |
| 191 | |
| 192 | |
| 193 | // ------------------------------------------------------------ |
| 194 | // |
| 195 | // Implements the "check" method defined in "SnmpMibGroup". |
| 196 | // See the "SnmpMibGroup" Javadoc API for more details. |
| 197 | // |
| 198 | // ------------------------------------------------------------ |
| 199 | |
| 200 | public void check(SnmpMibSubRequest req, int depth) |
| 201 | throws SnmpStatusException { |
| 202 | objectserver.check(this,req,depth); |
| 203 | } |
| 204 | |
| 205 | /** |
| 206 | * Returns true if "arc" identifies a scalar object. |
| 207 | */ |
| 208 | public boolean isVariable(long arc) { |
| 209 | |
| 210 | switch((int)arc) { |
| 211 | case 4: |
| 212 | case 3: |
| 213 | case 2: |
| 214 | case 1: |
| 215 | return true; |
| 216 | default: |
| 217 | break; |
| 218 | } |
| 219 | return false; |
| 220 | } |
| 221 | |
| 222 | /** |
| 223 | * Returns true if "arc" identifies a readable scalar object. |
| 224 | */ |
| 225 | public boolean isReadable(long arc) { |
| 226 | |
| 227 | switch((int)arc) { |
| 228 | case 4: |
| 229 | case 3: |
| 230 | case 2: |
| 231 | case 1: |
| 232 | return true; |
| 233 | default: |
| 234 | break; |
| 235 | } |
| 236 | return false; |
| 237 | } |
| 238 | |
| 239 | |
| 240 | // ------------------------------------------------------------ |
| 241 | // |
| 242 | // Implements the "skipVariable" method defined in "SnmpMibGroup". |
| 243 | // See the "SnmpMibGroup" Javadoc API for more details. |
| 244 | // |
| 245 | // ------------------------------------------------------------ |
| 246 | |
| 247 | public boolean skipVariable(long var, Object data, int pduVersion) { |
| 248 | return super.skipVariable(var,data,pduVersion); |
| 249 | } |
| 250 | |
| 251 | /** |
| 252 | * Return the name of the attribute corresponding to the SNMP variable identified by "id". |
| 253 | */ |
| 254 | public String getAttributeName(long id) |
| 255 | throws SnmpStatusException { |
| 256 | switch((int)id) { |
| 257 | case 4: |
| 258 | return "JvmOSProcessorCount"; |
| 259 | |
| 260 | case 3: |
| 261 | return "JvmOSVersion"; |
| 262 | |
| 263 | case 2: |
| 264 | return "JvmOSArch"; |
| 265 | |
| 266 | case 1: |
| 267 | return "JvmOSName"; |
| 268 | |
| 269 | default: |
| 270 | break; |
| 271 | } |
| 272 | throw new SnmpStatusException(SnmpStatusException.noSuchObject); |
| 273 | } |
| 274 | |
| 275 | /** |
| 276 | * Returns true if "arc" identifies a table object. |
| 277 | */ |
| 278 | public boolean isTable(long arc) { |
| 279 | |
| 280 | switch((int)arc) { |
| 281 | default: |
| 282 | break; |
| 283 | } |
| 284 | return false; |
| 285 | } |
| 286 | |
| 287 | /** |
| 288 | * Returns the table object identified by "arc". |
| 289 | */ |
| 290 | public SnmpMibTable getTable(long arc) { |
| 291 | return null; |
| 292 | } |
| 293 | |
| 294 | /** |
| 295 | * Register the group's SnmpMibTable objects with the meta-data. |
| 296 | */ |
| 297 | public void registerTableNodes(SnmpMib mib, MBeanServer server) { |
| 298 | } |
| 299 | |
| 300 | protected JvmOSMBean node; |
| 301 | protected SnmpStandardObjectServer objectserver = null; |
| 302 | } |