KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > jbossnet > jmx > server > JMXDynamicTest


1 /*
2 * JBoss, the OpenSource J2EE webOS
3 *
4 * Distributable under LGPL license.
5 * See terms of license at gnu.org.
6 */

7 package org.jboss.test.jbossnet.jmx.server;
8
9 import javax.management.Attribute JavaDoc;
10 import javax.management.AttributeList JavaDoc;
11 import javax.management.AttributeNotFoundException JavaDoc;
12 import javax.management.DynamicMBean JavaDoc;
13 import javax.management.InvalidAttributeValueException JavaDoc;
14 import javax.management.MBeanAttributeInfo JavaDoc;
15 import javax.management.MBeanConstructorInfo JavaDoc;
16 import javax.management.MBeanException JavaDoc;
17 import javax.management.MBeanInfo JavaDoc;
18 import javax.management.MBeanNotificationInfo JavaDoc;
19 import javax.management.MBeanOperationInfo JavaDoc;
20 import javax.management.MBeanParameterInfo JavaDoc;
21 import javax.management.ReflectionException JavaDoc;
22
23 /**
24  * A test dynamic mbean that will be provided as a web-service
25  * @jmx.mbean name="jboss.net:service=JMXDynamicTestMBean"
26  * @jboss-net.web-service urn="JMXDynamicTest" expose-all="true"
27  * @author jung
28  * @version $Revision: 1.1.1.1.6.1 $
29  * @since 18.02.04
30  */

31
32 public class JMXDynamicTest implements DynamicMBean JavaDoc
33 {
34
35    /* Member variables */
36    private String JavaDoc testString = "JMX_TEST_STRING";
37
38    /* (non-Javadoc)
39     * @see javax.management.DynamicMBean#getAttribute(java.lang.String)
40     */

41    public Object JavaDoc getAttribute(String JavaDoc attribute)
42       throws AttributeNotFoundException JavaDoc, MBeanException JavaDoc, ReflectionException JavaDoc
43    {
44       return testString;
45    }
46
47    /* (non-Javadoc)
48     * @see javax.management.DynamicMBean#setAttribute(javax.management.Attribute)
49     */

50    public void setAttribute(Attribute JavaDoc attribute)
51       throws
52          AttributeNotFoundException JavaDoc,
53          InvalidAttributeValueException JavaDoc,
54          MBeanException JavaDoc,
55          ReflectionException JavaDoc
56    {
57       testString = (String JavaDoc) attribute.getValue();
58    }
59
60    /* (non-Javadoc)
61     * @see javax.management.DynamicMBean#getAttributes(java.lang.String[])
62     */

63    public AttributeList JavaDoc getAttributes(String JavaDoc[] attributes)
64    {
65       return null;
66    }
67
68    /* (non-Javadoc)
69     * @see javax.management.DynamicMBean#setAttributes(javax.management.AttributeList)
70     */

71    public AttributeList JavaDoc setAttributes(AttributeList JavaDoc attributes)
72    {
73       return null;
74    }
75
76    /* (non-Javadoc)
77     * @see javax.management.DynamicMBean#invoke(java.lang.String, java.lang.Object[], java.lang.String[])
78     */

79    public Object JavaDoc invoke(String JavaDoc actionName, Object JavaDoc[] params, String JavaDoc[] signature)
80       throws MBeanException JavaDoc, ReflectionException JavaDoc
81    {
82       return null;
83    }
84
85    /* (non-Javadoc)
86     * @see javax.management.DynamicMBean#getMBeanInfo()
87     */

88    public MBeanInfo JavaDoc getMBeanInfo()
89    {
90       MBeanAttributeInfo JavaDoc[] attrs =
91          new MBeanAttributeInfo JavaDoc[] {
92              new MBeanAttributeInfo JavaDoc(
93                "TestString",
94                "java.lang.String",
95                "shit",
96                true,
97                true,
98                false)};
99       MBeanOperationInfo JavaDoc[] ops =
100          new MBeanOperationInfo JavaDoc[] {
101              new MBeanOperationInfo JavaDoc(
102                "noopOperation",
103                "shit",
104                new MBeanParameterInfo JavaDoc[0],
105                "void",
106                MBeanOperationInfo.UNKNOWN)};
107       MBeanInfo JavaDoc result =
108          new MBeanInfo JavaDoc(
109             getClass().getName(),
110             "shit",
111             attrs,
112             new MBeanConstructorInfo JavaDoc[0],
113             ops,
114             new MBeanNotificationInfo JavaDoc[0]);
115       return result;
116    }
117 }
118
Popular Tags