KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > jmx > snmp > agent > SnmpMibEntry


1 /*
2  * @(#)file SnmpMibEntry.java
3  * @(#)author Sun Microsystems, Inc.
4  * @(#)version 1.18
5  * @(#)date 08/02/09
6  *
7  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
8  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
9  */

10
11 package com.sun.jmx.snmp.agent;
12
13 // java imports
14
//
15
import java.io.Serializable JavaDoc;
16 import java.util.Hashtable JavaDoc;
17 import java.util.Enumeration JavaDoc;
18
19 // jmx imports
20
//
21
import com.sun.jmx.snmp.SnmpValue;
22 import com.sun.jmx.snmp.SnmpVarBind;
23 import com.sun.jmx.snmp.SnmpStatusException;
24 import com.sun.jmx.snmp.agent.SnmpMibOid;
25 import com.sun.jmx.snmp.agent.SnmpMibNode;
26
27 /**
28  * Represents a node in an SNMP MIB which corresponds to a table entry
29  * meta node.
30  * <P>
31  * This class is used by the class generated by <CODE>mibgen</CODE>.
32  * You should not need to use this class directly.
33  *
34  * <p><b>This API is a Sun Microsystems internal API and is subject
35  * to change without notice.</b></p>
36  * @version 4.3 10/29/99
37  * @author Sun Microsystems, Inc
38  */

39
40 public abstract class SnmpMibEntry extends SnmpMibNode
41     implements Serializable JavaDoc {
42
43     /**
44      * Tells whether the given arc identifies a variable (scalar object) in
45      * this entry.
46      *
47      * @param arc An OID arc.
48      *
49      * @return <CODE>true</CODE> if `arc' leads to a variable.
50      */

51     public abstract boolean isVariable(long arc);
52
53     /**
54      * Tells whether the given arc identifies a readable scalar object in
55      * this entry.
56      *
57      * @param arc An OID arc.
58      *
59      * @return <CODE>true</CODE> if `arc' leads to a readable variable.
60      */

61     public abstract boolean isReadable(long arc);
62
63     /**
64      * Get the next OID arc corresponding to a readable scalar variable.
65      *
66      */

67     public long getNextVarId(long id, Object JavaDoc userData)
68     throws SnmpStatusException {
69     long nextvar = super.getNextVarId(id,userData);
70     while (!isReadable(nextvar))
71         nextvar = super.getNextVarId(nextvar,userData);
72     return nextvar;
73     }
74
75     /**
76      * Checks whether the given OID arc identifies a variable (columnar
77      * object).
78      *
79      * @param userData A contextual object containing user-data.
80      * This object is allocated through the <code>
81      * {@link com.sun.jmx.snmp.agent.SnmpUserDataFactory}</code>
82      * for each incoming SNMP request.
83      *
84      * @exception If the given `arc' does not identify any variable in this
85      * group, throws an SnmpStatusException.
86      */

87     public void validateVarId(long arc, Object JavaDoc userData)
88     throws SnmpStatusException {
89     if (isVariable(arc) == false) throw noSuchNameException;
90     }
91
92     /**
93      * Generic handling of the <CODE>get</CODE> operation.
94      * <p>The actual implementation of this method will be generated
95      * by mibgen. Usually, this implementation only delegates the
96      * job to some other provided runtime class, which knows how to
97      * access the MBean. The current toolkit thus provides two
98      * implementations:
99      * <ul><li>The standard implementation will directly access the
100      * MBean through a java reference,</li>
101      * <li>The generic implementation will access the MBean through
102      * the MBean server.</li>
103      * </ul>
104      * <p>Both implementations rely upon specific - and distinct, set of
105      * mibgen generated methods.
106      * <p> You can override this method if you need to implement some
107      * specific policies for minimizing the accesses made to some remote
108      * underlying resources.
109      * <p>
110      *
111      * @param req The sub-request that must be handled by this node.
112      *
113      * @param depth The depth reached in the OID tree.
114      *
115      * @exception SnmpStatusException An error occurred while accessing
116      * the MIB node.
117      */

118     abstract public void get(SnmpMibSubRequest req, int depth)
119     throws SnmpStatusException;
120
121     /**
122      * Generic handling of the <CODE>set</CODE> operation.
123      * <p>The actual implementation of this method will be generated
124      * by mibgen. Usually, this implementation only delegates the
125      * job to some other provided runtime class, which knows how to
126      * access the MBean. The current toolkit thus provides two
127      * implementations:
128      * <ul><li>The standard implementation will directly access the
129      * MBean through a java reference,</li>
130      * <li>The generic implementation will access the MBean through
131      * the MBean server.</li>
132      * </ul>
133      * <p>Both implementations rely upon specific - and distinct, set of
134      * mibgen generated methods.
135      * <p> You can override this method if you need to implement some
136      * specific policies for minimizing the accesses made to some remote
137      * underlying resources.
138      * <p>
139      *
140      * @param req The sub-request that must be handled by this node.
141      *
142      * @param depth The depth reached in the OID tree.
143      *
144      * @exception SnmpStatusException An error occurred while accessing
145      * the MIB node.
146      */

147     abstract public void set(SnmpMibSubRequest req, int depth)
148     throws SnmpStatusException;
149
150     /**
151      * Generic handling of the <CODE>check</CODE> operation.
152      *
153      * <p>The actual implementation of this method will be generated
154      * by mibgen. Usually, this implementation only delegates the
155      * job to some other provided runtime class, which knows how to
156      * access the MBean. The current toolkit thus provides two
157      * implementations:
158      * <ul><li>The standard implementation will directly access the
159      * MBean through a java reference,</li>
160      * <li>The generic implementation will access the MBean through
161      * the MBean server.</li>
162      * </ul>
163      * <p>Both implementations rely upon specific - and distinct, set of
164      * mibgen generated methods.
165      * <p> You can override this method if you need to implement some
166      * specific policies for minimizing the accesses made to some remote
167      * underlying resources, or if you need to implement some consistency
168      * checks between the different values provided in the varbind list.
169      * <p>
170      *
171      * @param req The sub-request that must be handled by this node.
172      *
173      * @param depth The depth reached in the OID tree.
174      *
175      * @exception SnmpStatusException An error occurred while accessing
176      * the MIB node.
177      */

178     abstract public void check(SnmpMibSubRequest req, int depth)
179     throws SnmpStatusException;
180
181 }
182
Popular Tags