feat(jdk8): move files to new folder to avoid resources compiled.

This commit is contained in:
2025-09-07 15:25:52 +08:00
parent 3f0047bf6f
commit 8c35cfb1c0
17415 changed files with 217 additions and 213 deletions

View File

@@ -0,0 +1,249 @@
/*
* Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.naming.event;
import javax.naming.Name;
import javax.naming.Context;
import javax.naming.NamingException;
/**
* Contains methods for registering/deregistering listeners to be notified of
* events fired when objects named in a context changes.
*
*<h1>Target</h1>
* The name parameter in the <tt>addNamingListener()</tt> methods is referred
* to as the <em>target</em>. The target, along with the scope, identify
* the object(s) that the listener is interested in.
* It is possible to register interest in a target that does not exist, but
* there might be limitations in the extent to which this can be
* supported by the service provider and underlying protocol/service.
*<p>
* If a service only supports registration for existing
* targets, an attempt to register for a nonexistent target
* results in a <tt>NameNotFoundException</tt> being thrown as early as possible,
* preferably at the time <tt>addNamingListener()</tt> is called, or if that is
* not possible, the listener will receive the exception through the
* <tt>NamingExceptionEvent</tt>.
*<p>
* Also, for service providers that only support registration for existing
* targets, when the target that a listener has registered for is
* subsequently removed from the namespace, the listener is notified
* via a <tt>NamingExceptionEvent</tt> (containing a
*<tt>NameNotFoundException</tt>).
*<p>
* An application can use the method <tt>targetMustExist()</tt> to check
* whether a <tt>EventContext</tt> supports registration
* of nonexistent targets.
*
*<h1>Event Source</h1>
* The <tt>EventContext</tt> instance on which you invoke the
* registration methods is the <em>event source</em> of the events that are
* (potentially) generated.
* The source is <em>not necessarily</em> the object named by the target.
* Only when the target is the empty name is the object named by the target
* the source.
* In other words, the target,
* along with the scope parameter, are used to identify
* the object(s) that the listener is interested in, but the event source
* is the <tt>EventContext</tt> instance with which the listener
* has registered.
*<p>
* For example, suppose a listener makes the following registration:
*<blockquote><pre>
* NamespaceChangeListener listener = ...;
* src.addNamingListener("x", SUBTREE_SCOPE, listener);
*</pre></blockquote>
* When an object named "x/y" is subsequently deleted, the corresponding
* <tt>NamingEvent</tt> (<tt>evt</tt>) must contain:
*<blockquote><pre>
* evt.getEventContext() == src
* evt.getOldBinding().getName().equals("x/y")
*</pre></blockquote>
*<p>
* Furthermore, listener registration/deregistration is with
* the <tt>EventContext</tt>
* <em>instance</em>, and not with the corresponding object in the namespace.
* If the program intends at some point to remove a listener, then it needs to
* keep a reference to the <tt>EventContext</tt> instance on
* which it invoked <tt>addNamingListener()</tt> (just as
* it needs to keep a reference to the listener in order to remove it
* later). It cannot expect to do a <tt>lookup()</tt> and get another instance of
* a <tt>EventContext</tt> on which to perform the deregistration.
*<h1>Lifetime of Registration</h1>
* A registered listener becomes deregistered when:
*<ul>
*<li>It is removed using <tt>removeNamingListener()</tt>.
*<li>An exception is thrown while collecting information about the events.
* That is, when the listener receives a <tt>NamingExceptionEvent</tt>.
*<li><tt>Context.close()</tt> is invoked on the <tt>EventContext</tt>
* instance with which it has registered.
</ul>
* Until that point, a <tt>EventContext</tt> instance that has outstanding
* listeners will continue to exist and be maintained by the service provider.
*
*<h1>Listener Implementations</h1>
* The registration/deregistration methods accept an instance of
* <tt>NamingListener</tt>. There are subinterfaces of <tt>NamingListener</tt>
* for different of event types of <tt>NamingEvent</tt>.
* For example, the <tt>ObjectChangeListener</tt>
* interface is for the <tt>NamingEvent.OBJECT_CHANGED</tt> event type.
* To register interest in multiple event types, the listener implementation
* should implement multiple <tt>NamingListener</tt> subinterfaces and use a
* single invocation of <tt>addNamingListener()</tt>.
* In addition to reducing the number of method calls and possibly the code size
* of the listeners, this allows some service providers to optimize the
* registration.
*
*<h1>Threading Issues</h1>
*
* Like <tt>Context</tt> instances in general, instances of
* <tt>EventContext</tt> are not guaranteed to be thread-safe.
* Care must be taken when multiple threads are accessing the same
* <tt>EventContext</tt> concurrently.
* See the
* <a href=package-summary.html#THREADING>package description</a>
* for more information on threading issues.
*
* @author Rosanna Lee
* @author Scott Seligman
* @since 1.3
*/
public interface EventContext extends Context {
/**
* Constant for expressing interest in events concerning the object named
* by the target.
*<p>
* The value of this constant is <tt>0</tt>.
*/
public final static int OBJECT_SCOPE = 0;
/**
* Constant for expressing interest in events concerning objects
* in the context named by the target,
* excluding the context named by the target.
*<p>
* The value of this constant is <tt>1</tt>.
*/
public final static int ONELEVEL_SCOPE = 1;
/**
* Constant for expressing interest in events concerning objects
* in the subtree of the object named by the target, including the object
* named by the target.
*<p>
* The value of this constant is <tt>2</tt>.
*/
public final static int SUBTREE_SCOPE = 2;
/**
* Adds a listener for receiving naming events fired
* when the object(s) identified by a target and scope changes.
*
* The event source of those events is this context. See the
* class description for a discussion on event source and target.
* See the descriptions of the constants <tt>OBJECT_SCOPE</tt>,
* <tt>ONELEVEL_SCOPE</tt>, and <tt>SUBTREE_SCOPE</tt> to see how
* <tt>scope</tt> affects the registration.
*<p>
* <tt>target</tt> needs to name a context only when <tt>scope</tt> is
* <tt>ONELEVEL_SCOPE</tt>.
* <tt>target</tt> may name a non-context if <tt>scope</tt> is either
* <tt>OBJECT_SCOPE</tt> or <tt>SUBTREE_SCOPE</tt>. Using
* <tt>SUBTREE_SCOPE</tt> for a non-context might be useful,
* for example, if the caller does not know in advance whether <tt>target</tt>
* is a context and just wants to register interest in the (possibly
* degenerate subtree) rooted at <tt>target</tt>.
*<p>
* When the listener is notified of an event, the listener may
* in invoked in a thread other than the one in which
* <tt>addNamingListener()</tt> is executed.
* Care must be taken when multiple threads are accessing the same
* <tt>EventContext</tt> concurrently.
* See the
* <a href=package-summary.html#THREADING>package description</a>
* for more information on threading issues.
*
* @param target A nonnull name to be resolved relative to this context.
* @param scope One of <tt>OBJECT_SCOPE</tt>, <tt>ONELEVEL_SCOPE</tt>, or
* <tt>SUBTREE_SCOPE</tt>.
* @param l The nonnull listener.
* @exception NamingException If a problem was encountered while
* adding the listener.
* @see #removeNamingListener
*/
void addNamingListener(Name target, int scope, NamingListener l)
throws NamingException;
/**
* Adds a listener for receiving naming events fired
* when the object named by the string target name and scope changes.
*
* See the overload that accepts a <tt>Name</tt> for details.
*
* @param target The nonnull string name of the object resolved relative
* to this context.
* @param scope One of <tt>OBJECT_SCOPE</tt>, <tt>ONELEVEL_SCOPE</tt>, or
* <tt>SUBTREE_SCOPE</tt>.
* @param l The nonnull listener.
* @exception NamingException If a problem was encountered while
* adding the listener.
* @see #removeNamingListener
*/
void addNamingListener(String target, int scope, NamingListener l)
throws NamingException;
/**
* Removes a listener from receiving naming events fired
* by this <tt>EventContext</tt>.
* The listener may have registered more than once with this
* <tt>EventContext</tt>, perhaps with different target/scope arguments.
* After this method is invoked, the listener will no longer
* receive events with this <tt>EventContext</tt> instance
* as the event source (except for those events already in the process of
* being dispatched).
* If the listener was not, or is no longer, registered with
* this <tt>EventContext</tt> instance, this method does not do anything.
*
* @param l The nonnull listener.
* @exception NamingException If a problem was encountered while
* removing the listener.
* @see #addNamingListener
*/
void removeNamingListener(NamingListener l) throws NamingException;
/**
* Determines whether a listener can register interest in a target
* that does not exist.
*
* @return true if the target must exist; false if the target need not exist.
* @exception NamingException If the context's behavior in this regard cannot
* be determined.
*/
boolean targetMustExist() throws NamingException;
}

