FileDocCategorySizeDatePackage
RelationNotification.javaAPI DocJava SE 6 API19246Tue Jun 10 00:26:16 BST 2008javax.management.relation

RelationNotification

public class RelationNotification extends Notification
A notification of a change in the Relation Service. A RelationNotification notification is sent when a relation is created via the Relation Service, or an MBean is added as a relation in the Relation Service, or a role is updated in a relation, or a relation is removed from the Relation Service.

The serialVersionUID of this class is -6871117877523310399L.

since
1.5

Fields Summary
private static final long
oldSerialVersionUID
private static final long
newSerialVersionUID
private static final ObjectStreamField[]
oldSerialPersistentFields
private static final ObjectStreamField[]
newSerialPersistentFields
private static final long
serialVersionUID
private static final ObjectStreamField[]
serialPersistentFields
private static boolean
compat
public static final String
RELATION_BASIC_CREATION
Type for the creation of an internal relation.
public static final String
RELATION_MBEAN_CREATION
Type for the relation MBean added into the Relation Service.
public static final String
RELATION_BASIC_UPDATE
Type for an update of an internal relation.
public static final String
RELATION_MBEAN_UPDATE
Type for the update of a relation MBean.
public static final String
RELATION_BASIC_REMOVAL
Type for the removal from the Relation Service of an internal relation.
public static final String
RELATION_MBEAN_REMOVAL
Type for the removal from the Relation Service of a relation MBean.
private String
relationId
private String
relationTypeName
private ObjectName
relationObjName
private List
unregisterMBeanList
private String
roleName
private List
oldRoleValue
private List
newRoleValue
Constructors Summary
public RelationNotification(String notifType, Object sourceObj, long sequence, long timeStamp, String message, String id, String typeName, ObjectName objectName, List unregMBeanList)
Creates a notification for either a relation creation (RelationSupport object created internally in the Relation Service, or an MBean added as a relation) or for a relation removal from the Relation Service.

param
notifType type of the notification; either:

- RELATION_BASIC_CREATION

- RELATION_MBEAN_CREATION

- RELATION_BASIC_REMOVAL

- RELATION_MBEAN_REMOVAL

param
sourceObj source object, sending the notification. This is either an ObjectName or a RelationService object. In the latter case it must be the MBean emitting the notification; the MBean Server will rewrite the source to be the ObjectName under which that MBean is registered.
param
sequence sequence number to identify the notification
param
timeStamp time stamp
param
message human-readable message describing the notification
param
id relation id identifying the relation in the Relation Service
param
typeName name of the relation type
param
objectName ObjectName of the relation object if it is an MBean (null for relations internally handled by the Relation Service)
param
unregMBeanList list of ObjectNames of referenced MBeans expected to be unregistered due to relation removal (only for removal, due to CIM qualifiers, can be null)
exception
IllegalArgumentException if:

- no value for the notification type

- the notification type is not RELATION_BASIC_CREATION, RELATION_MBEAN_CREATION, RELATION_BASIC_REMOVAL or RELATION_MBEAN_REMOVAL

- no source object

- the source object is not a Relation Service

- no relation id

- no relation type name


    //
    // Constructors
    //

                                                                                                                                                                                                                                                
      
				 
				 
				 
				 
				 
				 
				 
				 
	  

	super(notifType, sourceObj, sequence, timeStamp, message);

	// Can throw IllegalArgumentException
	initMembers(1,
		    notifType,
		    sourceObj,
		    sequence,
		    timeStamp,
		    message,
		    id,
		    typeName,
		    objectName,
		    unregMBeanList,
		    null,
		    null,
		    null);
	return;
    
public RelationNotification(String notifType, Object sourceObj, long sequence, long timeStamp, String message, String id, String typeName, ObjectName objectName, String name, List newValue, List oldValue)
Creates a notification for a role update in a relation.

param
notifType type of the notification; either:

- RELATION_BASIC_UPDATE

- RELATION_MBEAN_UPDATE

param
sourceObj source object, sending the notification. This is either an ObjectName or a RelationService object. In the latter case it must be the MBean emitting the notification; the MBean Server will rewrite the source to be the ObjectName under which that MBean is registered.
param
sequence sequence number to identify the notification
param
timeStamp time stamp
param
message human-readable message describing the notification
param
id relation id identifying the relation in the Relation Service
param
typeName name of the relation type
param
objectName ObjectName of the relation object if it is an MBean (null for relations internally handled by the Relation Service)
param
name name of the updated role
param
newValue new role value (List of ObjectName objects)
param
oldValue old role value (List of ObjectName objects)
exception
IllegalArgumentException if null parameter


	super(notifType, sourceObj, sequence, timeStamp, message);

	// Can throw IllegalArgumentException
	initMembers(2,
		    notifType,
		    sourceObj,
		    sequence,
		    timeStamp,
		    message,
		    id,
		    typeName,
		    objectName,
		    null,
		    name,
		    newValue,
		    oldValue);
	return;
    
Methods Summary
public java.util.ListgetMBeansToUnregister()
Returns the list of ObjectNames of MBeans expected to be unregistered due to a relation removal (only for relation removal).

return
a {@link List} of {@link ObjectName}.

	List<ObjectName> result = null;
	if (unregisterMBeanList != null) {
	    result = new ArrayList<ObjectName>(unregisterMBeanList);
	} else {
	    result = Collections.emptyList();
	}
	return result;
    
public java.util.ListgetNewRoleValue()
Returns new value of updated role (only for role update).

return
the new value of the updated role.

	List<ObjectName> result = null;
	if (newRoleValue != null) {
	    result = new ArrayList<ObjectName>(newRoleValue);
	} else {
	    result = Collections.emptyList();
	}
	return result;
    
