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 import java.util.Vector;
36 
37 // jmx imports
38 //
39 import javax.management.MBeanServer;
40 import javax.management.ObjectName;
41 import com.sun.jmx.snmp.SnmpCounter;
42 import com.sun.jmx.snmp.SnmpCounter64;
43 import com.sun.jmx.snmp.SnmpGauge;
44 import com.sun.jmx.snmp.SnmpInt;
45 import com.sun.jmx.snmp.SnmpUnsignedInt;
46 import com.sun.jmx.snmp.SnmpIpAddress;
47 import com.sun.jmx.snmp.SnmpTimeticks;
48 import com.sun.jmx.snmp.SnmpOpaque;
49 import com.sun.jmx.snmp.SnmpString;
50 import com.sun.jmx.snmp.SnmpStringFixed;
51 import com.sun.jmx.snmp.SnmpOid;
52 import com.sun.jmx.snmp.SnmpNull;
53 import com.sun.jmx.snmp.SnmpValue;
54 import com.sun.jmx.snmp.SnmpVarBind;
55 import com.sun.jmx.snmp.SnmpStatusException;
56 
57 // jdmk imports
58 //
59 import com.sun.jmx.snmp.agent.SnmpIndex;
60 import com.sun.jmx.snmp.agent.SnmpMib;
61 import com.sun.jmx.snmp.agent.SnmpMibTable;
62 import com.sun.jmx.snmp.agent.SnmpMibSubRequest;
63 import com.sun.jmx.snmp.agent.SnmpStandardObjectServer;
64 
65 /**
66  * The class is used for implementing the "JvmThreadInstanceTable" group.
67  * The group is defined with the following oid: 1.3.6.1.4.1.42.2.145.3.163.1.1.3.10.
68  */
69 public class JvmThreadInstanceTableMeta extends SnmpMibTable implements Serializable {
70 
71     static final long serialVersionUID = 2519514732589115954L;
72     /**
73      * Constructor for the table. Initialize metadata for "JvmThreadInstanceTableMeta".
74      * The reference on the MBean server is updated so the entries created through an SNMP SET will be AUTOMATICALLY REGISTERED in Java DMK.
75      */
JvmThreadInstanceTableMeta(SnmpMib myMib, SnmpStandardObjectServer objserv)76     public JvmThreadInstanceTableMeta(SnmpMib myMib, SnmpStandardObjectServer objserv) {
77         super(myMib);
78         objectserver = objserv;
79     }
80 
81 
82     /**
83      * Factory method for "JvmThreadInstanceEntry" entry metadata class.
84      *
85      * You can redefine this method if you need to replace the default
86      * generated metadata class with your own customized class.
87      *
88      * @param snmpEntryName Name of the SNMP Entry object (conceptual row) ("JvmThreadInstanceEntry")
89      * @param tableName Name of the table in which the entries are registered ("JvmThreadInstanceTable")
90      * @param mib The SnmpMib object in which this table is registered
91      * @param server MBeanServer for this table entries (may be null)
92      *
93      * @return An instance of the metadata class generated for the
94      *         "JvmThreadInstanceEntry" conceptual row (JvmThreadInstanceEntryMeta)
95      *
96      **/
createJvmThreadInstanceEntryMetaNode(String snmpEntryName, String tableName, SnmpMib mib, MBeanServer server)97     protected JvmThreadInstanceEntryMeta createJvmThreadInstanceEntryMetaNode(String snmpEntryName, String tableName, SnmpMib mib, MBeanServer server)  {
98         return new JvmThreadInstanceEntryMeta(mib, objectserver);
99     }
100 
101 
102     // ------------------------------------------------------------
103     //
104     // Implements the "createNewEntry" method defined in "SnmpMibTable".
105     // See the "SnmpMibTable" Javadoc API for more details.
106     //
107     // ------------------------------------------------------------
108 
createNewEntry(SnmpMibSubRequest req, SnmpOid rowOid, int depth)109     public void createNewEntry(SnmpMibSubRequest req, SnmpOid rowOid, int depth)
110         throws SnmpStatusException {
111         if (factory != null)
112             factory.createNewEntry(req, rowOid, depth, this);
113         else
114             throw new SnmpStatusException(
115                 SnmpStatusException.snmpRspNoAccess);
116     }
117 
118 
119 
120     // ------------------------------------------------------------
121     //
122     // Implements the "isRegistrationRequired" method defined in "SnmpMibTable".
123     // See the "SnmpMibTable" Javadoc API for more details.
124     //
125     // ------------------------------------------------------------
126 
isRegistrationRequired()127     public boolean isRegistrationRequired()  {
128         return false;
129     }
130 
131 
132 
registerEntryNode(SnmpMib mib, MBeanServer server)133     public void registerEntryNode(SnmpMib mib, MBeanServer server)  {
134         node = createJvmThreadInstanceEntryMetaNode("JvmThreadInstanceEntry", "JvmThreadInstanceTable", mib, server);
135     }
136 
137 
138     // ------------------------------------------------------------
139     //
140     // Implements the "addEntry" method defined in "SnmpMibTable".
141     // See the "SnmpMibTable" Javadoc API for more details.
142     //
143     // ------------------------------------------------------------
144 
addEntry(SnmpOid rowOid, ObjectName objname, Object entry)145     public synchronized void addEntry(SnmpOid rowOid, ObjectName objname,
146                  Object entry)
147         throws SnmpStatusException {
148         if (! (entry instanceof JvmThreadInstanceEntryMBean) )
149             throw new ClassCastException("Entries for Table \"" +
150                            "JvmThreadInstanceTable" + "\" must implement the \"" +
151                            "JvmThreadInstanceEntryMBean" + "\" interface.");
152         super.addEntry(rowOid, objname, entry);
153     }
154 
155 
156     // ------------------------------------------------------------
157     //
158     // Implements the "get" method defined in "SnmpMibTable".
159     // See the "SnmpMibTable" Javadoc API for more details.
160     //
161     // ------------------------------------------------------------
162 
get(SnmpMibSubRequest req, SnmpOid rowOid, int depth)163     public void get(SnmpMibSubRequest req, SnmpOid rowOid, int depth)
164         throws SnmpStatusException {
165         JvmThreadInstanceEntryMBean entry = (JvmThreadInstanceEntryMBean) getEntry(rowOid);
166         synchronized (this) {
167             node.setInstance(entry);
168             node.get(req,depth);
169         }
170     }
171 
172     // ------------------------------------------------------------
173     //
174     // Implements the "set" method defined in "SnmpMibTable".
175     // See the "SnmpMibTable" Javadoc API for more details.
176     //
177     // ------------------------------------------------------------
178 
set(SnmpMibSubRequest req, SnmpOid rowOid, int depth)179     public void set(SnmpMibSubRequest req, SnmpOid rowOid, int depth)
180         throws SnmpStatusException {
181         if (req.getSize() == 0) return;
182 
183         JvmThreadInstanceEntryMBean entry = (JvmThreadInstanceEntryMBean) getEntry(rowOid);
184         synchronized (this) {
185             node.setInstance(entry);
186             node.set(req,depth);
187         }
188     }
189 
190     // ------------------------------------------------------------
191     //
192     // Implements the "check" method defined in "SnmpMibTable".
193     // See the "SnmpMibTable" Javadoc API for more details.
194     //
195     // ------------------------------------------------------------
196 
check(SnmpMibSubRequest req, SnmpOid rowOid, int depth)197     public void check(SnmpMibSubRequest req, SnmpOid rowOid, int depth)
198         throws SnmpStatusException {
199         if (req.getSize() == 0) return;
200 
201         JvmThreadInstanceEntryMBean entry = (JvmThreadInstanceEntryMBean) getEntry(rowOid);
202         synchronized (this) {
203             node.setInstance(entry);
204             node.check(req,depth);
205         }
206     }
207 
208     /**
209      * check that the given "var" identifies a columnar object.
210      */
validateVarEntryId( SnmpOid rowOid, long var, Object data )211     public void validateVarEntryId( SnmpOid rowOid, long var, Object data )
212         throws SnmpStatusException {
213         node.validateVarId(var, data);
214     }
215 
216     /**
217      * Returns true if "var" identifies a readable scalar object.
218      */
isReadableEntryId( SnmpOid rowOid, long var, Object data )219     public boolean isReadableEntryId( SnmpOid rowOid, long var, Object data )
220         throws SnmpStatusException {
221         return node.isReadable(var);
222     }
223 
224     /**
225      * Returns the arc of the next columnar object following "var".
226      */
getNextVarEntryId( SnmpOid rowOid, long var, Object data )227     public long getNextVarEntryId( SnmpOid rowOid, long var, Object data )
228         throws SnmpStatusException {
229         long nextvar = node.getNextVarId(var, data);
230         while (!isReadableEntryId(rowOid, nextvar, data))
231             nextvar = node.getNextVarId(nextvar, data);
232         return nextvar;
233     }
234 
235     // ------------------------------------------------------------
236     //
237     // Implements the "skipEntryVariable" method defined in "SnmpMibTable".
238     // See the "SnmpMibTable" Javadoc API for more details.
239     //
240     // ------------------------------------------------------------
241 
skipEntryVariable( SnmpOid rowOid, long var, Object data, int pduVersion)242     public boolean skipEntryVariable( SnmpOid rowOid, long var, Object data, int pduVersion) {
243         try {
244             JvmThreadInstanceEntryMBean entry = (JvmThreadInstanceEntryMBean) getEntry(rowOid);
245             synchronized (this) {
246                 node.setInstance(entry);
247                 return node.skipVariable(var, data, pduVersion);
248             }
249         } catch (SnmpStatusException x) {
250             return false;
251         }
252     }
253 
254 
255     /**
256      * Reference to the entry metadata.
257      */
258     private JvmThreadInstanceEntryMeta node;
259 
260     /**
261      * Reference to the object server.
262      */
263     protected SnmpStandardObjectServer objectserver;
264 
265 }
266