View File

@@ -0,0 +1,159 @@
/*
* Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.naming.event;
import javax.naming.Name;
import javax.naming.NamingException;
import javax.naming.directory.DirContext;
import javax.naming.directory.SearchControls;
/**
* Contains methods for registering listeners to be notified
* of events fired when objects named in a directory context changes.
*<p>
* The methods in this interface support identification of objects by
* <A HREF="http://www.ietf.org/rfc/rfc2254.txt">RFC 2254</a>
* search filters.
*
*<P>Using the search filter, it is possible to register interest in objects
* that do not exist at the time of registration but later come into existence and
* satisfy the filter. However, there might be limitations in the extent
* to which this can be supported by the service provider and underlying
* protocol/service. If the caller submits a filter that cannot be
* supported in this way, <tt>addNamingListener()</tt> throws an
* <tt>InvalidSearchFilterException</tt>.
*<p>
* See <tt>EventContext</tt> for a description of event source
* and target, and information about listener registration/deregistration
* that are also applicable to methods in this interface.
* See the
* <a href=package-summary.html#THREADING>package description</a>
* for information on threading issues.
*<p>
* A <tt>SearchControls</tt> or array object
* passed as a parameter to any method is owned by the caller.
* The service provider will not modify the object or keep a reference to it.
*
* @author Rosanna Lee
* @author Scott Seligman
* @since 1.3
*/
public interface EventDirContext extends EventContext, DirContext {
/**
* Adds a listener for receiving naming events fired
* when objects identified by the search filter <tt>filter</tt> at
* the object named by target are modified.
* <p>
* The scope, returningObj flag, and returningAttributes flag from
* the search controls <tt>ctls</tt> are used to control the selection
* of objects that the listener is interested in,
* and determines what information is returned in the eventual
* <tt>NamingEvent</tt> object. Note that the requested
* information to be returned might not be present in the <tt>NamingEvent</tt>
* object if they are unavailable or could not be obtained by the
* service provider or service.
*
* @param target The nonnull name of the object resolved relative to this context.
* @param filter The nonnull string filter (see RFC2254).
* @param ctls The possibly null search controls. If null, the default
* search controls are used.
* @param l The nonnull listener.
* @exception NamingException If a problem was encountered while
* adding the listener.
* @see EventContext#removeNamingListener
* @see javax.naming.directory.DirContext#search(javax.naming.Name, java.lang.String, javax.naming.directory.SearchControls)
*/
void addNamingListener(Name target, String filter, SearchControls ctls,
NamingListener l) throws NamingException;
/**
* Adds a listener for receiving naming events fired when
* objects identified by the search filter <tt>filter</tt> at the
* object named by the string target name are modified.
* See the overload that accepts a <tt>Name</tt> for details of
* how this method behaves.
*
* @param target The nonnull string name of the object resolved relative to this context.
* @param filter The nonnull string filter (see RFC2254).
* @param ctls The possibly null search controls. If null, the default
* search controls is used.
* @param l The nonnull listener.
* @exception NamingException If a problem was encountered while
* adding the listener.
* @see EventContext#removeNamingListener
* @see javax.naming.directory.DirContext#search(java.lang.String, java.lang.String, javax.naming.directory.SearchControls)
*/
void addNamingListener(String target, String filter, SearchControls ctls,
NamingListener l) throws NamingException;
/**
* Adds a listener for receiving naming events fired
* when objects identified by the search filter <tt>filter</tt> and
* filter arguments at the object named by the target are modified.
* The scope, returningObj flag, and returningAttributes flag from
* the search controls <tt>ctls</tt> are used to control the selection
* of objects that the listener is interested in,
* and determines what information is returned in the eventual
* <tt>NamingEvent</tt> object. Note that the requested
* information to be returned might not be present in the <tt>NamingEvent</tt>
* object if they are unavailable or could not be obtained by the
* service provider or service.
*
* @param target The nonnull name of the object resolved relative to this context.
* @param filter The nonnull string filter (see RFC2254).
* @param filterArgs The possibly null array of arguments for the filter.
* @param ctls The possibly null search controls. If null, the default
* search controls are used.
* @param l The nonnull listener.
* @exception NamingException If a problem was encountered while
* adding the listener.
* @see EventContext#removeNamingListener
* @see javax.naming.directory.DirContext#search(javax.naming.Name, java.lang.String, java.lang.Object[], javax.naming.directory.SearchControls)
*/
void addNamingListener(Name target, String filter, Object[] filterArgs,
SearchControls ctls, NamingListener l) throws NamingException;
/**
* Adds a listener for receiving naming events fired when
* objects identified by the search filter <tt>filter</tt>
* and filter arguments at the
* object named by the string target name are modified.
* See the overload that accepts a <tt>Name</tt> for details of
* how this method behaves.
*
* @param target The nonnull string name of the object resolved relative to this context.
* @param filter The nonnull string filter (see RFC2254).
* @param filterArgs The possibly null array of arguments for the filter.
* @param ctls The possibly null search controls. If null, the default
* search controls is used.
* @param l The nonnull listener.
* @exception NamingException If a problem was encountered while
* adding the listener.
* @see EventContext#removeNamingListener
* @see javax.naming.directory.DirContext#search(java.lang.String, java.lang.String, java.lang.Object[], javax.naming.directory.SearchControls) */
void addNamingListener(String target, String filter, Object[] filterArgs,
SearchControls ctls, NamingListener l) throws NamingException;
}

