1 22 23 package org.continuent.sequoia.controller.jmx; 24 25 import javax.management.ListenerNotFoundException ; 26 import javax.management.MBeanAttributeInfo ; 27 import javax.management.MBeanConstructorInfo ; 28 import javax.management.MBeanInfo ; 29 import javax.management.MBeanNotificationInfo ; 30 import javax.management.MBeanOperationInfo ; 31 import javax.management.MBeanParameterInfo ; 32 import javax.management.NotCompliantMBeanException ; 33 import javax.management.Notification ; 34 import javax.management.NotificationBroadcasterSupport ; 35 import javax.management.NotificationEmitter ; 36 import javax.management.NotificationFilter ; 37 import javax.management.NotificationListener ; 38 import javax.management.StandardMBean ; 39 40 import org.continuent.sequoia.common.i18n.JmxTranslate; 41 42 48 public abstract class AbstractStandardMBean extends StandardMBean 49 implements 50 NotificationEmitter 51 { 52 55 private transient NotificationBroadcasterSupport broadcaster; 56 57 65 public AbstractStandardMBean(Class mbeanInterface) 66 throws NotCompliantMBeanException 67 { 68 super(mbeanInterface); 69 broadcaster = new NotificationBroadcasterSupport (); 70 } 71 72 76 public void addNotificationListener(NotificationListener listener, 77 NotificationFilter filter, Object handback) 78 { 79 broadcaster.addNotificationListener(listener, filter, handback); 80 } 81 82 87 public NotificationBroadcasterSupport getBroadcaster() 88 { 89 return broadcaster; 90 } 91 92 95 public MBeanNotificationInfo [] getNotificationInfo() 96 { 97 if (broadcaster == null) 99 return new MBeanNotificationInfo [0]; 101 102 return broadcaster.getNotificationInfo(); 103 } 104 105 108 public void removeNotificationListener(NotificationListener listener) 109 throws ListenerNotFoundException 110 { 111 broadcaster.removeNotificationListener(listener); 112 } 113 114 118 public void removeNotificationListener(NotificationListener listener, 119 NotificationFilter filter, Object handback) 120 throws ListenerNotFoundException 121 { 122 broadcaster.removeNotificationListener(listener, filter, handback); 123 } 124 125 130 public void sendNotification(Notification notification) 131 { 132 broadcaster.sendNotification(notification); 133 } 134 135 139 144 public abstract String getAssociatedString(); 145 146 151 protected String getDescription(MBeanInfo info) 152 { 153 return JmxTranslate.get("mbean." + getAssociatedString() + ".description"); 154 } 155 156 159 protected String getDescription(MBeanConstructorInfo ctor) 160 { 161 return JmxTranslate.get("mbean." + getAssociatedString() + ".constructor." 162 + ctor.getSignature().length); 163 } 164 165 169 protected String getParameterName(MBeanConstructorInfo ctor, 170 MBeanParameterInfo param, int sequence) 171 { 172 return JmxTranslate.get("mbean." + getAssociatedString() + ".constructor." 173 + ctor.getSignature().length + ".parameter.name." + sequence); 174 } 175 176 180 protected String getDescription(MBeanConstructorInfo ctor, 181 MBeanParameterInfo param, int sequence) 182 { 183 return JmxTranslate.get("mbean." + getAssociatedString() + ".constructor." 184 + ctor.getSignature().length + ".parameter.description." + sequence); 185 } 186 187 190 protected String getDescription(MBeanAttributeInfo info) 191 { 192 return JmxTranslate.get("mbean." + getAssociatedString() + ".attribute." 193 + info.getName()); 194 } 195 196 199 protected String getDescription(MBeanOperationInfo info) 200 { 201 return JmxTranslate.get("mbean." + getAssociatedString() + "." 202 + info.getName()); 203 } 204 205 209 protected String getParameterName(MBeanOperationInfo op, 210 MBeanParameterInfo param, int sequence) 211 { 212 return JmxTranslate.get("mbean." + getAssociatedString() + "." 213 + op.getName() + ".parameter.name." + sequence); 214 } 215 216 220 protected String getDescription(MBeanOperationInfo op, 221 MBeanParameterInfo param, int sequence) 222 { 223 return JmxTranslate.get("mbean." + getAssociatedString() + "." 224 + op.getName() + ".parameter.description." + sequence); 225 } 226 } | Popular Tags |