|
Comments
|
Today's Top SOA Links
Enterprise Java Naming Services Internals
Implementing a Simple Client/Server-Based JNDI Naming Service
By: Kishore Kumar
Mar. 9, 2005 12:00 AM
The Java Naming and Directory Interface (JNDI) is a standard API to access different naming and directory service implementations like LDAP. A naming service provides naming functionality and a directory service provides applications with directory functionality. The Java naming service is a fundamental component of every J2EE system. JNDI consists of a client API and a service provider interface (SPI). The client application uses the client API to access various naming and directory services. The SPI lets naming and directory service implementations be plugged into the JNDI framework. In this article, we will explore how to use the JNDI SPI to implement a simple client/server-based naming service.
Naming Service Architecture The first thing any JNDI client does is to create an InitialContext object. The InitialContext uses an URLContextFactory to create a Context implementation. The naming service provider supplies the URLContextFactory and the corresponding Context implementation. The JNDI InitialContext object delegates every naming method to the provider's context implementation.
Hashtable properties=new HashTable();
Implementing the Java Naming Service - Server
A binding instance contains the triple: the name, object to be stored, and the object class name.
Naming Server Interface
Name In the case of a name 'comp/env/appOwner,' the Name object represents the list '{comp,env,appOwner}.' It's the NameParser of a naming system that parses the string representation of a name and creates the corresponding Name object. The parsing rules depend on the naming system and its naming parser implementation. There are two different kinds of structured names that implement the Name interface- CompositeName and CompoundName. A CompositeName represents a name that can span multiple naming systems. For instance, the name 'cn=aper-son, ou=ust_india,o=ust/profile/publications' represents two parts: an LDAP name 'cn=aperson,ou=ust_india,o=ust' and a File System name 'profile/publications.' When this name is used in a lookup operation, the method resolves through the LDAP naming service and passes into the File System naming service to find the target object. In a CompositeName the various components are separated by a forward slash ('/') character. Hence, the given name has three components '{(cn=aperson,ou=ust_india,o= ust),(profile),(publications)}'. The first component represents a name (compound name) in the LDAP naming system and the last two components represent a name in the File System naming system. The mechanism by which a JNDI system resolves through multiple naming systems is known as a naming federation. We will explore this technique later in this article. A CompoundName is a name in a single naming system. It is a convenience class that can parse a string representation of a name to create a Name object. Its parser can be customized by providing the required parsing syntax:
Properties syntax=new Properties(); This parses the string representation using the syntax provided to create an equivalent CompoundName in the current naming system. A typical naming parser can also use the CompoundName to parse a string name to a Name object:
Naming Server Implementation
Reader Feedback: Page 1 of 1
Subscribe to the World's Most Powerful Newsletters
Subscribe to Our Rss Feeds & Get Your SYS-CON News Live!
|
SYS-CON Featured Whitepapers
Most Read This Week |
|||||||||||||||||||||||||||