View File

@@ -0,0 +1,91 @@
/*
* Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.naming.event;
/**
* Specifies the methods that a listener interested in namespace changes
* must implement.
* Specifically, the listener is interested in <tt>NamingEvent</tt>s
* with event types of <tt>OBJECT_ADDED</TT>, <TT>OBJECT_RENAMED</TT>, or
* <TT>OBJECT_REMOVED</TT>.
*<p>
* Such a listener must:
*<ol>
*<li>Implement this interface and its methods.
*<li>Implement <tt>NamingListener.namingExceptionThrown()</tt> so that
* it will be notified of exceptions thrown while attempting to
* collect information about the events.
*<li>Register with the source using the source's <tt>addNamingListener()</tt>
* method.
*</ol>
* A listener that wants to be notified of <tt>OBJECT_CHANGED</tt> event types
* should also implement the <tt>ObjectChangeListener</tt>
* interface.
*
* @author Rosanna Lee
* @author Scott Seligman
*
* @see NamingEvent
* @see ObjectChangeListener
* @see EventContext
* @see EventDirContext
* @since 1.3
*/
public interface NamespaceChangeListener extends NamingListener {
/**
* Called when an object has been added.
*<p>
* The binding of the newly added object can be obtained using
* <tt>evt.getNewBinding()</tt>.
* @param evt The nonnull event.
* @see NamingEvent#OBJECT_ADDED
*/
void objectAdded(NamingEvent evt);
/**
* Called when an object has been removed.
*<p>
* The binding of the newly removed object can be obtained using
* <tt>evt.getOldBinding()</tt>.
* @param evt The nonnull event.
* @see NamingEvent#OBJECT_REMOVED
*/
void objectRemoved(NamingEvent evt);
/**
* Called when an object has been renamed.
*<p>
* The binding of the renamed object can be obtained using
* <tt>evt.getNewBinding()</tt>. Its old binding (before the rename)
* can be obtained using <tt>evt.getOldBinding()</tt>.
* One of these may be null if the old/new binding was outside the
* scope in which the listener has registered interest.
* @param evt The nonnull event.
* @see NamingEvent#OBJECT_RENAMED
*/
void objectRenamed(NamingEvent evt);
}

