Creating a subclass of StandardEmitterMBean could be simplified by removing the necessity to create a NotificationEmitter instance. Currently you have to do something like this:
public class MyEmitter extends StandardEmitterMBean implements MyMBean {
public MyEmitter() {
super(MyMBean.class, makeNotificationEmitter());
}
private static final MBeanNotificationInfo notificationInfo =
new MBeanNotificationInfo(new String[] {"a.b", "c.d"},
Notification.class.getName(),
"Description");
private static NotificationEmitter makeNotificationEmitter() {
return new NotificationBroadcasterSupport(notificationInfo);
}
}
It would be nice to be able to do this instead:
public class MyEmitter extends StandardEmitterMBean implements MyMBean {
public MyEmitter() {
super(this, MyMBean.class);
}
private static final MBeanNotificationInfo notificationInfo =
new MBeanNotificationInfo(new String[] {"a.b", "c.d"},
Notification.class.getName(),
"Description");
@Override
public MBeanNotificationInfo[] getNotificationInfo() {
return notificationInfo;
}
}
The current need to construct the NotificationEmitter within the superconstructor call is not obvious, and this simpler pattern would be more so.
This change does not imply a change to the API signature but it does imply changing the implementation. Currently the replacement code above will lead to an infinite recursion.