KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > snmp4j > agent > mo > jmx > JMXAttributeNotificationIndexSupport


1 /*_############################################################################
2   _##
3   _## SNMP4J-AgentJMX - JMXAttributeNotificationIndexSupport.java
4   _##
5   _## Copyright (C) 2006-2007 Frank Fock (SNMP4J.org)
6   _##
7   _## This program is free software; you can redistribute it and/or modify
8   _## it under the terms of the GNU General Public License version 2 as
9   _## published by the Free Software Foundation.
10   _##
11   _## This program is distributed in the hope that it will be useful,
12   _## but WITHOUT ANY WARRANTY; without even the implied warranty of
13   _## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14   _## GNU General Public License for more details.
15   _##
16   _## You should have received a copy of the GNU General Public License
17   _## along with this program; if not, write to the Free Software
18   _## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19   _## MA 02110-1301 USA
20   _##
21   _##########################################################################*/

22
23 package org.snmp4j.agent.mo.jmx;
24
25 import org.snmp4j.smi.OID;
26 import org.snmp4j.agent.mo.jmx.types.TypedAttribute;
27 import javax.management.openmbean.CompositeDataSupport JavaDoc;
28
29 /**
30  * Notification objects can refer to scalar and tabular data. Whereas for scalar
31  * data the OID of the instance is constant, the index portion of the instance
32  * identifier of tabular data may vary from notification to notification.
33  * <p>
34  * The <code>JMXAttributeNotificationIndexSupport</code> provides the index
35  * portion for a notification object by using a <code>JMXIndexSupport</code>
36  * instance. That instance can be shared with the table holding the target
37  * object.
38  *
39  * @author Frank Fock
40  * @version 1.0
41  */

42 public class JMXAttributeNotificationIndexSupport
43     implements JMXNotificationIndexSupport
44 {
45   private TypedAttribute attribute;
46   private JMXIndexSupport indexSupport;
47   private OID index;
48
49   public JMXAttributeNotificationIndexSupport(TypedAttribute attribute,
50                                               JMXIndexSupport indexSupport) {
51     this.attribute = attribute;
52     this.indexSupport = indexSupport;
53   }
54
55   public void intialize(Object JavaDoc notificationUserObject) {
56     Object JavaDoc key = notificationUserObject;
57     if (notificationUserObject instanceof CompositeDataSupport JavaDoc) {
58       key = ((CompositeDataSupport JavaDoc)
59              notificationUserObject).get(attribute.getName());
60     }
61     index = indexSupport.mapToIndex(key);
62   }
63
64   public OID getIndex(int objectIndex) {
65     return index;
66   }
67 }
68
Popular Tags