javax.naming.event
Class NamingEvent

java.lang.Object sample code for java.lang.Object definition code for java.lang.Object 
  extended by java.util.EventObject sample code for java.util.EventObject definition code for java.util.EventObject 
      extended by javax.naming.event.NamingEvent
All Implemented Interfaces:
Serializable sample code for java.io.Serializable definition code for java.io.Serializable

public class NamingEvent
extends EventObject sample code for java.util.EventObject definition code for java.util.EventObject

This class represents an event fired by a naming/directory service.

The NamingEvent's state consists of

Note that the event source is always the same EventContext instance that the listener has registered with. Furthermore, the names of the bindings in the NamingEvent are always relative to that instance. For example, suppose a listener makes the following registration:

        NamespaceChangeListener listener = ...;
        src.addNamingListener("x", SUBTREE_SCOPE, listener);
When an object named "x/y" is subsequently deleted, the corresponding NamingEvent (evt) must contain:
        evt.getEventContext() == src
        evt.getOldBinding().getName().equals("x/y")
Care must be taken when multiple threads are accessing the same EventContext concurrently. See the package description for more information on threading issues.

Since:
1.3
See Also:
NamingListener sample code for javax.naming.event.NamingListener definition code for javax.naming.event.NamingListener , EventContext sample code for javax.naming.event.EventContext definition code for javax.naming.event.EventContext , Serialized Form

Field Summary
protected  Object sample code for java.lang.Object definition code for java.lang.Object changeInfo sample code for javax.naming.event.NamingEvent.changeInfo definition code for javax.naming.event.NamingEvent.changeInfo
          Contains information about the change that generated this event.
protected  Binding sample code for javax.naming.Binding definition code for javax.naming.Binding newBinding sample code for javax.naming.event.NamingEvent.newBinding definition code for javax.naming.event.NamingEvent.newBinding
          Contains information about the object after the change.
static int OBJECT_ADDED sample code for javax.naming.event.NamingEvent.OBJECT_ADDED definition code for javax.naming.event.NamingEvent.OBJECT_ADDED
          Naming event type for indicating that a new object has been added.
static int OBJECT_CHANGED sample code for javax.naming.event.NamingEvent.OBJECT_CHANGED definition code for javax.naming.event.NamingEvent.OBJECT_CHANGED
          Naming event type for indicating that an object has been changed.
static int OBJECT_REMOVED sample code for javax.naming.event.NamingEvent.OBJECT_REMOVED definition code for javax.naming.event.NamingEvent.OBJECT_REMOVED
          Naming event type for indicating that an object has been removed.
static int OBJECT_RENAMED sample code for javax.naming.event.NamingEvent.OBJECT_RENAMED definition code for javax.naming.event.NamingEvent.OBJECT_RENAMED
          Naming event type for indicating that an object has been renamed.
protected  Binding sample code for javax.naming.Binding definition code for javax.naming.Binding oldBinding sample code for javax.naming.event.NamingEvent.oldBinding definition code for javax.naming.event.NamingEvent.oldBinding
          Contains information about the object before the change.
protected  int type sample code for javax.naming.event.NamingEvent.type definition code for javax.naming.event.NamingEvent.type
          Contains the type of this event.
 
Fields inherited from class java.util.EventObject sample code for java.util.EventObject definition code for java.util.EventObject
source sample code for java.util.EventObject.source definition code for java.util.EventObject.source
 
Constructor Summary
NamingEvent sample code for javax.naming.event.NamingEvent.NamingEvent(javax.naming.event.EventContext, int, javax.naming.Binding, javax.naming.Binding, java.lang.Object) definition code for javax.naming.event.NamingEvent.NamingEvent(javax.naming.event.EventContext, int, javax.naming.Binding, javax.naming.Binding, java.lang.Object) (EventContext sample code for javax.naming.event.EventContext definition code for javax.naming.event.EventContext  source, int type, Binding sample code for javax.naming.Binding definition code for javax.naming.Binding  newBd, Binding sample code for javax.naming.Binding definition code for javax.naming.Binding  oldBd, Object sample code for java.lang.Object definition code for java.lang.Object  changeInfo)
          Constructs an instance of NamingEvent.
 