View File

@@ -0,0 +1,300 @@
/*
* Copyright (c) 1999, 2000, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.naming.event;
import javax.naming.Binding;
/**
* This class represents an event fired by a naming/directory service.
*<p>
* The <tt>NamingEvent</tt>'s state consists of
* <ul>
* <li>The event source: the <tt>EventContext</tt> which fired this event.
* <li>The event type.
* <li>The new binding: information about the object after the change.
* <li>The old binding: information about the object before the change.
* <li>Change information: information about the change
* that triggered this event; usually service provider-specific or server-specific
* information.
* </ul>
* <p>
* Note that the event source is always the same <tt>EventContext</tt>
* <em>instance</em> that the listener has registered with.
* Furthermore, the names of the bindings in
* the <tt>NamingEvent</tt> are always relative to that instance.
* For example, suppose a listener makes the following registration:
*<blockquote><pre>
* NamespaceChangeListener listener = ...;
* src.addNamingListener("x", SUBTREE_SCOPE, listener);
*</pre></blockquote>
* When an object named "x/y" is subsequently deleted, the corresponding
* <tt>NamingEvent</tt> (<tt>evt</tt>) must contain:
*<blockquote><pre>
* evt.getEventContext() == src
* evt.getOldBinding().getName().equals("x/y")
*</pre></blockquote>
*
* Care must be taken when multiple threads are accessing the same
* <tt>EventContext</tt> concurrently.
* See the
* <a href=package-summary.html#THREADING>package description</a>
* for more information on threading issues.
*
* @author Rosanna Lee
* @author Scott Seligman
*
* @see NamingListener
* @see EventContext
* @since 1.3
*/
public class NamingEvent extends java.util.EventObject {
/**
* Naming event type for indicating that a new object has been added.
* The value of this constant is <tt>0</tt>.
*/
public static final int OBJECT_ADDED = 0;
/**
* Naming event type for indicating that an object has been removed.
* The value of this constant is <tt>1</tt>.
*/
public static final int OBJECT_REMOVED = 1;
/**
* Naming event type for indicating that an object has been renamed.
* Note that some services might fire multiple events for a single
* logical rename operation. For example, the rename operation might
* be implemented by adding a binding with the new name and removing
* the old binding.
*<p>
* The old/new binding in <tt>NamingEvent</tt> may be null if the old
* name or new name is outside of the scope for which the listener
* has registered.
*<p>
* When an interior node in the namespace tree has been renamed, the
* topmost node which is part of the listener's scope should used to generate
* a rename event. The extent to which this can be supported is
* provider-specific. For example, a service might generate rename
* notifications for all descendants of the changed interior node and the
* corresponding provider might not be able to prevent those
* notifications from being propagated to the listeners.
*<p>
* The value of this constant is <tt>2</tt>.
*/
public static final int OBJECT_RENAMED = 2;
/**
* Naming event type for indicating that an object has been changed.
* The changes might include the object's attributes, or the object itself.
* Note that some services might fire multiple events for a single
* modification. For example, the modification might
* be implemented by first removing the old binding and adding
* a new binding containing the same name but a different object.
*<p>
* The value of this constant is <tt>3</tt>.
*/
public static final int OBJECT_CHANGED = 3;
/**
* Contains information about the change that generated this event.
* @serial
*/
protected Object changeInfo;
/**
* Contains the type of this event.
* @see #OBJECT_ADDED
* @see #OBJECT_REMOVED
* @see #OBJECT_RENAMED
* @see #OBJECT_CHANGED
* @serial
*/
protected int type;
/**
* Contains information about the object before the change.
* @serial
*/
protected Binding oldBinding;
/**
* Contains information about the object after the change.
* @serial
*/
protected Binding newBinding;
/**
* Constructs an instance of <tt>NamingEvent</tt>.
*<p>
* The names in <tt>newBd</tt> and <tt>oldBd</tt> are to be resolved relative
* to the event source <tt>source</tt>.
*
* For an <tt>OBJECT_ADDED</tt> event type, <tt>newBd</tt> must not be null.
* For an <tt>OBJECT_REMOVED</tt> event type, <tt>oldBd</tt> must not be null.
* For an <tt>OBJECT_CHANGED</tt> event type, <tt>newBd</tt> and
* <tt>oldBd</tt> must not be null. For an <tt>OBJECT_RENAMED</tt> event type,
* one of <tt>newBd</tt> or <tt>oldBd</tt> may be null if the new or old
* binding is outside of the scope for which the listener has registered.
*
* @param source The non-null context that fired this event.
* @param type The type of the event.
* @param newBd A possibly null binding before the change. See method description.
* @param oldBd A possibly null binding after the change. See method description.
* @param changeInfo A possibly null object containing information about the change.
* @see #OBJECT_ADDED
* @see #OBJECT_REMOVED
* @see #OBJECT_RENAMED
* @see #OBJECT_CHANGED
*/
public NamingEvent(EventContext source, int type,
Binding newBd, Binding oldBd, Object changeInfo) {
super(source);
this.type = type;
oldBinding = oldBd;
newBinding = newBd;
this.changeInfo = changeInfo;
}
/**
* Returns the type of this event.
* @return The type of this event.
* @see #OBJECT_ADDED
* @see #OBJECT_REMOVED
* @see #OBJECT_RENAMED
* @see #OBJECT_CHANGED
*/
public int getType() {
return type;
}
/**
* Retrieves the event source that fired this event.
* This returns the same object as <tt>EventObject.getSource()</tt>.
*<p>
* If the result of this method is used to access the
* event source, for example, to look up the object or get its attributes,
* then it needs to be locked because implementations of <tt>Context</tt>
* are not guaranteed to be thread-safe
* (and <tt>EventContext</tt> is a subinterface of <tt>Context</tt>).
* See the
* <a href=package-summary.html#THREADING>package description</a>
* for more information on threading issues.
*
* @return The non-null context that fired this event.
*/
public EventContext getEventContext() {
return (EventContext)getSource();
}
/**
* Retrieves the binding of the object before the change.
*<p>
* The binding must be nonnull if the object existed before the change
* relative to the source context (<tt>getEventContext()</tt>).
* That is, it must be nonnull for <tt>OBJECT_REMOVED</tt> and
* <tt>OBJECT_CHANGED</tt>.
* For <tt>OBJECT_RENAMED</tt>, it is null if the object before the rename
* is outside of the scope for which the listener has registered interest;
* it is nonnull if the object is inside the scope before the rename.
*<p>
* The name in the binding is to be resolved relative
* to the event source <tt>getEventContext()</tt>.
* The object returned by <tt>Binding.getObject()</tt> may be null if
* such information is unavailable.
*
* @return The possibly null binding of the object before the change.
*/
public Binding getOldBinding() {
return oldBinding;
}
/**
* Retrieves the binding of the object after the change.
*<p>
* The binding must be nonnull if the object existed after the change
* relative to the source context (<tt>getEventContext()</tt>).
* That is, it must be nonnull for <tt>OBJECT_ADDED</tt> and
* <tt>OBJECT_CHANGED</tt>. For <tt>OBJECT_RENAMED</tt>,
* it is null if the object after the rename is outside the scope for
* which the listener registered interest; it is nonnull if the object
* is inside the scope after the rename.
*<p>
* The name in the binding is to be resolved relative
* to the event source <tt>getEventContext()</tt>.
* The object returned by <tt>Binding.getObject()</tt> may be null if
* such information is unavailable.
*
* @return The possibly null binding of the object after the change.
*/
public Binding getNewBinding() {
return newBinding;
}
/**
* Retrieves the change information for this event.
* The value of the change information is service-specific. For example,
* it could be an ID that identifies the change in a change log on the server.
*
* @return The possibly null change information of this event.
*/
public Object getChangeInfo() {
return changeInfo;
}
/**
* Invokes the appropriate listener method on this event.
* The default implementation of
* this method handles the following event types:
* <tt>OBJECT_ADDED</TT>, <TT>OBJECT_REMOVED</TT>,
* <TT>OBJECT_RENAMED</TT>, <TT>OBJECT_CHANGED</TT>.
*<p>
* The listener method is executed in the same thread
* as this method. See the
* <a href=package-summary.html#THREADING>package description</a>
* for more information on threading issues.
* @param listener The nonnull listener.
*/
public void dispatch(NamingListener listener) {
switch (type) {
case OBJECT_ADDED:
((NamespaceChangeListener)listener).objectAdded(this);
break;
case OBJECT_REMOVED:
((NamespaceChangeListener)listener).objectRemoved(this);
break;
case OBJECT_RENAMED:
((NamespaceChangeListener)listener).objectRenamed(this);
break;
case OBJECT_CHANGED:
((ObjectChangeListener)listener).objectChanged(this);
break;
}
}
private static final long serialVersionUID = -7126752885365133499L;
}

