1 package org.oddjob.jmx.server; 2 3 import javax.management.MBeanAttributeInfo ; 4 import javax.management.MBeanException ; 5 import javax.management.MBeanNotificationInfo ; 6 import javax.management.MBeanOperationInfo ; 7 import javax.management.MBeanParameterInfo ; 8 import javax.management.Notification ; 9 import javax.management.ReflectionException ; 10 11 import org.oddjob.jmx.RemoteOddjob; 12 import org.oddjob.jmx.SharedConstants; 13 14 16 public class RemoteOddjobInfo implements InterfaceInfo { 17 18 public Class interfaceClass() { 19 return RemoteOddjob.class; 20 } 21 22 public MBeanAttributeInfo [] getMBeanAttributeInfo() { 23 return new MBeanAttributeInfo [0]; 24 } 25 26 public MBeanOperationInfo [] getMBeanOperationInfo() { 27 return new MBeanOperationInfo [] { 28 new MBeanOperationInfo (SharedConstants.SERVER_INFO_METHOD, 29 "The OddjobMBean Server side information.", 30 new MBeanParameterInfo [0], 31 ServerInfo.class.getName(), 32 MBeanOperationInfo.INFO), 33 new MBeanOperationInfo (SharedConstants.RESYNC_METHOD, 34 "Re-synchronize the MBean.", 35 new MBeanParameterInfo [0], 36 Void.TYPE.getName(), 37 MBeanOperationInfo.ACTION), 38 new MBeanOperationInfo (SharedConstants.DESTROY_METHOD, 39 "Destroy the MBean.", 40 new MBeanParameterInfo [0], 41 Void.TYPE.getName(), 42 MBeanOperationInfo.ACTION) 43 }; 44 } 45 46 public MBeanNotificationInfo [] getMBeanNotificationInfo() { 47 return new MBeanNotificationInfo [0]; 48 } 49 50 51 public InterfaceHandler attach(Object target, OddjobMBean ojmb) { 52 return new RemoteOddjobHandler(ojmb); 53 } 54 55 class RemoteOddjobHandler implements InterfaceHandler { 56 57 private final OddjobMBean ojmb; 58 59 RemoteOddjobHandler(OddjobMBean ojmb) { 60 this.ojmb = ojmb; 61 } 62 63 public Object invoke(String actionName, Object [] params, String [] signature) throws MBeanException , ReflectionException { 64 if (SharedConstants.DESTROY_METHOD.equals(actionName) 65 && params.length == 0) { 66 ojmb.destroy(); 67 return null; 68 } 69 else if (SharedConstants.RESYNC_METHOD.equals(actionName) 70 && params.length == 0) { 71 ojmb.resync(); 72 return null; 73 } 74 else if (SharedConstants.SERVER_INFO_METHOD.equals(actionName) 75 && params.length == 0) { 76 return ojmb.serverSideInfo(); 77 } 78 else { 79 throw new ReflectionException ( 80 new IllegalStateException ("invoked for an unknown method."), 81 actionName); 82 } 83 } 84 85 public Notification [] getLastNotifications() { 86 return null; 87 } 88 89 public void destroy() { 90 } 91 } 92 } | Popular Tags |