Method Summary
 void dispatch sample code for javax.naming.event.NamingEvent.dispatch(javax.naming.event.NamingListener) definition code for javax.naming.event.NamingEvent.dispatch(javax.naming.event.NamingListener) (NamingListener sample code for javax.naming.event.NamingListener definition code for javax.naming.event.NamingListener  listener)
          Invokes the appropriate listener method on this event.
 Object sample code for java.lang.Object definition code for java.lang.Object getChangeInfo sample code for javax.naming.event.NamingEvent.getChangeInfo() definition code for javax.naming.event.NamingEvent.getChangeInfo() ()
          Retrieves the change information for this event.
 EventContext sample code for javax.naming.event.EventContext definition code for javax.naming.event.EventContext getEventContext sample code for javax.naming.event.NamingEvent.getEventContext() definition code for javax.naming.event.NamingEvent.getEventContext() ()
          Retrieves the event source that fired this event.
 Binding sample code for javax.naming.Binding definition code for javax.naming.Binding getNewBinding sample code for javax.naming.event.NamingEvent.getNewBinding() definition code for javax.naming.event.NamingEvent.getNewBinding() ()
          Retrieves the binding of the object after the change.
 Binding sample code for javax.naming.Binding definition code for javax.naming.Binding getOldBinding sample code for javax.naming.event.NamingEvent.getOldBinding() definition code for javax.naming.event.NamingEvent.getOldBinding() ()
          Retrieves the binding of the object before the change.
 int getType sample code for javax.naming.event.NamingEvent.getType() definition code for javax.naming.event.NamingEvent.getType() ()
          Returns the type of this event.
 
Methods inherited from class java.util.EventObject sample code for java.util.EventObject definition code for java.util.EventObject
getSource sample code for java.util.EventObject.getSource() definition code for java.util.EventObject.getSource() , toString sample code for java.util.EventObject.toString() definition code for java.util.EventObject.toString()
 
Methods inherited from class java.lang.Object sample code for java.lang.Object definition code for java.lang.Object
clone sample code for java.lang.Object.clone() definition code for java.lang.Object.clone() , equals sample code for java.lang.Object.equals(java.lang.Object) definition code for java.lang.Object.equals(java.lang.Object) , finalize sample code for java.lang.Object.finalize() definition code for java.lang.Object.finalize() , getClass sample code for java.lang.Object.getClass() definition code for java.lang.Object.getClass() , hashCode sample code for java.lang.Object.hashCode() definition code for java.lang.Object.hashCode() , notify sample code for java.lang.Object.notify() definition code for java.lang.Object.notify() , notifyAll sample code for java.lang.Object.notifyAll() definition code for java.lang.Object.notifyAll() , wait sample code for java.lang.Object.wait() definition code for java.lang.Object.wait() , wait sample code for java.lang.Object.wait(long) definition code for java.lang.Object.wait(long) , wait sample code for java.lang.Object.wait(long, int) definition code for java.lang.Object.wait(long, int)
 

Field Detail

OBJECT_ADDED sample code for javax.naming.event.NamingEvent.OBJECT_ADDED

public static final int OBJECT_ADDED
Naming event type for indicating that a new object has been added. The value of this constant is 0.

See Also:
Constant Field Values

OBJECT_REMOVED sample code for javax.naming.event.NamingEvent.OBJECT_REMOVED

public static final int OBJECT_REMOVED
Naming event type for indicating that an object has been removed. The value of this constant is 1.

See Also:
Constant Field Values

OBJECT_RENAMED sample code for javax.naming.event.NamingEvent.OBJECT_RENAMED

