1 16 17 package org.springframework.jmx.export; 18 19 import javax.management.Attribute ; 20 import javax.management.AttributeList ; 21 import javax.management.AttributeNotFoundException ; 22 import javax.management.DynamicMBean ; 23 import javax.management.InvalidAttributeValueException ; 24 import javax.management.MBeanAttributeInfo ; 25 import javax.management.MBeanConstructorInfo ; 26 import javax.management.MBeanException ; 27 import javax.management.MBeanInfo ; 28 import javax.management.MBeanNotificationInfo ; 29 import javax.management.MBeanOperationInfo ; 30 import javax.management.ReflectionException ; 31 32 35 public class TestDynamicMBean implements DynamicMBean { 36 37 public void setFailOnInit(boolean failOnInit) { 38 if (failOnInit) { 39 throw new IllegalArgumentException ("Failing on initialization"); 40 } 41 } 42 43 public Object getAttribute(String attribute) 44 throws AttributeNotFoundException , MBeanException , ReflectionException { 45 46 if ("name".equals(attribute)) { 47 return "Rob Harrop"; 48 } 49 else { 50 return null; 51 } 52 } 53 54 public void setAttribute(Attribute arg0) throws AttributeNotFoundException , 55 InvalidAttributeValueException , MBeanException , ReflectionException { 56 } 57 58 public AttributeList getAttributes(String [] arg0) { 59 return null; 60 } 61 62 public AttributeList setAttributes(AttributeList arg0) { 63 return null; 64 } 65 66 public Object invoke(String arg0, Object [] arg1, String [] arg2) 67 throws MBeanException , ReflectionException { 68 return null; 69 } 70 71 public MBeanInfo getMBeanInfo() { 72 MBeanAttributeInfo attr = 73 new MBeanAttributeInfo ("name", "java.lang.String", "", true, false, false); 74 75 MBeanInfo inf = new MBeanInfo ( 76 TestDynamicMBean.class.getName(), "", 77 new MBeanAttributeInfo []{attr}, 78 new MBeanConstructorInfo [0], 79 new MBeanOperationInfo [0], 80 new MBeanNotificationInfo [0]); 81 82 return inf; 83 } 84 85 } 86 | Popular Tags |