Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6440827

StandardEmitter subclasses could be allowed to use "this" as their NotificationEmitter

    Details

    • Type: Enhancement
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 6
    • Fix Version/s: 7
    • Component/s: core-svc
    • Labels:
      None
    • Subcomponent:
    • Resolved In Build:
      b34
    • CPU:
      generic
    • OS:
      generic

      Description

      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.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                emcmanus Eamonn McManus
                Reporter:
                emcmanus Eamonn McManus
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: