src/java.naming/share/classes/javax/naming/event/NamingEvent.java
author darcy
Wed, 09 Oct 2019 18:23:20 -0700
changeset 58531 9b40d05c9f66
parent 47216 71c04702a3d5
permissions -rw-r--r--
8232076: Suppress warnings on non-serializable non-transient instance fields java.naming Reviewed-by: lancea
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
58531
9b40d05c9f66 8232076: Suppress warnings on non-serializable non-transient instance fields java.naming
darcy
parents: 47216
diff changeset
     2
 * Copyright (c) 1999, 2019, Oracle and/or its affiliates. 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
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
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
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
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.naming.event;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import javax.naming.Binding;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
  * This class represents an event fired by a naming/directory service.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
  *<p>
32029
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
    33
  * The {@code NamingEvent}'s state consists of
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
  * <ul>
32029
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
    35
  * <li>The event source: the {@code EventContext} which fired this event.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
  * <li>The event type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
  * <li>The new binding: information about the object after the change.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
  * <li>The old binding: information about the object before the change.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
  * <li>Change information: information about the change
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
  * that triggered this event; usually service provider-specific or server-specific
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
  * information.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
  * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
  * <p>
32029
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
    44
  * Note that the event source is always the same {@code EventContext}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
  * <em>instance</em>  that the listener has registered with.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
  * Furthermore, the names of the bindings in
32029
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
    47
  * the {@code NamingEvent} are always relative to that instance.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
  * For example, suppose a listener makes the following registration:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
  *<blockquote><pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
  *     NamespaceChangeListener listener = ...;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
  *     src.addNamingListener("x", SUBTREE_SCOPE, listener);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
  *</pre></blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
  * When an object named "x/y" is subsequently deleted, the corresponding
32029
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
    54
  * {@code NamingEvent} ({@code evt}) must contain:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
  *<blockquote><pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
  *     evt.getEventContext() == src
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
  *     evt.getOldBinding().getName().equals("x/y")
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
  *</pre></blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
  *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
  * Care must be taken when multiple threads are accessing the same
32029
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
    61
  * {@code EventContext} concurrently.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
  * See the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
  * <a href=package-summary.html#THREADING>package description</a>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
  * for more information on threading issues.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
  *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
  * @author Rosanna Lee
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
  * @author Scott Seligman
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
  *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
  * @see NamingListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
  * @see EventContext
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
  * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
  */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