View File

@@ -0,0 +1,94 @@
/*
* Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.naming.event;
import javax.naming.NamingException;
/**
* This class represents an event fired when the procedures/processes
* used to collect information for notifying listeners of
* <tt>NamingEvent</tt>s threw a <tt>NamingException</tt>.
* This can happen, for example, if the server which the listener is using
* aborts subsequent to the <tt>addNamingListener()</tt> call.
*
* @author Rosanna Lee
* @author Scott Seligman
*
* @see NamingListener#namingExceptionThrown
* @see EventContext
* @since 1.3
*/
public class NamingExceptionEvent extends java.util.EventObject {
/**
* Contains the exception that was thrown
* @serial
*/
private NamingException exception;
/**
* Constructs an instance of <tt>NamingExceptionEvent</tt> using
* the context in which the <tt>NamingException</tt> was thrown and the exception
* that was thrown.
*
* @param source The non-null context in which the exception was thrown.
* @param exc The non-null <tt>NamingException</tt> that was thrown.
*
*/
public NamingExceptionEvent(EventContext source, NamingException exc) {
super(source);
exception = exc;
}
/**
* Retrieves the exception that was thrown.
* @return The exception that was thrown.
*/
public NamingException getException() {
return exception;
}
/**
* Retrieves the <tt>EventContext</tt> that fired this event.
* This returns the same object as <tt>EventObject.getSource()</tt>.
* @return The non-null <tt>EventContext</tt> that fired this event.
*/
public EventContext getEventContext() {
return (EventContext)getSource();
}
/**
* Invokes the <tt>namingExceptionThrown()</tt> method on
* a listener using this event.
* @param listener The non-null naming listener on which to invoke
* the method.
*/
public void dispatch(NamingListener listener) {
listener.namingExceptionThrown(this);
}
private static final long serialVersionUID = -4877678086134736336L;
}

