jdk/src/share/classes/javax/management/relation/RelationNotification.java
author xdono
Wed, 02 Jul 2008 12:55:45 -0700
changeset 715 f16baef3a20e
parent 526 61ba2d5ea9da
child 5506 202f599c92aa
permissions -rw-r--r--
6719955: Update copyright year Summary: Update copyright year for files that have been modified in 2008 Reviewed-by: ohair, tbell
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
715
f16baef3a20e 6719955: Update copyright year
xdono
parents: 526
diff changeset
     2
 * Copyright 2000-2008 Sun Microsystems, Inc.  All Rights Reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package javax.management.relation;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import javax.management.Notification;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import javax.management.ObjectName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.io.IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.io.ObjectInputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.io.ObjectOutputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.io.ObjectStreamField;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import java.security.AccessController;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import java.security.PrivilegedAction;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
import java.util.ArrayList;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
import java.util.Collections;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
import java.util.List;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
import com.sun.jmx.mbeanserver.GetPropertyAction;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
import static com.sun.jmx.mbeanserver.Util.cast;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * A notification of a change in the Relation Service.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * A RelationNotification notification is sent when a relation is created via
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * the Relation Service, or an MBean is added as a relation in the Relation
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * Service, or a role is updated in a relation, or a relation is removed from
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * the Relation Service.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * <p>The <b>serialVersionUID</b> of this class is <code>-6871117877523310399L</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
@SuppressWarnings("serial")  // serialVersionUID not constant
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
public class RelationNotification extends Notification {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    // Serialization compatibility stuff:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    // Two serial forms are supported in this class. The selected form depends
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    // on system property "jmx.serial.form":
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    //  - "1.0" for JMX 1.0
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    //  - any other value for JMX 1.1 and higher
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    // Serial version for old serial form
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    private static final long oldSerialVersionUID = -2126464566505527147L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    // Serial version for new serial form
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    private static final long newSerialVersionUID = -6871117877523310399L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    // Serializable fields in old serial form
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    private static final ObjectStreamField[] oldSerialPersistentFields =
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
        new ObjectStreamField("myNewRoleValue", ArrayList.class),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
        new ObjectStreamField("myOldRoleValue", ArrayList.class),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
        new ObjectStreamField("myRelId", String.class),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
        new ObjectStreamField("myRelObjName", ObjectName.class),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
        new ObjectStreamField("myRelTypeName", String.class),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
        new ObjectStreamField("myRoleName", String.class),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
        new ObjectStreamField("myUnregMBeanList", ArrayList.class)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    // Serializable fields in new serial form
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    private static final ObjectStreamField[] newSerialPersistentFields =
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
        new ObjectStreamField("newRoleValue", List.class),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
        new ObjectStreamField("oldRoleValue", List.class),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
        new ObjectStreamField("relationId", String.class),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
        new ObjectStreamField("relationObjName", ObjectName.class),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
        new ObjectStreamField("relationTypeName", String.class),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
        new ObjectStreamField("roleName", String.class),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
        new ObjectStreamField("unregisterMBeanList", List.class)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    // Actual serial version and serial form
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    private static final long serialVersionUID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     * @serialField relationId String Relation identifier of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     * created/removed/updated relation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     * @serialField relationTypeName String Relation type name of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     * created/removed/updated relation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     * @serialField relationObjName ObjectName {@link ObjectName} of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     * the relation MBean of created/removed/updated relation (only if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     * the relation is represented by an MBean)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     * @serialField unregisterMBeanList List List of {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     * ObjectName}s of referenced MBeans to be unregistered due to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     * relation removal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     * @serialField roleName String Name of updated role (only for role update)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     * @serialField oldRoleValue List Old role value ({@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     * ArrayList} of {@link ObjectName}s) (only for role update)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     * @serialField newRoleValue List New role value ({@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     * ArrayList} of {@link ObjectName}s) (only for role update)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    private static final ObjectStreamField[] serialPersistentFields;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    private static boolean compat = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    static {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
            GetPropertyAction act = new GetPropertyAction("jmx.serial.form");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
            String form = AccessController.doPrivileged(act);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
            compat = (form != null && form.equals("1.0"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
        } catch (Exception e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
            // OK : Too bad, no compat with 1.0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
        if (compat) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
            serialPersistentFields = oldSerialPersistentFields;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
            serialVersionUID = oldSerialVersionUID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
            serialPersistentFields = newSerialPersistentFields;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
            serialVersionUID = newSerialVersionUID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
    // END Serialization compatibility stuff
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    // Notification types
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     * Type for the creation of an internal relation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
    public static final String RELATION_BASIC_CREATION = "jmx.relation.creation.basic";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     * Type for the relation MBean added into the Relation Service.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
    public static final String RELATION_MBEAN_CREATION = "jmx.relation.creation.mbean";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     * Type for an update of an internal relation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
    public static final String RELATION_BASIC_UPDATE = "jmx.relation.update.basic";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     * Type for the update of a relation MBean.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
    public static final String RELATION_MBEAN_UPDATE = "jmx.relation.update.mbean";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     * Type for the removal from the Relation Service of an internal relation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
    public static final String RELATION_BASIC_REMOVAL = "jmx.relation.removal.basic";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     * Type for the removal from the Relation Service of a relation MBean.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
    public static final String RELATION_MBEAN_REMOVAL = "jmx.relation.removal.mbean";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
    // Private members
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     * @serial Relation identifier of created/removed/updated relation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    private String relationId = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     * @serial Relation type name of created/removed/updated relation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    private String relationTypeName = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     * @serial {@link ObjectName} of the relation MBean of created/removed/updated relation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     *         (only if the relation is represented by an MBean)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
    private ObjectName relationObjName = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     * @serial List of {@link ObjectName}s of referenced MBeans to be unregistered due to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     *         relation removal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
    private List<ObjectName> unregisterMBeanList = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     * @serial Name of updated role (only for role update)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
    private String roleName = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
     * @serial Old role value ({@link ArrayList} of {@link ObjectName}s) (only for role update)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
    private List<ObjectName> oldRoleValue = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
     * @serial New role value ({@link ArrayList} of {@link ObjectName}s) (only for role update)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
    private List<ObjectName> newRoleValue = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
    // Constructors
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
     * Creates a notification for either a relation creation (RelationSupport
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     * object created internally in the Relation Service, or an MBean added as a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
     * relation) or for a relation removal from the Relation Service.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
     * @param notifType  type of the notification; either:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     * <P>- RELATION_BASIC_CREATION
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
     * <P>- RELATION_MBEAN_CREATION
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
     * <P>- RELATION_BASIC_REMOVAL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
     * <P>- RELATION_MBEAN_REMOVAL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
     * @param sourceObj  source object, sending the notification.  This is either
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
     * an ObjectName or a RelationService object.  In the latter case it must be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
     * the MBean emitting the notification; the MBean Server will rewrite the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
     * source to be the ObjectName under which that MBean is registered.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
     * @param sequence  sequence number to identify the notification
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
     * @param timeStamp  time stamp
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
     * @param message  human-readable message describing the notification
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
     * @param id  relation id identifying the relation in the Relation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
     * Service
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
     * @param typeName  name of the relation type
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
     * @param objectName  ObjectName of the relation object if it is an MBean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
     * (null for relations internally handled by the Relation Service)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
     * @param unregMBeanList  list of ObjectNames of referenced MBeans
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
     * expected to be unregistered due to relation removal (only for removal,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
     * due to CIM qualifiers, can be null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
     * @exception IllegalArgumentException  if:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
     * <P>- no value for the notification type
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
     * <P>- the notification type is not RELATION_BASIC_CREATION,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
     * RELATION_MBEAN_CREATION, RELATION_BASIC_REMOVAL or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
     * RELATION_MBEAN_REMOVAL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
     * <P>- no source object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
     * <P>- the source object is not a Relation Service
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
     * <P>- no relation id
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
     * <P>- no relation type name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
    public RelationNotification(String notifType,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
                                Object sourceObj,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
                                long sequence,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
                                long timeStamp,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
                                String message,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
                                String id,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
                                String typeName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
                                ObjectName objectName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
                                List<ObjectName> unregMBeanList)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
        throws IllegalArgumentException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
        super(notifType, sourceObj, sequence, timeStamp, message);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
        // Can throw IllegalArgumentException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
        initMembers(1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
                    notifType,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
                    sourceObj,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
                    sequence,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
                    timeStamp,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
                    message,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
                    id,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
                    typeName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
                    objectName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
                    unregMBeanList,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
                    null,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
                    null,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
                    null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
     * Creates a notification for a role update in a relation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
     * @param notifType  type of the notification; either:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
     * <P>- RELATION_BASIC_UPDATE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
     * <P>- RELATION_MBEAN_UPDATE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
     * @param sourceObj  source object, sending the notification. This is either
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
     * an ObjectName or a RelationService object.  In the latter case it must be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
     * the MBean emitting the notification; the MBean Server will rewrite the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
     * source to be the ObjectName under which that MBean is registered.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
     * @param sequence  sequence number to identify the notification
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
     * @param timeStamp  time stamp
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
     * @param message  human-readable message describing the notification
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
     * @param id  relation id identifying the relation in the Relation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
     * Service
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
     * @param typeName  name of the relation type
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
     * @param objectName  ObjectName of the relation object if it is an MBean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
     * (null for relations internally handled by the Relation Service)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
     * @param name  name of the updated role
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
     * @param newValue  new role value (List of ObjectName objects)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
     * @param oldValue  old role value (List of ObjectName objects)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
     * @exception IllegalArgumentException  if null parameter
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
    public RelationNotification(String notifType,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
                                Object sourceObj,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
                                long sequence,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
                                long timeStamp,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
                                String message,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
                                String id,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
                                String typeName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
                                ObjectName objectName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
                                String name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
                                List<ObjectName> newValue,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
                                List<ObjectName> oldValue
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
                                )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
            throws IllegalArgumentException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
        super(notifType, sourceObj, sequence, timeStamp, message);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
        // Can throw IllegalArgumentException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
        initMembers(2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
                    notifType,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
                    sourceObj,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
                    sequence,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
                    timeStamp,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
                    message,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
                    id,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
                    typeName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
                    objectName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
                    null,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
                    name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
                    newValue,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
                    oldValue);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
    // Accessors
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
     * Returns the relation identifier of created/removed/updated relation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
     * @return the relation id.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
    public String getRelationId() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
        return relationId;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
     * Returns the relation type name of created/removed/updated relation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
     * @return the relation type name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
    public String getRelationTypeName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
        return relationTypeName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
     * Returns the ObjectName of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
     * created/removed/updated relation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
     * @return the ObjectName if the relation is an MBean, otherwise null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
    public ObjectName getObjectName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
        return relationObjName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
     * Returns the list of ObjectNames of MBeans expected to be unregistered
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
     * due to a relation removal (only for relation removal).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
     * @return a {@link List} of {@link ObjectName}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
    public List<ObjectName> getMBeansToUnregister() {
526
61ba2d5ea9da 6701459: Synchronization bug pattern found in javax.management.relation.RelationService
emcmanus
parents: 2
diff changeset
   372
        List<ObjectName> result;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
        if (unregisterMBeanList != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
            result = new ArrayList<ObjectName>(unregisterMBeanList);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
            result = Collections.emptyList();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
        return result;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
     * Returns name of updated role of updated relation (only for role update).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
     * @return the name of the updated role.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
    public String getRoleName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
        String result = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
        if (roleName != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
            result = roleName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
        return result;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
     * Returns old value of updated role (only for role update).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
     * @return the old value of the updated role.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
    public List<ObjectName> getOldRoleValue() {
526
61ba2d5ea9da 6701459: Synchronization bug pattern found in javax.management.relation.RelationService
emcmanus
parents: 2
diff changeset
   400
        List<ObjectName> result;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
        if (oldRoleValue != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
            result = new ArrayList<ObjectName>(oldRoleValue);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
            result = Collections.emptyList();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
        return result;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
     * Returns new value of updated role (only for role update).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
     * @return the new value of the updated role.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
    public List<ObjectName> getNewRoleValue() {
526
61ba2d5ea9da 6701459: Synchronization bug pattern found in javax.management.relation.RelationService
emcmanus
parents: 2
diff changeset
   415
        List<ObjectName> result;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
        if (newRoleValue != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
            result = new ArrayList<ObjectName>(newRoleValue);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
            result = Collections.emptyList();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
        return result;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
    // Misc
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
    // Initializes members
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
    // -param notifKind  1 for creation/removal, 2 for update
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
    // -param notifType  type of the notification; either:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
    //  - RELATION_BASIC_UPDATE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
    //  - RELATION_MBEAN_UPDATE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
    //  for an update, or:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
    //  - RELATION_BASIC_CREATION
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
    //  - RELATION_MBEAN_CREATION
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
    //  - RELATION_BASIC_REMOVAL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
    //  - RELATION_MBEAN_REMOVAL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
    //  for a creation or removal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
    // -param sourceObj  source object, sending the notification. Will always
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
    //  be a RelationService object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
    // -param sequence  sequence number to identify the notification
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
    // -param timeStamp  time stamp
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
    // -param message  human-readable message describing the notification
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
    // -param id  relation id identifying the relation in the Relation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
    //  Service
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
    // -param typeName  name of the relation type
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
    // -param objectName  ObjectName of the relation object if it is an MBean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
    //  (null for relations internally handled by the Relation Service)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
    // -param unregMBeanList  list of ObjectNames of MBeans expected to be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
    //  removed due to relation removal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
    // -param name  name of the updated role
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
    // -param newValue  new value (List of ObjectName objects)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
    // -param oldValue  old value (List of ObjectName objects)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
    // -exception IllegalArgumentException  if:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
    //  - no value for the notification type
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
    //  - incorrect notification type
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
    //  - no source object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
    //  - the source object is not a Relation Service
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
    //  - no relation id
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
    //  - no relation type name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
    //  - no role name (for role update)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
    //  - no role old value (for role update)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
    //  - no role new value (for role update)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
    private void initMembers(int notifKind,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
                             String notifType,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
                             Object sourceObj,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
                             long sequence,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
                             long timeStamp,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
                             String message,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
                             String id,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
                             String typeName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
                             ObjectName objectName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
                             List<ObjectName> unregMBeanList,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
                             String name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
                             List<ObjectName> newValue,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
                             List<ObjectName> oldValue)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
            throws IllegalArgumentException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
        boolean badInitFlg = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
        if (notifType == null ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
            sourceObj == null ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
            (!(sourceObj instanceof RelationService) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
             !(sourceObj instanceof ObjectName)) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
            id == null ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
            typeName == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
            badInitFlg = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
        if (notifKind == 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
            if ((!(notifType.equals(RelationNotification.RELATION_BASIC_CREATION)))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
                &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
                (!(notifType.equals(RelationNotification.RELATION_MBEAN_CREATION)))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
                &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
                (!(notifType.equals(RelationNotification.RELATION_BASIC_REMOVAL)))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
                &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
                (!(notifType.equals(RelationNotification.RELATION_MBEAN_REMOVAL)))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
                ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
                // Creation/removal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
                badInitFlg = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
        } else if (notifKind == 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
            if (((!(notifType.equals(RelationNotification.RELATION_BASIC_UPDATE)))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
                 &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
                 (!(notifType.equals(RelationNotification.RELATION_MBEAN_UPDATE))))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
                || name == null ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
                oldValue == null ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
                newValue == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
                // Role update
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
                badInitFlg = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
        if (badInitFlg) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
            String excMsg = "Invalid parameter.";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
            throw new IllegalArgumentException(excMsg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
        relationId = id;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
        relationTypeName = typeName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
        relationObjName = objectName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
        if (unregMBeanList != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
            unregisterMBeanList = new ArrayList<ObjectName>(unregMBeanList);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
        if (name != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
            roleName = name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
        if (oldValue != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
            oldRoleValue = new ArrayList<ObjectName>(oldValue);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
        if (newValue != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
            newRoleValue = new ArrayList<ObjectName>(newValue);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
     * Deserializes a {@link RelationNotification} from an {@link ObjectInputStream}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
    private void readObject(ObjectInputStream in)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
            throws IOException, ClassNotFoundException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
      if (compat)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
      {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
        // Read an object serialized in the old serial form
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
        ObjectInputStream.GetField fields = in.readFields();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
        newRoleValue = cast(fields.get("myNewRoleValue", null));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
        if (fields.defaulted("myNewRoleValue"))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
          throw new NullPointerException("newRoleValue");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
        oldRoleValue = cast(fields.get("myOldRoleValue", null));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
        if (fields.defaulted("myOldRoleValue"))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
          throw new NullPointerException("oldRoleValue");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
        relationId = (String) fields.get("myRelId", null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
        if (fields.defaulted("myRelId"))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
          throw new NullPointerException("relationId");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
        relationObjName = (ObjectName) fields.get("myRelObjName", null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
        if (fields.defaulted("myRelObjName"))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
          throw new NullPointerException("relationObjName");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
        relationTypeName = (String) fields.get("myRelTypeName", null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
        if (fields.defaulted("myRelTypeName"))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
          throw new NullPointerException("relationTypeName");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
        roleName = (String) fields.get("myRoleName", null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
        if (fields.defaulted("myRoleName"))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
          throw new NullPointerException("roleName");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
        unregisterMBeanList = cast(fields.get("myUnregMBeanList", null));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
        if (fields.defaulted("myUnregMBeanList"))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
          throw new NullPointerException("unregisterMBeanList");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
      else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
      {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
        // Read an object serialized in the new serial form
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
        in.defaultReadObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
     * Serializes a {@link RelationNotification} to an {@link ObjectOutputStream}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
    private void writeObject(ObjectOutputStream out)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
            throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
      if (compat)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
      {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
        // Serializes this instance in the old serial form
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
        ObjectOutputStream.PutField fields = out.putFields();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
        fields.put("myNewRoleValue", newRoleValue);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
        fields.put("myOldRoleValue", oldRoleValue);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
        fields.put("myRelId", relationId);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
        fields.put("myRelObjName", relationObjName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
        fields.put("myRelTypeName", relationTypeName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
        fields.put("myRoleName",roleName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
        fields.put("myUnregMBeanList", unregisterMBeanList);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
        out.writeFields();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
      else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
      {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
        // Serializes this instance in the new serial form
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
        out.defaultWriteObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
}