public static final int OBJECT_RENAMED
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.

The old/new binding in NamingEvent may be null if the old name or new name is outside of the scope for which the listener has registered.

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.

The value of this constant is 2.

See Also:
Constant Field Values

OBJECT_CHANGED sample code for javax.naming.event.NamingEvent.OBJECT_CHANGED

public static final int OBJECT_CHANGED
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.

The value of this constant is 3.

See Also:
Constant Field Values

changeInfo sample code for javax.naming.event.NamingEvent.changeInfo

protected Object sample code for java.lang.Object definition code for java.lang.Object  changeInfo
Contains information about the change that generated this event.


type sample code for javax.naming.event.NamingEvent.type

protected int type
Contains the type of this event.

See Also:
OBJECT_ADDED sample code for javax.naming.event.NamingEvent.OBJECT_ADDED definition code for javax.naming.event.NamingEvent.OBJECT_ADDED , OBJECT_REMOVED sample code for javax.naming.event.NamingEvent.OBJECT_REMOVED definition code for javax.naming.event.NamingEvent.OBJECT_REMOVED , OBJECT_RENAMED sample code for javax.naming.event.NamingEvent.OBJECT_RENAMED definition code for javax.naming.event.NamingEvent.OBJECT_RENAMED , OBJECT_CHANGED sample code for javax.naming.event.NamingEvent.OBJECT_CHANGED definition code for javax.naming.event.NamingEvent.OBJECT_CHANGED

oldBinding sample code for javax.naming.event.NamingEvent.oldBinding

protected Binding sample code for javax.naming.Binding definition code for javax.naming.Binding  oldBinding
Contains information about the object before the change.


newBinding sample code for javax.naming.event.NamingEvent.newBinding

protected Binding sample code for javax.naming.Binding definition code for javax.naming.Binding  newBinding
Contains information about the object after the change.

Constructor Detail

NamingEvent sample code for javax.naming.event.NamingEvent(javax.naming.event.EventContext, int, javax.naming.Binding, javax.naming.Binding, java.lang.Object) definition code for javax.naming.event.NamingEvent(javax.naming.event.EventContext, int, javax.naming.Binding, javax.naming.Binding, java.lang.Object)

public NamingEvent(EventContext sample code for javax.naming.event.EventContext definition code for javax.naming.event.EventContext  source,
                   int type,
                   Binding sample code for javax.naming.Binding definition code for javax.naming.Binding  newBd,
                   Binding sample code for javax.naming.Binding definition code for javax.naming.Binding  oldBd,
                   Object sample code for java.lang.Object definition code for java.lang.Object  changeInfo)
Constructs an instance of NamingEvent.

The names in newBd and oldBd are to be resolved relative to the event source source. For an OBJECT_ADDED event type, newBd must not be null. For an OBJECT_REMOVED event type, oldBd must not be null. For an OBJECT_CHANGED event type, newBd and oldBd must not be null. For an OBJECT_RENAMED event type, one of newBd or oldBd may be null if the new or old binding is outside of the scope for which the listener has registered.

Parameters:
source - The non-null context that fired this event.
type - The type of the event.
newBd - A possibly null binding before the change. See method description.
oldBd - A possibly null binding after the change. See method description.
changeInfo - A possibly null object containing information about the change.
See Also:
OBJECT_ADDED sample code for javax.naming.event.NamingEvent.OBJECT_ADDED definition code for javax.naming.event.NamingEvent.OBJECT_ADDED , OBJECT_REMOVED sample code for javax.naming.event.NamingEvent.OBJECT_REMOVED definition code for javax.naming.event.NamingEvent.OBJECT_REMOVED , OBJECT_RENAMED sample code for javax.naming.event.NamingEvent.OBJECT_RENAMED definition code for javax.naming.event.NamingEvent.OBJECT_RENAMED , OBJECT_CHANGED sample code for javax.naming.event.NamingEvent.OBJECT_CHANGED definition code for javax.naming.event.NamingEvent.OBJECT_CHANGED
Method Detail