View File

@@ -0,0 +1,65 @@
/*
* Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.naming.event;
/**
* This interface is the root of listener interfaces that
* handle <tt>NamingEvent</tt>s.
* It does not make sense for a listener to implement just this interface.
* A listener typically implements a subinterface of <tt>NamingListener</tt>,
* such as <tt>ObjectChangeListener</tt> or <tt>NamespaceChangeListener</tt>.
*<p>
* This interface contains a single method, <tt>namingExceptionThrown()</tt>,
* that must be implemented so that the listener can be notified of
* exceptions that are thrown (by the service provider) while gathering
* information about the events that they're interested in.
* When this method is invoked, the listener has been automatically deregistered
* from the <tt>EventContext</tt> with which it has registered.
*<p>
* For example, suppose a listener implements <tt>ObjectChangeListener</tt> and
* registers with a <tt>EventContext</tt>.
* Then, if the connection to the server is subsequently broken,
* the listener will receive a <tt>NamingExceptionEvent</tt> and may
* take some corrective action, such as notifying the user of the application.
*
* @author Rosanna Lee
* @author Scott Seligman
*
* @see NamingEvent
* @see NamingExceptionEvent
* @see EventContext
* @see EventDirContext
* @since 1.3
*/
public interface NamingListener extends java.util.EventListener {
/**
* Called when a naming exception is thrown while attempting
* to fire a <tt>NamingEvent</tt>.
*
* @param evt The nonnull event.
*/
void namingExceptionThrown(NamingExceptionEvent evt);
}