public javax.management.ObjectNamegetObjectName()
Returns the ObjectName of the created/removed/updated relation.

return
the ObjectName if the relation is an MBean, otherwise null.

	return relationObjName;
    
public java.util.ListgetOldRoleValue()
Returns old value of updated role (only for role update).

return
the old value of the updated role.

	List<ObjectName> result = null;
	if (oldRoleValue != null) {
	    result = new ArrayList<ObjectName>(oldRoleValue);
	} else {
	    result = Collections.emptyList();
	}
	return result;
    
public java.lang.StringgetRelationId()
Returns the relation identifier of created/removed/updated relation.

return
the relation id.

	return relationId;
    
public java.lang.StringgetRelationTypeName()
Returns the relation type name of created/removed/updated relation.

return
the relation type name.

	return relationTypeName;
    
public java.lang.StringgetRoleName()
Returns name of updated role of updated relation (only for role update).

return
the name of the updated role.

	String result = null;
	if (roleName != null) {
	    result = roleName;
	}
	return result;
    
private voidinitMembers(int notifKind, java.lang.String notifType, java.lang.Object sourceObj, long sequence, long timeStamp, java.lang.String message, java.lang.String id, java.lang.String typeName, javax.management.ObjectName objectName, java.util.List unregMBeanList, java.lang.String name, java.util.List newValue, java.util.List oldValue)


	boolean badInitFlg = false;

	if (notifType == null ||	  
	    sourceObj == null ||
	    (!(sourceObj instanceof RelationService) &&
             !(sourceObj instanceof ObjectName)) ||
	    id == null ||
	    typeName == null) {

	    badInitFlg = true;
	}

	if (notifKind == 1) {

	    if ((!(notifType.equals(RelationNotification.RELATION_BASIC_CREATION)))
		&&
		(!(notifType.equals(RelationNotification.RELATION_MBEAN_CREATION)))
		&&
		(!(notifType.equals(RelationNotification.RELATION_BASIC_REMOVAL)))
		&&
		(!(notifType.equals(RelationNotification.RELATION_MBEAN_REMOVAL)))
		) {

		// Creation/removal
		badInitFlg = true;
	    }

	} else if (notifKind == 2) {

	    if (((!(notifType.equals(RelationNotification.RELATION_BASIC_UPDATE)))
		 &&
		 (!(notifType.equals(RelationNotification.RELATION_MBEAN_UPDATE))))
		|| name == null ||
		oldValue == null ||
		newValue == null) {

		// Role update
		badInitFlg = true;
	    }
	}

	if (badInitFlg) {
	    String excMsg = "Invalid parameter.";
	    throw new IllegalArgumentException(excMsg);
	}

	relationId = id;
	relationTypeName = typeName;
	relationObjName = objectName;
	if (unregMBeanList != null) {
	    unregisterMBeanList = new ArrayList<ObjectName>(unregMBeanList);
	}
	if (name != null) {
	    roleName = name;
	}
	if (oldValue != null) {
	    oldRoleValue = new ArrayList<ObjectName>(oldValue);
	}
	if (newValue != null) {
	    newRoleValue = new ArrayList<ObjectName>(newValue);
	}
	return;
    
private voidreadObject(java.io.ObjectInputStream in)
Deserializes a {@link RelationNotification} from an {@link ObjectInputStream}.

      if (compat)
      {
        // Read an object serialized in the old serial form
        //
        ObjectInputStream.GetField fields = in.readFields();
	newRoleValue = (List<ObjectName>) fields.get("myNewRoleValue", null);
	if (fields.defaulted("myNewRoleValue"))
        {
          throw new NullPointerException("newRoleValue");
        }
	oldRoleValue = (List<ObjectName>) fields.get("myOldRoleValue", null);
	if (fields.defaulted("myOldRoleValue"))
        {
          throw new NullPointerException("oldRoleValue");
        }
	relationId = (String) fields.get("myRelId", null);
	if (fields.defaulted("myRelId"))
        {
          throw new NullPointerException("relationId");
        }
	relationObjName = (ObjectName) fields.get("myRelObjName", null);
	if (fields.defaulted("myRelObjName"))
        {
          throw new NullPointerException("relationObjName");
        }
	relationTypeName = (String) fields.get("myRelTypeName", null);
	if (fields.defaulted("myRelTypeName"))
        {
          throw new NullPointerException("relationTypeName");
        }
	roleName = (String) fields.get("myRoleName", null);
	if (fields.defaulted("myRoleName"))
        {
          throw new NullPointerException("roleName");
        }
	unregisterMBeanList =
	    (List<ObjectName>) fields.get("myUnregMBeanList", null);
	if (fields.defaulted("myUnregMBeanList"))
        {
          throw new NullPointerException("unregisterMBeanList");
        }
      }
      else
      {
        // Read an object serialized in the new serial form
        //
        in.defaultReadObject();
      }
    
private voidwriteObject(java.io.ObjectOutputStream out)
Serializes a {@link RelationNotification} to an {@link ObjectOutputStream}.

      if (compat)
      {
        // Serializes this instance in the old serial form
        //
        ObjectOutputStream.PutField fields = out.putFields();
	fields.put("myNewRoleValue", newRoleValue);
	fields.put("myOldRoleValue", oldRoleValue);
	fields.put("myRelId", relationId);
	fields.put("myRelObjName", relationObjName);
	fields.put("myRelTypeName", relationTypeName);
	fields.put("myRoleName",roleName);
	fields.put("myUnregMBeanList", unregisterMBeanList);
	out.writeFields();
      }
      else
      {
        // Serializes this instance in the new serial form
        //
        out.defaultWriteObject();
      }