KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*_############################################################################
2   _##
3   _## SNMP4J-AgentJMX - MBeanInvokationKeyProvider.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 javax.management.ObjectName JavaDoc;
26 import org.snmp4j.agent.mo.jmx.types.TypedAttribute;
27 import javax.management.MBeanServerConnection JavaDoc;
28 import java.io.IOException JavaDoc;
29 import javax.management.MBeanException JavaDoc;
30 import javax.management.AttributeNotFoundException JavaDoc;
31 import javax.management.InstanceNotFoundException JavaDoc;
32 import javax.management.ReflectionException JavaDoc;
33
34 /**
35  * If a MBean provides the keys for a SNMP conceptual table by an attribute
36  * and the objects that represent rows of that table can be accessed through
37  * a call to an operation of that MBean then this class can be used to provide
38  * the row objects for the SNMP conceptual table.
39  *
40  * @author Frank Fock
41  * @version 1.0
42  */

43 public class MBeanInvokationKeyProvider extends MBeanAttributeKeyProvider {
44
45   private String JavaDoc rowProvidingOperation;
46
47   public MBeanInvokationKeyProvider(ObjectName JavaDoc mBeanName,
48                                     TypedAttribute keyAttribute,
49                                     String JavaDoc rowProvidingOperation) {
50     super(mBeanName, keyAttribute);
51     this.rowProvidingOperation = rowProvidingOperation;
52   }
53
54   public MBeanInvokationKeyProvider(ObjectName JavaDoc mBeanName,
55                                     TypedAttribute keyAttribute,
56                                     String JavaDoc rowProvidingOperation,
57                                     boolean keysNeedSorting) {
58     super(mBeanName, keyAttribute, keysNeedSorting);
59     this.rowProvidingOperation = rowProvidingOperation;
60   }
61
62   public Object JavaDoc getRowValues(MBeanServerConnection JavaDoc server, Object JavaDoc indexObject)
63       throws IOException JavaDoc, MBeanException JavaDoc, AttributeNotFoundException JavaDoc,
64       InstanceNotFoundException JavaDoc, ReflectionException JavaDoc
65   {
66     Object JavaDoc row =
67         server.invoke(getObjectName(), rowProvidingOperation,
68                       new Object JavaDoc[] { indexObject },
69                       new String JavaDoc[] { getAttribute().getType().getName() });
70     return row;
71   }
72
73 }
74
Popular Tags