KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * @(#)file SnmpUserDataFactory.java
3  * @(#)author Sun Microsystems, Inc.
4  * @(#)version 1.16
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 import com.sun.jmx.snmp.SnmpPduPacket;
14 import com.sun.jmx.snmp.SnmpPdu;
15 import com.sun.jmx.snmp.SnmpStatusException;
16
17 /**
18  * This interface is provided to enable fine customization of the SNMP
19  * agent behaviour.
20  *
21  * <p>You will not need to implement this interface except if your agent
22  * needs extra customization requiring some contextual information.</p>
23  *
24  * <p>If an SnmpUserDataFactory is set on the SnmpAdaptorServer, then a new
25  * object containing user-data will be allocated through this factory
26  * for each incoming request. This object will be passed along to
27  * the SnmpMibAgent within SnmpMibRequest objects. By default, no
28  * SnmpUserDataFactory is set on the SnmpAdaptorServer, and the contextual
29  * object passed to SnmpMibAgent is null.</p>
30  *
31  * <p>You can use this feature to obtain on contextual information
32  * (such as community string etc...) or to implement a caching
33  * mechanism, or for whatever purpose might be required by your specific
34  * agent implementation.</p>
35  *
36  * <p>The sequence <code>allocateUserData() / releaseUserData()</code> can
37  * also be used to implement a caching mechanism:
38  * <ul>
39  * <li><code>allocateUserData()</code> could be used to allocate
40  * some cache space,</li>
41  * <li>and <code>releaseUserData()</code> could be used to flush it.</li>
42  * </ul></p>
43  *
44  * <p><b>This API is a Sun Microsystems internal API and is subject
45  * to change without notice.</b></p>
46  * @see com.sun.jmx.snmp.agent.SnmpMibRequest
47  * @see com.sun.jmx.snmp.agent.SnmpMibAgent
48  * @see com.sun.jmx.snmp.daemon.SnmpAdaptorServer
49  *
50  **/

51 public interface SnmpUserDataFactory {
52     /**
53      * Called by the <CODE>SnmpAdaptorServer</CODE> adaptor.
54      * Allocate a contextual object containing some user data. This method
55      * is called once for each incoming SNMP request. The scope
56      * of this object will be the whole request. Since the request can be
57      * handled in several threads, the user should make sure that this
58      * object can be accessed in a thread-safe manner. The SNMP framework
59      * will never access this object directly - it will simply pass
60      * it to the <code>SnmpMibAgent</code> within
61      * <code>SnmpMibRequest</code> objects - from where it can be retrieved
62      * through the {@link com.sun.jmx.snmp.agent.SnmpMibRequest#getUserData() getUserData()} accessor.
63      * <code>null</code> is considered to be a valid return value.
64      *
65      * This method is called just after the SnmpPduPacket has been
66      * decoded.
67      *
68      * @param requestPdu The SnmpPduPacket received from the SNMP manager.
69      * <b>This parameter is owned by the SNMP framework and must be
70      * considered as transient.</b> If you wish to keep some of its
71      * content after this method returns (by storing it in the
72      * returned object for instance) you should clone that
73      * information.
74      *
75      * @return A newly allocated user-data contextual object, or
76      * <code>null</code>
77      * @exception SnmpStatusException If an SnmpStatusException is thrown,
78      * the request will be aborted.
79      *
80      * @since 1.5
81      **/

82     public Object JavaDoc allocateUserData(SnmpPdu requestPdu)
83     throws SnmpStatusException;
84     
85     /**
86      * Called by the <CODE>SnmpAdaptorServer</CODE> adaptor.
87      * Release a previously allocated contextual object containing user-data.
88      * This method is called just before the responsePdu is sent back to the
89      * manager. It gives the user a chance to alter the responsePdu packet
90      * before it is encoded, and to free any resources that might have
91      * been allocated when creating the contextual object.
92      *
93      * @param userData The contextual object being released.
94      * @param responsePdu The SnmpPduPacket that will be sent back to the
95      * SNMP manager.
96      * <b>This parameter is owned by the SNMP framework and must be
97      * considered as transient.</b> If you wish to keep some of its
98      * content after this method returns you should clone that
99      * information.
100      *
101      * @exception SnmpStatusException If an SnmpStatusException is thrown,
102      * the responsePdu is dropped and nothing is returned to
103      * to the manager.
104      *
105      * @since 1.5
106      **/

107     public void releaseUserData(Object JavaDoc userData, SnmpPdu responsePdu)
108     throws SnmpStatusException;
109 }
110
Popular Tags