1 package org.oddjob.jmx.server; 2 3 import java.util.Map ; 4 5 import javax.management.MBeanAttributeInfo ; 6 import javax.management.MBeanException ; 7 import javax.management.MBeanNotificationInfo ; 8 import javax.management.MBeanOperationInfo ; 9 import javax.management.MBeanParameterInfo ; 10 import javax.management.Notification ; 11 import javax.management.ReflectionException ; 12 13 import org.oddjob.jmx.client.Describeable; 14 import org.oddjob.monitor.model.Describer; 15 16 18 public class DescribeableInfo implements InterfaceInfo { 19 20 public Class interfaceClass() { 21 return Describeable.class; 22 } 23 24 public MBeanAttributeInfo [] getMBeanAttributeInfo() { 25 return new MBeanAttributeInfo [0]; 26 } 27 28 public MBeanOperationInfo [] getMBeanOperationInfo() { 29 return new MBeanOperationInfo [] { 30 new MBeanOperationInfo ("describe", "Describe properties.", 31 new MBeanParameterInfo [0], Map .class.getName(), 32 MBeanOperationInfo.INFO) 33 }; 34 } 35 36 public MBeanNotificationInfo [] getMBeanNotificationInfo() { 37 return new MBeanNotificationInfo [0]; 38 } 39 40 41 public InterfaceHandler attach(Object target, OddjobMBean ojmb) { 42 return new ObjectInterfaceHandler(target); 43 } 44 45 class ObjectInterfaceHandler implements InterfaceHandler { 46 47 private final Object object; 48 49 ObjectInterfaceHandler(Object object) { 50 this.object = object; 51 } 52 53 public Object invoke(String actionName, Object [] params, String [] signature) throws MBeanException , ReflectionException { 54 if ("describe".equals(actionName) 55 && signature.length == 0) { 56 return Describer.describe(object); 57 } 58 else { 59 throw new ReflectionException ( 60 new IllegalStateException ("invoked for an unknown method."), 61 actionName); 62 } 63 } 64 65 public Notification [] getLastNotifications() { 66 return null; 67 } 68 69 public void destroy() { 70 } 71 } 72 } | Popular Tags |