View File

@@ -0,0 +1,73 @@
/*
* Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.naming.event;
/**
* Specifies the method that a listener of a <tt>NamingEvent</tt>
* with event type of <tt>OBJECT_CHANGED</tt> must implement.
*<p>
* An <tt>OBJECT_CHANGED</tt> event type is fired when (the contents of)
* an object has changed. This might mean that its attributes have been modified,
* added, or removed, and/or that the object itself has been replaced.
* How the object has changed can be determined by examining the
* <tt>NamingEvent</tt>'s old and new bindings.
*<p>
* A listener interested in <tt>OBJECT_CHANGED</tt> event types must:
*<ol>
*
*<li>Implement this interface and its method (<tt>objectChanged()</tt>)
*<li>Implement <tt>NamingListener.namingExceptionThrown()</tt> so that
* it will be notified of exceptions thrown while attempting to
* collect information about the events.
*<li>Register with the source using the source's <tt>addNamingListener()</tt>
* method.
*</ol>
* A listener that wants to be notified of namespace change events
* should also implement the <tt>NamespaceChangeListener</tt>
* interface.
*
* @author Rosanna Lee
* @author Scott Seligman
*
* @see NamingEvent
* @see NamespaceChangeListener
* @see EventContext
* @see EventDirContext
* @since 1.3
*/
public interface ObjectChangeListener extends NamingListener {
/**
* Called when an object has been changed.
*<p>
* The binding of the changed object can be obtained using
* <tt>evt.getNewBinding()</tt>. Its old binding (before the change)
* can be obtained using <tt>evt.getOldBinding()</tt>.
* @param evt The nonnull naming event.
* @see NamingEvent#OBJECT_CHANGED
*/
void objectChanged(NamingEvent evt);
}