jdk/src/java.naming/share/classes/javax/naming/event/NamingEvent.java
author igerasim
Tue, 09 Sep 2014 19:02:36 +0400
changeset 26458 d6a5aed9204b
parent 25859 3317bb8137f4
child 32029 a5538163e144
permissions -rw-r--r--
7010989: Duplicate closure of file descriptors leads to unexpected and incorrect closure of sockets Reviewed-by: chegar
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     2
 * Copyright (c) 1999, 2000, 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>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
  * The <tt>NamingEvent</tt>'s state consists of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
  * <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
  * <li>The event source: the <tt>EventContext</tt> which fired this event.
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>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
  * Note that the event source is always the same <tt>EventContext</tt>
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
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
  * the <tt>NamingEvent</tt> are always relative to that instance.
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
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
  * <tt>NamingEvent</tt> (<tt>evt</tt>) must contain:
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
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
  * <tt>EventContext</tt> concurrently.
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.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     * The value of this constant is <tt>0</tt>.
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.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     * The value of this constant is <tt>1</tt>.
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>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     * The old/new binding in <tt>NamingEvent</tt> may be null if the old
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>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     * The value of this constant is <tt>2</tt>.
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>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     * The value of this constant is <tt>3</tt>.
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
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    protected Object changeInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     * Contains the type of this event.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     * @see #OBJECT_ADDED
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     * @see #OBJECT_REMOVED
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     * @see #OBJECT_RENAMED
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     * @see #OBJECT_CHANGED
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
    protected int type;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     * Contains information about the object before the change.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
    protected Binding oldBinding;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     * Contains information about the object after the change.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
    protected Binding newBinding;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     * Constructs an instance of <tt>NamingEvent</tt>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     *<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     * The names in <tt>newBd</tt> and <tt>oldBd</tt> are to be resolved relative
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     * to the event source <tt>source</tt>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     * For an <tt>OBJECT_ADDED</tt> event type, <tt>newBd</tt> must not be null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     * For an <tt>OBJECT_REMOVED</tt> event type, <tt>oldBd</tt> must not be null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     * For an <tt>OBJECT_CHANGED</tt> event type,  <tt>newBd</tt> and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     * <tt>oldBd</tt> must not be null. For  an <tt>OBJECT_RENAMED</tt> event type,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     * one of <tt>newBd</tt> or <tt>oldBd</tt> may be null if the new or old
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     * binding is outside of the scope for which the listener has registered.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     * @param source The non-null context that fired this event.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     * @param type The type of the event.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     * @param newBd A possibly null binding before the change. See method description.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     * @param oldBd A possibly null binding after the change. See method description.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
     * @param changeInfo A possibly null object containing information about the change.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
     * @see #OBJECT_ADDED
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
     * @see #OBJECT_REMOVED
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     * @see #OBJECT_RENAMED
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     * @see #OBJECT_CHANGED
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    public NamingEvent(EventContext source, int type,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
        Binding newBd, Binding oldBd, Object changeInfo) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
        super(source);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
        this.type = type;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
        oldBinding = oldBd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
        newBinding = newBd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
        this.changeInfo = changeInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     * Returns the type of this event.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
     * @return The type of this event.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     * @see #OBJECT_ADDED
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     * @see #OBJECT_REMOVED
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     * @see #OBJECT_RENAMED
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     * @see #OBJECT_CHANGED
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
    public int getType() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
        return type;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     * Retrieves the event source that fired this event.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
     * This returns the same object as <tt>EventObject.getSource()</tt>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
     *<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
     * If the result of this method is used to access the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
     * event source, for example, to look up the object or get its attributes,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
     * then it needs to be locked  because implementations of <tt>Context</tt>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
     * are not guaranteed to be thread-safe
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
     * (and <tt>EventContext</tt> is a subinterface of <tt>Context</tt>).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
     * See the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
     * <a href=package-summary.html#THREADING>package description</a>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
     * for more information on threading issues.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
     * @return The non-null context that fired this event.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
    public EventContext getEventContext() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
        return (EventContext)getSource();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
     * Retrieves the binding of the object before the change.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
     *<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
     * The binding must be nonnull if the object existed before the change
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     * relative to the source context (<tt>getEventContext()</tt>).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
     * That is, it must be nonnull for <tt>OBJECT_REMOVED</tt> and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
     * <tt>OBJECT_CHANGED</tt>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
     * For <tt>OBJECT_RENAMED</tt>, it is null if the object before the rename
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
     * is outside of the scope for which the listener has registered interest;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
     * it is nonnull if the object is inside the scope before the rename.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
     *<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
     * The name in the binding is to be resolved relative
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
     * to the event source <tt>getEventContext()</tt>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
     * The object returned by <tt>Binding.getObject()</tt> may be null if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
     * such information is unavailable.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
     * @return The possibly null binding of the object before the change.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
    public Binding getOldBinding() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
        return oldBinding;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
     * Retrieves the binding of the object after the change.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
     *<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
     * The binding must be nonnull if the object existed after the change
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
     * relative to the source context (<tt>getEventContext()</tt>).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
     * That is, it must be nonnull for <tt>OBJECT_ADDED</tt> and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
     * <tt>OBJECT_CHANGED</tt>. For <tt>OBJECT_RENAMED</tt>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
     * it is null if the object after the rename is outside the scope for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
     * which the listener registered interest; it is nonnull if the object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
     * is inside the scope after the rename.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
     *<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
     * The name in the binding is to be resolved relative
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
     * to the event source <tt>getEventContext()</tt>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
     * The object returned by <tt>Binding.getObject()</tt> may be null if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
     * such information is unavailable.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
     * @return The possibly null binding of the object after the change.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
    public Binding getNewBinding() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
        return newBinding;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
     * Retrieves the change information for this event.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
     * The value of the change information is service-specific. For example,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
     * it could be an ID that identifies the change in a change log on the server.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
     * @return The possibly null change information of this event.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
    public Object getChangeInfo() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
        return changeInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
     * Invokes the appropriate listener method on this event.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
     * The default implementation of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
     * this method handles the following event types:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
     * <tt>OBJECT_ADDED</TT>, <TT>OBJECT_REMOVED</TT>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
     * <TT>OBJECT_RENAMED</TT>, <TT>OBJECT_CHANGED</TT>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
     *<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
     * The listener method is executed in the same thread
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
     * as this method.  See the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
     * <a href=package-summary.html#THREADING>package description</a>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
     * for more information on threading issues.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
     * @param listener The nonnull listener.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
    public void dispatch(NamingListener listener) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
        switch (type) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
        case OBJECT_ADDED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
            ((NamespaceChangeListener)listener).objectAdded(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
        case OBJECT_REMOVED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
            ((NamespaceChangeListener)listener).objectRemoved(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
        case OBJECT_RENAMED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
            ((NamespaceChangeListener)listener).objectRenamed(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
        case OBJECT_CHANGED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
            ((ObjectChangeListener)listener).objectChanged(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
    private static final long serialVersionUID = -7126752885365133499L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
}