public class NamingEvent extends java.util.EventObject {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     * Naming event type for indicating that a new object has been added.
32029
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
    76
     * The value of this constant is {@code 0}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    public static final int OBJECT_ADDED = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     * Naming event type for indicating that an object has been removed.
32029
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
    82
     * The value of this constant is {@code 1}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    public static final int OBJECT_REMOVED = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     * Naming event type for indicating that an object has been renamed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     * Note that some services might fire multiple events for a single
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     * logical rename operation. For example, the rename operation might
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     * be implemented by adding a binding with the new name and removing
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     * the old binding.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     *<p>
32029
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
    93
     * The old/new binding in {@code NamingEvent} may be null if the old
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     * name or new name is outside of the scope for which the listener
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     * has registered.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     *<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     * When an interior node in the namespace tree has been renamed, the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     * topmost node which is part of the listener's scope should used to generate
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     * a rename event. The extent to which this can be supported is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     * provider-specific. For example, a service might generate rename
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     * notifications for all descendants of the changed interior node and the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     * corresponding provider might not be able to prevent those
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     * notifications from being propagated to the listeners.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     *<p>
32029
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
   105
     * The value of this constant is {@code 2}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    public static final int OBJECT_RENAMED = 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     * Naming event type for indicating that an object has been changed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     * The changes might include the object's attributes, or the object itself.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     * Note that some services might fire multiple events for a single
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     * modification. For example, the modification might
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     * be implemented by first removing the old binding and adding
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     * a new binding containing the same name but a different object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     *<p>
32029
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
   117
     * The value of this constant is {@code 3}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    public static final int OBJECT_CHANGED = 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     * Contains information about the change that generated this event.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     */
58531
9b40d05c9f66 8232076: Suppress warnings on non-serializable non-transient instance fields java.naming
darcy
parents: 47216
diff changeset
   125
    @SuppressWarnings("serial") // Not statically typed as Serializable
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    protected Object changeInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     * Contains the type of this event.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     * @see #OBJECT_ADDED
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     * @see #OBJECT_REMOVED
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     * @see #OBJECT_RENAMED
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     * @see #OBJECT_CHANGED
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    protected int type;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
     * Contains information about the object before the change.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    protected Binding oldBinding;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     * Contains information about the object after the change.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
    protected Binding newBinding;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
    /**
32029
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
   151
     * Constructs an instance of {@code NamingEvent}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     *<p>
32029
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
   153
     * The names in {@code newBd} and {@code oldBd} are to be resolved relative
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
   154
     * to the event source {@code source}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     *
32029
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
   156
     * For an {@code OBJECT_ADDED} event type, {@code newBd} must not be null.
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
   157
     * For an {@code OBJECT_REMOVED} event type, {@code oldBd} must not be null.
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
   158
     * For an {@code OBJECT_CHANGED} event type,  {@code newBd} and
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
   159
     * {@code oldBd} must not be null. For  an {@code OBJECT_RENAMED} event type,
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
   160
     * one of {@code newBd} or {@code oldBd} may be null if the new or old
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     * binding is outside of the scope for which the listener has registered.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     * @param source The non-null context that fired this event.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     * @param type The type of the event.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     * @param newBd A possibly null binding before the change. See method description.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
     * @param oldBd A possibly null binding after the change. See method description.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
     * @param changeInfo A possibly null object containing information about the change.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
     * @see #OBJECT_ADDED
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     * @see #OBJECT_REMOVED
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     * @see #OBJECT_RENAMED
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     * @see #OBJECT_CHANGED
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
    public NamingEvent(EventContext source, int type,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
        Binding newBd, Binding oldBd, Object changeInfo) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
        super(source);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
        this.type = type;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
        oldBinding = oldBd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
        newBinding = newBd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
        this.changeInfo = changeInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
     * Returns the type of this event.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     * @return The type of this event.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     * @see #OBJECT_ADDED
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     * @see #OBJECT_REMOVED
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     * @see #OBJECT_RENAMED
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     * @see #OBJECT_CHANGED
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
    public int getType() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
        return type;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
     * Retrieves the event source that fired this event.
32029
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
   196
     * This returns the same object as {@code EventObject.getSource()}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
     *<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
     * If the result of this method is used to access the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
     * event source, for example, to look up the object or get its attributes,
32029
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
   200
     * then it needs to be locked  because implementations of {@code Context}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
     * are not guaranteed to be thread-safe
32029
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
   202
     * (and {@code EventContext} is a subinterface of {@code Context}).
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
     * See the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
     * <a href=package-summary.html#THREADING>package description</a>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
     * for more information on threading issues.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     * @return The non-null context that fired this event.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
    public EventContext getEventContext() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
        return (EventContext)getSource();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
     * Retrieves the binding of the object before the change.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
     *<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     * The binding must be nonnull if the object existed before the change
32029
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
   217
     * relative to the source context ({@code getEventContext()}).
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
   218
     * That is, it must be nonnull for {@code OBJECT_REMOVED} and
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
   219
     * {@code OBJECT_CHANGED}.
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
   220
     * For {@code OBJECT_RENAMED}, it is null if the object before the rename
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
     * is outside of the scope for which the listener has registered interest;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
     * it is nonnull if the object is inside the scope before the rename.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
     *<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
     * The name in the binding is to be resolved relative
32029
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
   225
     * to the event source {@code getEventContext()}.
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
   226
     * The object returned by {@code Binding.getObject()} may be null if
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
     * such information is unavailable.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
     * @return The possibly null binding of the object before the change.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
    public Binding getOldBinding() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
        return oldBinding;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
     * Retrieves the binding of the object after the change.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
     *<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
     * The binding must be nonnull if the object existed after the change
32029
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
   239
     * relative to the source context ({@code getEventContext()}).
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
   240
     * That is, it must be nonnull for {@code OBJECT_ADDED} and
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
   241
     * {@code OBJECT_CHANGED}. For {@code OBJECT_RENAMED},
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
     * it is null if the object after the rename is outside the scope for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
     * which the listener registered interest; it is nonnull if the object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
     * is inside the scope after the rename.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
     *<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
     * The name in the binding is to be resolved relative
32029
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
   247
     * to the event source {@code getEventContext()}.
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
   248
     * The object returned by {@code Binding.getObject()} may be null if
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
     * such information is unavailable.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
     * @return The possibly null binding of the object after the change.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
    public Binding getNewBinding() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
        return newBinding;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
     * Retrieves the change information for this event.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
     * The value of the change information is service-specific. For example,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
     * it could be an ID that identifies the change in a change log on the server.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
     * @return The possibly null change information of this event.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
    public Object getChangeInfo() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
        return changeInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
     * Invokes the appropriate listener method on this event.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
     * The default implementation of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
     * this method handles the following event types:
32029
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
   272
     * {@code OBJECT_ADDED, OBJECT_REMOVED,
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
   273
     * OBJECT_RENAMED, OBJECT_CHANGED}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
     *<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
     * The listener method is executed in the same thread
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
     * as this method.  See the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
     * <a href=package-summary.html#THREADING>package description</a>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
     * for more information on threading issues.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
     * @param listener The nonnull listener.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
    public void dispatch(NamingListener listener) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
        switch (type) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
        case OBJECT_ADDED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
            ((NamespaceChangeListener)listener).objectAdded(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
        case OBJECT_REMOVED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
            ((NamespaceChangeListener)listener).objectRemoved(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
        case OBJECT_RENAMED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
            ((NamespaceChangeListener)listener).objectRenamed(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
        case OBJECT_CHANGED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
            ((ObjectChangeListener)listener).objectChanged(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
    private static final long serialVersionUID = -7126752885365133499L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
}