Previous | Next | Trail Map | Beyond the Basics | Contents

Event Notification

As the naming/directory service plays an increasingly important role in the computing environment, the need to provide administration and monitoring tools to help manage changes in the service also increases. For such tools and other applications, the traditional request/response style of interaction needs to be augmented with an asynchronous notification model that allows applications to register interest in changes in the service.

The javax.naming.event(in the API reference documentation) package contains classes and interfaces for supporting event notification. It uses an event model similar to that used by the Java Abstract Windowing Toolkit (AWT) and JavaBeansTM, both of which are part of the Java 2 platform. The model is essentially that events are fired by event sources. An event listener registers with an event source to receive notifications about events of a particular type.

In the JNDI, event sources are objects that implement either the EventContext(in the API reference documentation) or EventDirContext(in the API reference documentation) interface. Event listeners are objects that implement the NamingListener(in the API reference documentation) interface or one of its subinterfaces.

This lesson describes the different types of event listeners available in the JNDI and how to register them to receive event notifications. It also describes how to register for unsolicited notifications that might be generated by LDAP servers.

Client and Server Configuration

The examples in this lesson use the LDAP service provider. They assume that you have set up a sample namespace using the content described in the Preparations (in the Basics trail) lesson. If you use another service provider or choose to use another part of the LDAP namespace, the behavior will differ from what is shown here.

The initial context used in these examples is initialized using the following environment properties.

// Set up the environment for creating the initial context
Hashtable env = new Hashtable();
env.put(Context.PROVIDER_URL, "ldap://localhost:389/o=JNDITutorial");

Also, the LDAP server must support the Persistent Search control (Internet-draft draft-ietf-ldapext-psearch-03.txt). The Netscape Directory Server v4.1 supports this control.

Windows Active Directory: Because Active Directory does not support the Persistent Search Control, none of the examples in this lesson will work against Active Directory.

Previous | Next | Trail Map | Beyond the Basics | Contents