00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
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
00044
00045
00046
00047
00048
00049
00050 public abstract class AbstractStandardMBean extends StandardMBean
00051 implements
00052 NotificationEmitter
00053 {
00054
00055
00056
00057 private transient NotificationBroadcasterSupport broadcaster;
00058
00059
00060
00061
00062
00063 public void addNotificationListener(NotificationListener listener,
00064 NotificationFilter filter, Object handback)
00065 {
00066 broadcaster.addNotificationListener(listener, filter, handback);
00067 }
00068
00069
00070
00071
00072 public MBeanNotificationInfo[] getNotificationInfo()
00073 {
00074
00075 if (broadcaster == null)
00076
00077 return new MBeanNotificationInfo[0];
00078
00079 return broadcaster.getNotificationInfo();
00080 }
00081
00082
00083
00084
00085 public void removeNotificationListener(NotificationListener listener)
00086 throws ListenerNotFoundException
00087 {
00088 broadcaster.removeNotificationListener(listener);
00089 }
00090
00091
00092
00093
00094
00095 public void removeNotificationListener(NotificationListener listener,
00096 NotificationFilter filter, Object handback)
00097 throws ListenerNotFoundException
00098 {
00099 broadcaster.removeNotificationListener(listener, filter, handback);
00100 }
00101
00102
00103
00104
00105
00106
00107 public void sendNotification(Notification notification)
00108 {
00109 broadcaster.sendNotification(notification);
00110 }
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124 public AbstractStandardMBean(Class mbeanInterface)
00125 throws NotCompliantMBeanException
00126 {
00127 super(mbeanInterface);
00128 broadcaster = new NotificationBroadcasterSupport();
00129 }
00130
00131
00132
00133
00134
00135
00136 public abstract String getAssociatedString();
00137
00138
00139
00140
00141
00142
00143 protected String getDescription(MBeanInfo info)
00144 {
00145 return JmxTranslate.get("mbean." + getAssociatedString() + ".description");
00146 }
00147
00148
00149
00150
00151 protected String getDescription(MBeanConstructorInfo ctor)
00152 {
00153 return JmxTranslate.get("mbean." + getAssociatedString() + ".constructor."
00154 + ctor.getSignature().length);
00155 }
00156
00157
00158
00159
00160
00161 protected String getParameterName(MBeanConstructorInfo ctor,
00162 MBeanParameterInfo param, int sequence)
00163 {
00164 return JmxTranslate.get("mbean." + getAssociatedString() + ".constructor."
00165 + ctor.getSignature().length + ".parameter.name." + sequence);
00166 }
00167
00168
00169
00170
00171
00172 protected String getDescription(MBeanConstructorInfo ctor,
00173 MBeanParameterInfo param, int sequence)
00174 {
00175 return JmxTranslate.get("mbean." + getAssociatedString() + ".constructor."
00176 + ctor.getSignature().length + ".parameter.description." + sequence);
00177 }
00178
00179
00180
00181
00182 protected String getDescription(MBeanAttributeInfo info)
00183 {
00184 return JmxTranslate.get("mbean." + getAssociatedString() + ".attribute."
00185 + info.getName());
00186 }
00187
00188
00189
00190
00191 protected String getDescription(MBeanOperationInfo info)
00192 {
00193 return JmxTranslate.get("mbean." + getAssociatedString() + "."
00194 + info.getName());
00195 }
00196
00197
00198
00199
00200
00201 protected String getParameterName(MBeanOperationInfo op,
00202 MBeanParameterInfo param, int sequence)
00203 {
00204 return JmxTranslate.get("mbean." + getAssociatedString() + "."
00205 + op.getName() + ".parameter.name." + sequence);
00206 }
00207
00208
00209
00210
00211
00212 protected String getDescription(MBeanOperationInfo op,
00213 MBeanParameterInfo param, int sequence)
00214 {
00215 return JmxTranslate.get("mbean." + getAssociatedString() + "."
00216 + op.getName() + ".parameter.description." + sequence);
00217 }
00218 }