KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > jbossmx > performance > dynamic > support > Dyn


1 /*
2   * JBoss, Home of Professional Open Source
3   * Copyright 2005, JBoss Inc., and individual contributors as indicated
4   * by the @authors tag. See the copyright.txt in the distribution for a
5   * full listing of individual contributors.
6   *
7   * This is free software; you can redistribute it and/or modify it
8   * under the terms of the GNU Lesser General Public License as
9   * published by the Free Software Foundation; either version 2.1 of
10   * the License, or (at your option) any later version.
11   *
12   * This software is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15   * Lesser General Public License for more details.
16   *
17   * You should have received a copy of the GNU Lesser General Public
18   * License along with this software; if not, write to the Free
19   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21   */

22 package org.jboss.test.jbossmx.performance.dynamic.support;
23
24 import javax.management.*;
25
26 /**
27  * Dynamic MBean with a single void management operation.
28  *
29  * @author <a HREF="mailto:juha@jboss.org">Juha Lindfors</a>.
30  * @version $Revision: 37406 $
31  *
32  */

33 public class Dyn
34          implements DynamicMBean
35 {
36
37    private int counter = 0;
38
39    public Object JavaDoc getAttribute(String JavaDoc attribute)
40    throws AttributeNotFoundException, MBeanException, ReflectionException
41    {
42       return null;
43    }
44
45    public void setAttribute(Attribute attribute)
46    throws AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException
47       {}
48
49    public AttributeList getAttributes(String JavaDoc[] attributes)
50    {
51       return null;
52    }
53
54    public AttributeList setAttributes(AttributeList attributes)
55    {
56       return null;
57    }
58
59    public Object JavaDoc invoke(String JavaDoc actionName, Object JavaDoc[] params, String JavaDoc[] signature)
60    throws MBeanException, ReflectionException
61    {
62       if (actionName.equals("methodInvocation"))
63       {
64          methodInvocation();
65          return null;
66       }
67
68       else if (actionName.equals("counter"))
69       {
70          countInvocation();
71          return null;
72       }
73
74       else if (actionName.equals("mixedArguments"))
75       {
76          myMethod((Integer JavaDoc)params[0], ((Integer JavaDoc)params[1]).intValue(),
77                   (Object JavaDoc[][][])params[2], (Attribute)params[3]);
78       
79          return null;
80       }
81       
82       return null;
83    }
84
85    public MBeanInfo getMBeanInfo()
86    {
87
88       return new MBeanInfo(
89                 "test.performance.dynamic.support.Dynamic", "",
90                 null,
91                 null,
92                 new MBeanOperationInfo[] {
93                      new MBeanOperationInfo(
94                            "methodInvocation", "",
95                            null, void.class.getName(), 0)
96                      ,
97                      new MBeanOperationInfo(
98                            "counter", "",
99                            null, void.class.getName(), 0)
100                      },
101                 null
102              );
103    }
104
105    private void methodInvocation()
106    {}
107
108    private void countInvocation()
109    {
110       ++counter;
111    }
112
113    public void myMethod(Integer JavaDoc int1, int int2, Object JavaDoc[][][] space, Attribute attr)
114    {
115       
116    }
117    
118    public int getCount()
119    {
120       return counter;
121    }
122 }
123
124
125
126
127
Popular Tags