KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > 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 test.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: 37459 $
31  *
32  */

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