001: /*
002: * JBoss, Home of Professional Open Source.
003: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004: * as indicated by the @author tags. See the copyright.txt file in the
005: * distribution for a full listing of individual contributors.
006: *
007: * This is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU Lesser General Public License as
009: * published by the Free Software Foundation; either version 2.1 of
010: * the License, or (at your option) any later version.
011: *
012: * This software is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this software; if not, write to the Free
019: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021: */
022: package test.performance.dynamic.support;
023:
024: import javax.management.*;
025:
026: /**
027: * Dynamic MBean with a single void management operation.
028: *
029: * @author <a href="mailto:juha@jboss.org">Juha Lindfors</a>.
030: * @version $Revision: 57200 $
031: *
032: */
033: public class Dyn implements DynamicMBean {
034:
035: private int counter = 0;
036:
037: public Object getAttribute(String attribute)
038: throws AttributeNotFoundException, MBeanException,
039: ReflectionException {
040: return null;
041: }
042:
043: public void setAttribute(Attribute attribute)
044: throws AttributeNotFoundException,
045: InvalidAttributeValueException, MBeanException,
046: ReflectionException {
047: }
048:
049: public AttributeList getAttributes(String[] attributes) {
050: return null;
051: }
052:
053: public AttributeList setAttributes(AttributeList attributes) {
054: return null;
055: }
056:
057: public Object invoke(String actionName, Object[] params,
058: String[] signature) throws MBeanException,
059: ReflectionException {
060: if (actionName.equals("bogus1"))
061: return null;
062: else if (actionName.equals("bogus2"))
063: return null;
064: else if (actionName.equals("bogus3"))
065: return null;
066: else if (actionName.equals("bogus4"))
067: return null;
068: else if (actionName.equals("bogus5"))
069: return null;
070:
071: else if (actionName.equals("methodInvocation")) {
072: methodInvocation();
073: return null;
074: }
075:
076: else if (actionName.equals("counter")) {
077: countInvocation();
078: return null;
079: }
080:
081: else if (actionName.equals("mixedArguments")) {
082: return myMethod((Integer) params[0], ((Integer) params[1])
083: .intValue(), (Object[][][]) params[2],
084: (Attribute) params[3]);
085:
086: }
087:
088: return null;
089: }
090:
091: public MBeanInfo getMBeanInfo() {
092:
093: return new MBeanInfo(
094: "test.performance.dynamic.support.Dynamic", "", null,
095: null, new MBeanOperationInfo[] {
096: new MBeanOperationInfo("methodInvocation", "",
097: null, void.class.getName(), 0),
098: new MBeanOperationInfo("counter", "", null,
099: void.class.getName(), 0) }, null);
100: }
101:
102: private void methodInvocation() {
103: }
104:
105: private void countInvocation() {
106: }
107:
108: public Object myMethod(Integer int1, int int2, Object[][][] space,
109: Attribute attr) {
110: ++counter;
111: return new Integer(counter);
112: }
113:
114: public int getCount() {
115: return counter;
116: }
117: }
|