00001
00025 package org.objectweb.cjdbc.controller.jmx;
00026
00027
import javax.management.ListenerNotFoundException;
00028
import javax.management.MBeanAttributeInfo;
00029
import javax.management.MBeanConstructorInfo;
00030
import javax.management.MBeanInfo;
00031
import javax.management.MBeanNotificationInfo;
00032
import javax.management.MBeanOperationInfo;
00033
import javax.management.MBeanParameterInfo;
00034
import javax.management.NotCompliantMBeanException;
00035
import javax.management.Notification;
00036
import javax.management.NotificationBroadcasterSupport;
00037
import javax.management.NotificationEmitter;
00038
import javax.management.NotificationFilter;
00039
import javax.management.NotificationListener;
00040
import javax.management.StandardMBean;
00041
00042
import org.objectweb.cjdbc.common.i18n.JmxTranslate;
00043
00050 public abstract class AbstractStandardMBean extends StandardMBean
00051 implements
00052 NotificationEmitter
00053 {
00054
00058 private NotificationBroadcasterSupport
broadcaster;
00059
00064 public void addNotificationListener(NotificationListener listener,
00065 NotificationFilter filter, Object handback)
00066 {
00067
broadcaster.addNotificationListener(listener, filter, handback);
00068 }
00069
00073 public MBeanNotificationInfo[]
getNotificationInfo()
00074 {
00075
00076
if (
broadcaster == null)
00077
00078
return new MBeanNotificationInfo[0];
00079
00080
return broadcaster.getNotificationInfo();
00081 }
00082
00086 public void removeNotificationListener(NotificationListener listener)
00087
throws ListenerNotFoundException
00088 {
00089
broadcaster.removeNotificationListener(listener);
00090 }
00091
00096 public void removeNotificationListener(NotificationListener listener,
00097 NotificationFilter filter, Object handback)
00098
throws ListenerNotFoundException
00099 {
00100
broadcaster.removeNotificationListener(listener, filter, handback);
00101 }
00102
00108 public void sendNotification(Notification notification)
00109 {
00110
broadcaster.sendNotification(notification);
00111 }
00112
00113
00114
00115
00116
00125 public AbstractStandardMBean(Class mbeanInterface)
00126
throws NotCompliantMBeanException
00127 {
00128 super(mbeanInterface);
00129
broadcaster =
new NotificationBroadcasterSupport();
00130 }
00131
00137
public abstract String
getAssociatedString();
00138
00144 protected String
getDescription(MBeanInfo info)
00145 {
00146
return JmxTranslate.get(
"mbean." +
getAssociatedString() +
".description");
00147 }
00148
00152 protected String
getDescription(MBeanConstructorInfo ctor)
00153 {
00154
return JmxTranslate.get(
"mbean." +
getAssociatedString() +
".constructor."
00155 + ctor.getSignature().length);
00156 }
00157
00162 protected String
getParameterName(MBeanConstructorInfo ctor,
00163 MBeanParameterInfo param,
int sequence)
00164 {
00165
return JmxTranslate.get(
"mbean." +
getAssociatedString() +
".constructor."
00166 + ctor.getSignature().length +
".parameter.name." + sequence);
00167 }
00168
00173 protected String
getDescription(MBeanConstructorInfo ctor,
00174 MBeanParameterInfo param,
int sequence)
00175 {
00176
return JmxTranslate.get(
"mbean." +
getAssociatedString() +
".constructor."
00177 + ctor.getSignature().length +
".parameter.description." + sequence);
00178 }
00179
00183 protected String
getDescription(MBeanAttributeInfo info)
00184 {
00185
return JmxTranslate.get(
"mbean." +
getAssociatedString() +
".attribute."
00186 + info.getName());
00187 }
00188
00192 protected String
getDescription(MBeanOperationInfo info)
00193 {
00194
return JmxTranslate.get(
"mbean." +
getAssociatedString() +
"."
00195 + info.getName());
00196 }
00197
00202 protected String
getParameterName(MBeanOperationInfo op,
00203 MBeanParameterInfo param,
int sequence)
00204 {
00205
return JmxTranslate.get(
"mbean." +
getAssociatedString() +
"."
00206 + op.getName() +
".parameter.name." + sequence);
00207 }
00208
00213 protected String
getDescription(MBeanOperationInfo op,
00214 MBeanParameterInfo param,
int sequence)
00215 {
00216
return JmxTranslate.get(
"mbean." +
getAssociatedString() +
"."
00217 + op.getName() +
".parameter.description." + sequence);
00218 }
00219 }