1 22 package test.performance.dynamic.support; 23 24 import javax.management.*; 25 26 33 public class Dyn implements DynamicMBean 34 { 35 36 private int counter = 0; 37 38 public Object getAttribute(String 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 [] attributes) 49 { 50 return null; 51 } 52 53 public AttributeList setAttributes(AttributeList attributes) 54 { 55 return null; 56 } 57 58 public Object invoke(String actionName, Object [] params, String [] 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 )params[0], ((Integer )params[1]).intValue(), 87 (Object [][][])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 myMethod(Integer int1, int int2, Object [][][] space, Attribute attr) 122 { 123 ++counter; 124 return new Integer (counter); 125 } 126 127 public int getCount() 128 { 129 return counter; 130 } 131 } 132 133 134 135 136 | Popular Tags |