1 24 25 package org.objectweb.cjdbc.controller.jmx; 26 27 import javax.management.ListenerNotFoundException ; 28 import javax.management.MBeanAttributeInfo ; 29 import javax.management.MBeanConstructorInfo ; 30 import javax.management.MBeanInfo ; 31 import javax.management.MBeanNotificationInfo ; 32 import javax.management.MBeanOperationInfo ; 33 import javax.management.MBeanParameterInfo ; 34 import javax.management.NotCompliantMBeanException ; 35 import javax.management.Notification ; 36 import javax.management.NotificationBroadcasterSupport ; 37 import javax.management.NotificationEmitter ; 38 import javax.management.NotificationFilter ; 39 import javax.management.NotificationListener ; 40 import javax.management.StandardMBean ; 41 42 import org.objectweb.cjdbc.common.i18n.JmxTranslate; 43 44 50 public abstract class AbstractStandardMBean extends StandardMBean 51 implements 52 NotificationEmitter 53 { 54 57 private transient NotificationBroadcasterSupport broadcaster; 58 59 63 public void addNotificationListener(NotificationListener listener, 64 NotificationFilter filter, Object handback) 65 { 66 broadcaster.addNotificationListener(listener, filter, handback); 67 } 68 69 72 public MBeanNotificationInfo [] getNotificationInfo() 73 { 74 if (broadcaster == null) 76 return new MBeanNotificationInfo [0]; 78 79 return broadcaster.getNotificationInfo(); 80 } 81 82 85 public void removeNotificationListener(NotificationListener listener) 86 throws ListenerNotFoundException 87 { 88 broadcaster.removeNotificationListener(listener); 89 } 90 91 95 public void removeNotificationListener(NotificationListener listener, 96 NotificationFilter filter, Object handback) 97 throws ListenerNotFoundException 98 { 99 broadcaster.removeNotificationListener(listener, filter, handback); 100 } 101 102 107 public void sendNotification(Notification notification) 108 { 109 broadcaster.sendNotification(notification); 110 } 111 112 115 116 124 public AbstractStandardMBean(Class mbeanInterface) 125 throws NotCompliantMBeanException 126 { 127 super(mbeanInterface); 128 broadcaster = new NotificationBroadcasterSupport (); 129 } 130 131 136 public abstract String getAssociatedString(); 137 138 143 protected String getDescription(MBeanInfo info) 144 { 145 return JmxTranslate.get("mbean." + getAssociatedString() + ".description"); 146 } 147 148 151 protected String getDescription(MBeanConstructorInfo ctor) 152 { 153 return JmxTranslate.get("mbean." + getAssociatedString() + ".constructor." 154 + ctor.getSignature().length); 155 } 156 157 161 protected String getParameterName(MBeanConstructorInfo ctor, 162 MBeanParameterInfo param, int sequence) 163 { 164 return JmxTranslate.get("mbean." + getAssociatedString() + ".constructor." 165 + ctor.getSignature().length + ".parameter.name." + sequence); 166 } 167 168 172 protected String getDescription(MBeanConstructorInfo ctor, 173 MBeanParameterInfo param, int sequence) 174 { 175 return JmxTranslate.get("mbean." + getAssociatedString() + ".constructor." 176 + ctor.getSignature().length + ".parameter.description." + sequence); 177 } 178 179 182 protected String getDescription(MBeanAttributeInfo info) 183 { 184 return JmxTranslate.get("mbean." + getAssociatedString() + ".attribute." 185 + info.getName()); 186 } 187 188 191 protected String getDescription(MBeanOperationInfo info) 192 { 193 return JmxTranslate.get("mbean." + getAssociatedString() + "." 194 + info.getName()); 195 } 196 197 201 protected String getParameterName(MBeanOperationInfo op, 202 MBeanParameterInfo param, int sequence) 203 { 204 return JmxTranslate.get("mbean." + getAssociatedString() + "." 205 + op.getName() + ".parameter.name." + sequence); 206 } 207 208 212 protected String getDescription(MBeanOperationInfo op, 213 MBeanParameterInfo param, int sequence) 214 { 215 return JmxTranslate.get("mbean." + getAssociatedString() + "." 216 + op.getName() + ".parameter.description." + sequence); 217 } 218 } | Popular Tags |