1 8 9 package test.javax.management.support; 10 11 import javax.management.MBeanAttributeInfo ; 12 import javax.management.MBeanConstructorInfo ; 13 import javax.management.MBeanInfo ; 14 import javax.management.MBeanOperationInfo ; 15 import javax.management.MBeanParameterInfo ; 16 import javax.management.NotCompliantMBeanException ; 17 import javax.management.StandardMBean ; 18 19 import test.MutableInteger; 20 21 24 public class StandardMBeanSupport 25 { 26 29 public static class SubclassNotCompliant extends StandardMBean 30 { 31 public SubclassNotCompliant() throws NotCompliantMBeanException 32 { 33 super(null); 34 } 35 } 36 37 40 public static class SubclassWithNoManagement extends StandardMBean implements SubclassWithNoManagementMBean 41 { 42 public SubclassWithNoManagement() throws NotCompliantMBeanException 43 { 44 super(null); 45 } 46 47 public Object test() 48 { 49 return new Object (); 50 } 51 } 52 53 public interface SubclassWithNoManagementMBean 54 { 55 public Object test(); 56 } 57 58 public static class SubclassWithManagement extends StandardMBean implements Management 59 { 60 public SubclassWithManagement() throws NotCompliantMBeanException 61 { 62 super(Management.class); 63 } 64 65 public void cannotCall() 66 { 67 } 68 69 public Object test() 70 { 71 return new Object (); 72 } 73 } 74 75 public interface Management 76 { 77 public Object test(); 78 } 79 80 public static class ImplementationWithNoManagement implements ImplementationWithNoManagementMBean 81 { 82 public Object test() 83 { 84 return new Object (); 85 } 86 } 87 88 public interface ImplementationWithNoManagementMBean 89 { 90 public Object test(); 91 } 92 93 public static class ImplementationWithManagement implements Management 94 { 95 public Object test() 96 { 97 return new Object (); 98 } 99 } 100 101 public interface FullManagement 102 { 103 public void setAttrib(int i); 104 105 public void operation(int i); 106 } 107 108 public interface PublicInterfaceMBean 109 { 110 public Object test(); 111 } 112 113 private static class PublicInterface implements PublicInterfaceMBean 114 { 115 public PublicInterface() 116 { 117 } 118 119 public Object test() 120 { 121 return new Object (); 122 } 123 } 124 125 public static PublicInterfaceMBean createPublicInterfaceMBean() 126 { 127 return new PublicInterface(); 128 } 129 130 131 public static class CallbackCounter extends StandardMBean implements FullManagement 132 { 133 private MutableInteger count; 134 135 public CallbackCounter(int dummy) throws NotCompliantMBeanException 136 { 137 super(FullManagement.class); 139 } 140 141 public void setAttrib(int i) 142 { 143 } 144 145 public void operation(int i) 146 { 147 } 148 149 public int getCount() 150 { 151 return count.get(); 152 } 153 154 protected String getClassName(MBeanInfo info) 155 { 156 increment(); 157 return super.getClassName(info); 158 } 159 160 protected String getDescription(MBeanInfo info) 161 { 162 increment(); 163 return super.getDescription(info); 164 } 165 166 protected String getDescription(MBeanAttributeInfo info) 167 { 168 increment(); 169 return super.getDescription(info); 170 } 171 172 protected String getDescription(MBeanConstructorInfo info) 173 { 174 increment(); 175 return super.getDescription(info); 176 } 177 178 protected String getDescription(MBeanOperationInfo info) 179 { 180 increment(); 181 return super.getDescription(info); 182 } 183 184 protected String getDescription(MBeanConstructorInfo constructor, MBeanParameterInfo param, int sequence) 185 { 186 increment(); 187 return super.getDescription(constructor, param, sequence); 188 } 189 190 protected String getDescription(MBeanOperationInfo operation, MBeanParameterInfo param, int sequence) 191 { 192 increment(); 193 return super.getDescription(operation, param, sequence); 194 } 195 196 protected String getParameterName(MBeanConstructorInfo constructor, MBeanParameterInfo param, int sequence) 197 { 198 increment(); 199 return super.getParameterName(constructor, param, sequence); 200 } 201 202 protected String getParameterName(MBeanOperationInfo operation, MBeanParameterInfo param, int sequence) 203 { 204 increment(); 205 return super.getParameterName(operation, param, sequence); 206 } 207 208 protected int getImpact(MBeanOperationInfo info) 209 { 210 increment(); 211 return super.getImpact(info); 212 } 213 214 private void increment() 215 { 216 if (count == null) count = new MutableInteger(0); 217 count.set(count.get() + 1); 218 } 219 220 } 221 222 } 223 | Popular Tags |