getType sample code for javax.naming.event.NamingEvent.getType() definition code for javax.naming.event.NamingEvent.getType()

public int getType()
Returns the type of this event.

Returns:
The type of this event.
See Also:
OBJECT_ADDED sample code for javax.naming.event.NamingEvent.OBJECT_ADDED definition code for javax.naming.event.NamingEvent.OBJECT_ADDED , OBJECT_REMOVED sample code for javax.naming.event.NamingEvent.OBJECT_REMOVED definition code for javax.naming.event.NamingEvent.OBJECT_REMOVED , OBJECT_RENAMED sample code for javax.naming.event.NamingEvent.OBJECT_RENAMED definition code for javax.naming.event.NamingEvent.OBJECT_RENAMED , OBJECT_CHANGED sample code for javax.naming.event.NamingEvent.OBJECT_CHANGED definition code for javax.naming.event.NamingEvent.OBJECT_CHANGED

getEventContext sample code for javax.naming.event.NamingEvent.getEventContext() definition code for javax.naming.event.NamingEvent.getEventContext()

public EventContext sample code for javax.naming.event.EventContext definition code for javax.naming.event.EventContext  getEventContext()
Retrieves the event source that fired this event. This returns the same object as EventObject.getSource().

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 Context are not guaranteed to be thread-safe (and EventContext is a subinterface of Context). See the package description for more information on threading issues.

Returns:
The non-null context that fired this event.

getOldBinding sample code for javax.naming.event.NamingEvent.getOldBinding() definition code for javax.naming.event.NamingEvent.getOldBinding()

public Binding sample code for javax.naming.Binding definition code for javax.naming.Binding  getOldBinding()
Retrieves the binding of the object before the change.

The binding must be nonnull if the object existed before the change relative to the source context (getEventContext()). That is, it must be nonnull for OBJECT_REMOVED and OBJECT_CHANGED. For OBJECT_RENAMED, 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.

The name in the binding is to be resolved relative to the event source getEventContext(). The object returned by Binding.getObject() may be null if such information is unavailable.

Returns:
The possibly null binding of the object before the change.

getNewBinding sample code for javax.naming.event.NamingEvent.getNewBinding() definition code for javax.naming.event.NamingEvent.getNewBinding()

public Binding sample code for javax.naming.Binding definition code for javax.naming.Binding  getNewBinding()
Retrieves the binding of the object after the change.

The binding must be nonnull if the object existed after the change relative to the source context (getEventContext()). That is, it must be nonnull for OBJECT_ADDED and OBJECT_CHANGED. For OBJECT_RENAMED, 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.

The name in the binding is to be resolved relative to the event source getEventContext(). The object returned by Binding.getObject() may be null if such information is unavailable.

Returns:
The possibly null binding of the object after the change.

getChangeInfo sample code for javax.naming.event.NamingEvent.getChangeInfo() definition code for javax.naming.event.NamingEvent.getChangeInfo()

public Object sample code for java.lang.Object definition code for java.lang.Object  getChangeInfo()
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.

Returns:
The possibly null change information of this event.

dispatch sample code for javax.naming.event.NamingEvent.dispatch(javax.naming.event.NamingListener) definition code for javax.naming.event.NamingEvent.dispatch(javax.naming.event.NamingListener)

public void dispatch(NamingListener sample code for javax.naming.event.NamingListener definition code for javax.naming.event.NamingListener  listener)
Invokes the appropriate listener method on this event. The default implementation of this method handles the following event types: OBJECT_ADDED, OBJECT_REMOVED, OBJECT_RENAMED, OBJECT_CHANGED.

The listener method is executed in the same thread as this method. See the package description for more information on threading issues.

Parameters:
listener - The nonnull listener.