Please note that this documentation is not final and is subject to change.

Java™ Platform
Standard Ed. 7

DRAFT ea-b76

javax.management
Annotation Type NotificationInfo


@Documented
@Inherited
@Target(value=TYPE)
@Retention(value=RUNTIME)
public @interface NotificationInfo

Specifies the kinds of notification an MBean can emit. In both the following examples, the MBean emits notifications of type "com.example.notifs.create" and of type "com.example.notifs.destroy":

 // Example one: a Standard MBean
 @NotificationInfo(types={"com.example.notifs.create",
                          "com.example.notifs.destroy"})
 public interface CacheMBean {...}

 public class Cache
         extends NotificationBroadcasterSupport implements CacheMBean {
     public Cache() {
         super();   // do not supply any MBeanNotificationInfo[]
     }
     ...
 }
 
 // Example two: an annotated MBean
 @MBean
 @NotificationInfo(types={"com.example.notifs.create",
                          "com.example.notifs.destroy"})
 public class Cache {
     @Resource
     private volatile SendNotification sendNotification;
     ...
 }
 

Each @NotificationInfo produces an MBeanNotificationInfo inside the MBeanInfo of each MBean to which the annotation applies.

If you need to specify different notification classes, or different descriptions for different notification types, then you can group several @NotificationInfo annotations into a containing @NotificationInfos annotation.

The @NotificationInfo and @NotificationInfos annotations are ignored on an MBean that is not a notification source or that implements NotificationBroadcaster and returns a non-empty array from its getNotificationInfo() method.

The NotificationInfo and NotificationInfos annotations can be applied to the MBean implementation class, or to any parent class or interface. These annotations on a class take precedence over annotations on any superclass or superinterface. If an MBean does not have these annotations on its class or any superclass, then superinterfaces are examined. It is an error for more than one superinterface to have these annotations, unless one of them is a descendant of all the others; registering such an erroneous MBean will cause a NotCompliantMBeanException.


Required Element Summary
Modifier and Type Required Element and Description
 String[] types
          The notification types that this MBean can emit.
 
Optional Element Summary
Modifier and Type Optional Element and Description
 Description description
          The description of this notification.
 String[] descriptorFields
          Additional descriptor fields for the derived MBeanNotificationInfo.
 Class<? extends Notification> notificationClass
          The class that emitted notifications will have.
 

Element Detail

types

public abstract String[] types

The notification types that this MBean can emit.

notificationClass

public abstract Class<? extends Notification> notificationClass

The class that emitted notifications will have. It is recommended that this be Notification, or one of its standard subclasses in the JMX API.

Default:
javax.management.Notification.class

description

public abstract Description description

The description of this notification. For example:

 @NotificationInfo(
         types={"com.example.notifs.create"},
         description=@Description("object created"))
 

Default:
@javax.management.Description("")

descriptorFields

public abstract String[] descriptorFields

Additional descriptor fields for the derived MBeanNotificationInfo. They are specified in the same way as for the @DescriptorFields annotation, for example:

 @NotificationInfo(
         types={"com.example.notifs.create"},
         descriptorFields={"severity=6"})
 

Default:
{}

Java™ Platform
Standard Ed. 7

DRAFT ea-b76

Submit a bug or feature

Copyright 2009 Sun Microsystems, Inc. All Rights Reserved. Use is subject to license terms.