1 22 23 package org.continuent.sequoia.controller.jmx; 24 25 import java.io.ObjectInputStream ; 26 import java.util.Set ; 27 28 import javax.management.Attribute ; 29 import javax.management.AttributeList ; 30 import javax.management.AttributeNotFoundException ; 31 import javax.management.InstanceAlreadyExistsException ; 32 import javax.management.InstanceNotFoundException ; 33 import javax.management.IntrospectionException ; 34 import javax.management.InvalidAttributeValueException ; 35 import javax.management.ListenerNotFoundException ; 36 import javax.management.MBeanException ; 37 import javax.management.MBeanInfo ; 38 import javax.management.MBeanRegistrationException ; 39 import javax.management.MBeanServer ; 40 import javax.management.NotCompliantMBeanException ; 41 import javax.management.NotificationFilter ; 42 import javax.management.NotificationListener ; 43 import javax.management.ObjectInstance ; 44 import javax.management.ObjectName ; 45 import javax.management.OperationsException ; 46 import javax.management.QueryExp ; 47 import javax.management.ReflectionException ; 48 import javax.management.loading.ClassLoaderRepository ; 49 50 60 public class ChainedMBeanServer implements MBeanServer 61 62 { 63 private MBeanServer mbServer; 64 65 69 public ChainedMBeanServer() 70 { 71 this(null); 72 } 73 74 80 public ChainedMBeanServer(MBeanServer server) 81 { 82 setMBeanServer(server); 83 } 84 85 88 protected synchronized MBeanServer getMBeanServer() 89 { 90 return mbServer; 91 } 92 93 protected synchronized void setMBeanServer(MBeanServer server) 94 { 95 mbServer = server; 96 } 97 98 103 public void addNotificationListener(ObjectName observed, 104 NotificationListener listener, NotificationFilter filter, Object handback) 105 throws InstanceNotFoundException 106 { 107 getMBeanServer().addNotificationListener(observed, listener, filter, 108 handback); 109 } 110 111 116 public void addNotificationListener(ObjectName observed, ObjectName listener, 117 NotificationFilter filter, Object handback) 118 throws InstanceNotFoundException 119 { 120 getMBeanServer().addNotificationListener(observed, listener, filter, 121 handback); 122 } 123 124 128 public ObjectInstance createMBean(String className, ObjectName objectName) 129 throws ReflectionException , InstanceAlreadyExistsException , 130 MBeanRegistrationException , MBeanException , NotCompliantMBeanException 131 { 132 return getMBeanServer().createMBean(className, objectName); 133 } 134 135 139 public ObjectInstance createMBean(String className, ObjectName objectName, 140 Object [] args, String [] parameters) throws ReflectionException , 141 InstanceAlreadyExistsException , MBeanRegistrationException , 142 MBeanException , NotCompliantMBeanException 143 { 144 return getMBeanServer() 145 .createMBean(className, objectName, args, parameters); 146 } 147 148 152 public ObjectInstance createMBean(String className, ObjectName objectName, 153 ObjectName loaderName) throws ReflectionException , 154 InstanceAlreadyExistsException , MBeanRegistrationException , 155 MBeanException , NotCompliantMBeanException , InstanceNotFoundException 156 { 157 return getMBeanServer().createMBean(className, objectName, loaderName); 158 } 159 160 165 public ObjectInstance createMBean(String className, ObjectName objectName, 166 ObjectName loaderName, Object [] args, String [] parameters) 167 throws ReflectionException , InstanceAlreadyExistsException , 168 MBeanRegistrationException , MBeanException , NotCompliantMBeanException , 169 InstanceNotFoundException 170 { 171 return getMBeanServer().createMBean(className, objectName, loaderName, 172 args, parameters); 173 } 174 175 178 public ObjectInputStream deserialize(String className, byte[] bytes) 179 throws OperationsException , ReflectionException 180 { 181 return getMBeanServer().deserialize(className, bytes); 182 } 183 184 188 public ObjectInputStream deserialize(String className, ObjectName loaderName, 189 byte[] bytes) throws InstanceNotFoundException , OperationsException , 190 ReflectionException 191 { 192 return getMBeanServer().deserialize(className, loaderName, bytes); 193 } 194 195 199 public ObjectInputStream deserialize(ObjectName objectName, byte[] bytes) 200 throws InstanceNotFoundException , OperationsException 201 { 202 return getMBeanServer().deserialize(objectName, bytes); 203 } 204 205 209 public Object getAttribute(ObjectName objectName, String attribute) 210 throws MBeanException , AttributeNotFoundException , 211 InstanceNotFoundException , ReflectionException 212 { 213 return getMBeanServer().getAttribute(objectName, attribute); 214 } 215 216 220 public AttributeList getAttributes(ObjectName objectName, String [] attributes) 221 throws InstanceNotFoundException , ReflectionException 222 { 223 return getMBeanServer().getAttributes(objectName, attributes); 224 } 225 226 229 public String getDefaultDomain() 230 { 231 return getMBeanServer().getDefaultDomain(); 232 } 233 234 237 public String [] getDomains() 238 { 239 return getMBeanServer().getDomains(); 240 } 241 242 245 public Integer getMBeanCount() 246 { 247 return getMBeanServer().getMBeanCount(); 248 } 249 250 253 public MBeanInfo getMBeanInfo(ObjectName objectName) 254 throws InstanceNotFoundException , IntrospectionException , 255 ReflectionException 256 { 257 return getMBeanServer().getMBeanInfo(objectName); 258 } 259 260 263 public ObjectInstance getObjectInstance(ObjectName objectName) 264 throws InstanceNotFoundException 265 { 266 return getMBeanServer().getObjectInstance(objectName); 267 } 268 269 272 public Object instantiate(String className) throws ReflectionException , 273 MBeanException 274 { 275 return getMBeanServer().instantiate(className); 276 } 277 278 282 public Object instantiate(String className, Object [] args, String [] parameters) 283 throws ReflectionException , MBeanException 284 { 285 return getMBeanServer().instantiate(className, args, parameters); 286 } 287 288 292 public Object instantiate(String className, ObjectName loaderName) 293 throws ReflectionException , MBeanException , InstanceNotFoundException 294 { 295 return getMBeanServer().instantiate(className, loaderName); 296 } 297 298 302 public Object instantiate(String className, ObjectName loaderName, 303 Object [] args, String [] parameters) throws ReflectionException , 304 MBeanException , InstanceNotFoundException 305 { 306 return getMBeanServer() 307 .instantiate(className, loaderName, args, parameters); 308 } 309 310 314 public Object invoke(ObjectName objectName, String methodName, Object [] args, 315 String [] parameters) throws InstanceNotFoundException , MBeanException , 316 ReflectionException 317 { 318 return getMBeanServer().invoke(objectName, methodName, args, parameters); 319 } 320 321 325 public boolean isInstanceOf(ObjectName objectName, String className) 326 throws InstanceNotFoundException 327 { 328 return getMBeanServer().isInstanceOf(objectName, className); 329 } 330 331 334 public boolean isRegistered(ObjectName objectname) 335 { 336 return getMBeanServer().isRegistered(objectname); 337 } 338 339 343 public Set queryMBeans(ObjectName patternName, QueryExp filter) 344 { 345 return getMBeanServer().queryMBeans(patternName, filter); 346 } 347 348 352 public Set queryNames(ObjectName patternName, QueryExp filter) 353 { 354 return getMBeanServer().queryNames(patternName, filter); 355 } 356 357 361 public ObjectInstance registerMBean(Object mbean, ObjectName objectName) 362 throws InstanceAlreadyExistsException , MBeanRegistrationException , 363 NotCompliantMBeanException 364 { 365 return getMBeanServer().registerMBean(mbean, objectName); 366 } 367 368 372 public void removeNotificationListener(ObjectName observed, 373 NotificationListener listener) throws InstanceNotFoundException , 374 ListenerNotFoundException 375 { 376 getMBeanServer().removeNotificationListener(observed, listener); 377 } 378 379 383 public void removeNotificationListener(ObjectName observed, 384 ObjectName listener) throws InstanceNotFoundException , 385 ListenerNotFoundException 386 { 387 getMBeanServer().removeNotificationListener(observed, listener); 388 } 389 390 395 public void removeNotificationListener(ObjectName observed, 396 ObjectName listener, NotificationFilter filter, Object handback) 397 throws InstanceNotFoundException , ListenerNotFoundException 398 { 399 getMBeanServer().removeNotificationListener(observed, listener, filter, 400 handback); 401 } 402 403 408 public void removeNotificationListener(ObjectName observed, 409 NotificationListener listener, NotificationFilter filter, Object handback) 410 throws InstanceNotFoundException , ListenerNotFoundException 411 { 412 getMBeanServer().removeNotificationListener(observed, listener, filter, 413 handback); 414 } 415 416 420 public void setAttribute(ObjectName objectName, Attribute attribute) 421 throws InstanceNotFoundException , AttributeNotFoundException , 422 InvalidAttributeValueException , MBeanException , ReflectionException 423 { 424 getMBeanServer().setAttribute(objectName, attribute); 425 } 426 427 431 public AttributeList setAttributes(ObjectName objectName, 432 AttributeList attributes) throws InstanceNotFoundException , 433 ReflectionException 434 { 435 return getMBeanServer().setAttributes(objectName, attributes); 436 } 437 438 441 public void unregisterMBean(ObjectName objectName) 442 throws InstanceNotFoundException , MBeanRegistrationException 443 { 444 getMBeanServer().unregisterMBean(objectName); 445 } 446 447 450 public ClassLoader getClassLoaderFor(ObjectName mbeanName) 451 throws InstanceNotFoundException 452 { 453 return getMBeanServer().getClassLoaderFor(mbeanName); 454 } 455 456 459 public ClassLoader getClassLoader(ObjectName loaderName) 460 throws InstanceNotFoundException 461 { 462 return getMBeanServer().getClassLoader(loaderName); 463 } 464 465 468 public ClassLoaderRepository getClassLoaderRepository() 469 { 470 return getMBeanServer().getClassLoaderRepository(); 471 } 472 473 } 474 | Popular Tags |