01: /*_############################################################################
02: _##
03: _## SNMP4J-AgentJMX - JMXAttributeNotificationIndexSupport.java
04: _##
05: _## Copyright (C) 2006-2007 Frank Fock (SNMP4J.org)
06: _##
07: _## This program is free software; you can redistribute it and/or modify
08: _## it under the terms of the GNU General Public License version 2 as
09: _## 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;
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 implements
43: JMXNotificationIndexSupport {
44: private TypedAttribute attribute;
45: private JMXIndexSupport indexSupport;
46: private OID index;
47:
48: public JMXAttributeNotificationIndexSupport(
49: TypedAttribute attribute, JMXIndexSupport indexSupport) {
50: this .attribute = attribute;
51: this .indexSupport = indexSupport;
52: }
53:
54: public void intialize(Object notificationUserObject) {
55: Object key = notificationUserObject;
56: if (notificationUserObject instanceof CompositeDataSupport) {
57: key = ((CompositeDataSupport) notificationUserObject)
58: .get(attribute.getName());
59: }
60: index = indexSupport.mapToIndex(key);
61: }
62:
63: public OID getIndex(int objectIndex) {
64: return index;
65: }
66: }
|