1 24 25 package org.objectweb.cjdbc.controller.jmx; 26 27 import java.io.ObjectInputStream ; 28 import java.util.Set ; 29 30 import javax.management.Attribute ; 31 import javax.management.AttributeList ; 32 import javax.management.AttributeNotFoundException ; 33 import javax.management.InstanceAlreadyExistsException ; 34 import javax.management.InstanceNotFoundException ; 35 import javax.management.IntrospectionException ; 36 import javax.management.InvalidAttributeValueException ; 37 import javax.management.ListenerNotFoundException ; 38 import javax.management.MBeanException ; 39 import javax.management.MBeanInfo ; 40 import javax.management.MBeanRegistrationException ; 41 import javax.management.MBeanServer ; 42 import javax.management.NotCompliantMBeanException ; 43 import javax.management.NotificationFilter ; 44 import javax.management.NotificationListener ; 45 import javax.management.ObjectInstance ; 46 import javax.management.ObjectName ; 47 import javax.management.OperationsException ; 48 import javax.management.QueryExp ; 49 import javax.management.ReflectionException ; 50 import javax.management.loading.ClassLoaderRepository ; 51 52 62 public class ChainedMBeanServer implements MBeanServer 63 64 { 65 private MBeanServer mbServer; 66 67 71 public ChainedMBeanServer() 72 { 73 this(null); 74 } 75 76 82 public ChainedMBeanServer(MBeanServer server) 83 { 84 setMBeanServer(server); 85 } 86 87 90 protected synchronized MBeanServer getMBeanServer() 91 { 92 return mbServer; 93 } 94 95 protected synchronized void setMBeanServer(MBeanServer server) 96 { 97 mbServer = server; 98 } 99 100 105 public void addNotificationListener(ObjectName observed, 106 NotificationListener listener, NotificationFilter filter, Object handback) 107 throws InstanceNotFoundException 108 { 109 getMBeanServer().addNotificationListener(observed, listener, filter, 110 handback); 111 } 112 113 118 public void addNotificationListener(ObjectName observed, ObjectName listener, 119 NotificationFilter filter, Object handback) 120 throws InstanceNotFoundException 121 { 122 getMBeanServer().addNotificationListener(observed, listener, filter, 123 handback); 124 } 125 126 130 public ObjectInstance createMBean(String className, ObjectName objectName) 131 throws ReflectionException , InstanceAlreadyExistsException , 132 MBeanRegistrationException , MBeanException , NotCompliantMBeanException 133 { 134 return getMBeanServer().createMBean(className, objectName); 135 } 136 137 141 public ObjectInstance createMBean(String className, ObjectName objectName, 142 Object [] args, String [] parameters) throws ReflectionException , 143 InstanceAlreadyExistsException , MBeanRegistrationException , 144 MBeanException , NotCompliantMBeanException 145 { 146 return getMBeanServer() 147 .createMBean(className, objectName, args, parameters); 148 } 149 150 154 public ObjectInstance createMBean(String className, ObjectName objectName, 155 ObjectName loaderName) throws ReflectionException , 156 InstanceAlreadyExistsException , MBeanRegistrationException , 157 MBeanException , NotCompliantMBeanException , InstanceNotFoundException 158 { 159 return getMBeanServer().createMBean(className, objectName, loaderName); 160 } 161 162 167 public ObjectInstance createMBean(String className, ObjectName objectName, 168 ObjectName loaderName, Object [] args, String [] parameters) 169 throws ReflectionException , InstanceAlreadyExistsException , 170 MBeanRegistrationException , MBeanException , NotCompliantMBeanException , 171 InstanceNotFoundException 172 { 173 return getMBeanServer().createMBean(className, objectName, loaderName, 174 args, parameters); 175 } 176 177 180 public ObjectInputStream deserialize(String className, byte[] bytes) 181 throws OperationsException , ReflectionException 182 { 183 return getMBeanServer().deserialize(className, bytes); 184 } 185 186 190 public ObjectInputStream deserialize(String className, ObjectName loaderName, 191 byte[] bytes) throws InstanceNotFoundException , OperationsException , 192 ReflectionException 193 { 194 return getMBeanServer().deserialize(className, loaderName, bytes); 195 } 196 197 201 public ObjectInputStream deserialize(ObjectName objectName, byte[] bytes) 202 throws InstanceNotFoundException , OperationsException 203 { 204 return getMBeanServer().deserialize(objectName, bytes); 205 } 206 207 211 public Object getAttribute(ObjectName objectName, String attribute) 212 throws MBeanException , AttributeNotFoundException , 213 InstanceNotFoundException , ReflectionException 214 { 215 return getMBeanServer().getAttribute(objectName, attribute); 216 } 217 218 222 public AttributeList getAttributes(ObjectName objectName, String [] attributes) 223 throws InstanceNotFoundException , ReflectionException 224 { 225 return getMBeanServer().getAttributes(objectName, attributes); 226 } 227 228 231 public String getDefaultDomain() 232 { 233 return getMBeanServer().getDefaultDomain(); 234 } 235 236 239 public String [] getDomains() 240 { 241 return getMBeanServer().getDomains(); 242 } 243 244 247 public Integer getMBeanCount() 248 { 249 return getMBeanServer().getMBeanCount(); 250 } 251 252 255 public MBeanInfo getMBeanInfo(ObjectName objectName) 256 throws InstanceNotFoundException , IntrospectionException , 257 ReflectionException 258 { 259 return getMBeanServer().getMBeanInfo(objectName); 260 } 261 262 265 public ObjectInstance getObjectInstance(ObjectName objectName) 266 throws InstanceNotFoundException 267 { 268 return getMBeanServer().getObjectInstance(objectName); 269 } 270 271 274 public Object instantiate(String className) throws ReflectionException , 275 MBeanException 276 { 277 return getMBeanServer().instantiate(className); 278 } 279 280 284 public Object instantiate(String className, Object [] args, String [] parameters) 285 throws ReflectionException , MBeanException 286 { 287 return getMBeanServer().instantiate(className, args, parameters); 288 } 289 290 294 public Object instantiate(String className, ObjectName loaderName) 295 throws ReflectionException , MBeanException , InstanceNotFoundException 296 { 297 return getMBeanServer().instantiate(className, loaderName); 298 } 299 300 304 public Object instantiate(String className, ObjectName loaderName, 305 Object [] args, String [] parameters) throws ReflectionException , 306 MBeanException , InstanceNotFoundException 307 { 308 return getMBeanServer() 309 .instantiate(className, loaderName, args, parameters); 310 } 311 312 316 public Object invoke(ObjectName objectName, String methodName, Object [] args, 317 String [] parameters) throws InstanceNotFoundException , MBeanException , 318 ReflectionException 319 { 320 return getMBeanServer().invoke(objectName, methodName, args, parameters); 321 } 322 323 327 public boolean isInstanceOf(ObjectName objectName, String className) 328 throws InstanceNotFoundException 329 { 330 return getMBeanServer().isInstanceOf(objectName, className); 331 } 332 333 336 public boolean isRegistered(ObjectName objectname) 337 { 338 return getMBeanServer().isRegistered(objectname); 339 } 340 341 345 public Set queryMBeans(ObjectName patternName, QueryExp filter) 346 { 347 return getMBeanServer().queryMBeans(patternName, filter); 348 } 349 350 354 public Set queryNames(ObjectName patternName, QueryExp filter) 355 { 356 return getMBeanServer().queryNames(patternName, filter); 357 } 358 359 363 public ObjectInstance registerMBean(Object mbean, ObjectName objectName) 364 throws InstanceAlreadyExistsException , MBeanRegistrationException , 365 NotCompliantMBeanException 366 { 367 return getMBeanServer().registerMBean(mbean, objectName); 368 } 369 370 374 public void removeNotificationListener(ObjectName observed, 375 NotificationListener listener) throws InstanceNotFoundException , 376 ListenerNotFoundException 377 { 378 getMBeanServer().removeNotificationListener(observed, listener); 379 } 380 381 385 public void removeNotificationListener(ObjectName observed, 386 ObjectName listener) throws InstanceNotFoundException , 387 ListenerNotFoundException 388 { 389 getMBeanServer().removeNotificationListener(observed, listener); 390 } 391 392 397 public void removeNotificationListener(ObjectName observed, 398 ObjectName listener, NotificationFilter filter, Object handback) 399 throws InstanceNotFoundException , ListenerNotFoundException 400 { 401 getMBeanServer().removeNotificationListener(observed, listener, filter, 402 handback); 403 } 404 405 410 public void removeNotificationListener(ObjectName observed, 411 NotificationListener listener, NotificationFilter filter, Object handback) 412 throws InstanceNotFoundException , ListenerNotFoundException 413 { 414 getMBeanServer().removeNotificationListener(observed, listener, filter, 415 handback); 416 } 417 418 422 public void setAttribute(ObjectName objectName, Attribute attribute) 423 throws InstanceNotFoundException , AttributeNotFoundException , 424 InvalidAttributeValueException , MBeanException , ReflectionException 425 { 426 getMBeanServer().setAttribute(objectName, attribute); 427 } 428 429 433 public AttributeList setAttributes(ObjectName objectName, 434 AttributeList attributes) throws InstanceNotFoundException , 435 ReflectionException 436 { 437 return getMBeanServer().setAttributes(objectName, attributes); 438 } 439 440 443 public void unregisterMBean(ObjectName objectName) 444 throws InstanceNotFoundException , MBeanRegistrationException 445 { 446 getMBeanServer().unregisterMBean(objectName); 447 } 448 449 452 public ClassLoader getClassLoaderFor(ObjectName mbeanName) 453 throws InstanceNotFoundException 454 { 455 return getMBeanServer().getClassLoaderFor(mbeanName); 456 } 457 458 461 public ClassLoader getClassLoader(ObjectName loaderName) 462 throws InstanceNotFoundException 463 { 464 return getMBeanServer().getClassLoader(loaderName); 465 } 466 467 470 public ClassLoaderRepository getClassLoaderRepository() 471 { 472 return getMBeanServer().getClassLoaderRepository(); 473 } 474 475 } 476 | Popular Tags |