1 8 9 package test.javax.management.support; 10 11 import javax.management.Attribute ; 12 import javax.management.AttributeList ; 13 import javax.management.AttributeNotFoundException ; 14 import javax.management.DynamicMBean ; 15 import javax.management.InvalidAttributeValueException ; 16 import javax.management.MBeanAttributeInfo ; 17 import javax.management.MBeanConstructorInfo ; 18 import javax.management.MBeanException ; 19 import javax.management.MBeanInfo ; 20 import javax.management.MBeanNotificationInfo ; 21 import javax.management.MBeanOperationInfo ; 22 import javax.management.MBeanRegistration ; 23 import javax.management.MBeanServer ; 24 import javax.management.ObjectName ; 25 import javax.management.ReflectionException ; 26 27 30 public class ExceptionGeneratingDMB 31 implements DynamicMBean , MBeanRegistration 32 { 33 private boolean invoked = false; 34 private boolean register; 35 36 public ExceptionGeneratingDMB(boolean register) 37 { 38 this.register = register; 39 } 40 41 public MBeanInfo getMBeanInfo() 42 { 43 if ((this.register == false) || (this.invoked == true)) 44 { 45 throw new RuntimeException (); 46 } 47 else 48 { 49 invoked = true; 50 return new MBeanInfo ("test.javax.management.support.test.ExceptionGeneratingDMB", 51 "Exception generating DynamicMBean", 52 new MBeanAttributeInfo [0], 53 new MBeanConstructorInfo [0], 54 new MBeanOperationInfo [0], 55 new MBeanNotificationInfo [0]); 56 } 57 } 58 59 public Object getAttribute(String attribute) 60 throws AttributeNotFoundException , MBeanException , ReflectionException 61 { 62 return null; 63 } 64 65 public void setAttribute(Attribute attribute) 66 throws 67 AttributeNotFoundException , 68 InvalidAttributeValueException , 69 MBeanException , 70 ReflectionException 71 { 72 } 73 74 public AttributeList getAttributes(String [] attributes) 75 { 76 return null; 77 } 78 79 public AttributeList setAttributes(AttributeList attributes) 80 { 81 return null; 82 } 83 84 public Object invoke(String method, Object [] arguments, String [] params) 85 throws MBeanException , ReflectionException 86 { 87 return null; 88 } 89 90 public ObjectName preRegister(MBeanServer server, ObjectName name) 91 throws Exception 92 { 93 if (name.getKeyProperty("register").compareTo("no") == 0) 94 { 95 this.register = false; 96 } 97 return name; 98 } 99 100 public void postRegister(Boolean registrationDone) 101 { 102 } 103 104 public void preDeregister() throws Exception 105 { 106 } 107 108 public void postDeregister() 109 { 110 } 111 112 } 113 | Popular Tags |