
JNDI
• A naming service allows you to tie resources to human readable strings.
- This makes your code much more human readable.
- A naming service will provide a reference to some part of memory.
- You must get familiar with the concept of a context before you can understand JNDI.
• References or Handles are pointers to some memory location.
- The reference is typically some large number on your machine.
- References to the same thing can vary from machine to machine. The location c:\temp\myFile.txt is not
accessed using the same string from another machine.
- References can also change based on when they were accessed.
• Giving a reference a name is a way to allow distributed environments to refer to the same
object/memory area in one way.
- The reference o in the following code only makes sense for the machine it was created it.
Object o = new Object();
- This value of o will also be unusable later in the program if o falls out of scope.
• Names in the distributed sense give us the ability to assign one human readable name to an object
accessed from multiple different machines.
- A name could be a string referring to a file.
- A name could be the hostname that refers to some machine on your network.
- A name could refer to a server (such as a CORBA server) running on some other machine.
- Names only make sense when viewed as part of a context. The name “Hartford” can refer to many
towns. The context of Hartford is Connecticut, USA. Just saying Hartford can refer to many different
towns.
• Directory services provide structure to collections of directory objects.
- Directories are normally hierarchical.
- Directories support searchable attributes so you can find all services that support some feature.
• A context represents a place or scope of where a name exists.
- For instance when you type in http://www.intertech-inc.com/index.html you are actually being shown a
file called index.html that exists in some directory on the web server.
- A context provides a name to object bindings.
- Each folder in a directory represents a context.
- You can visualize the JNDI registry as a tree.
• Names in JNDI can have different forms.
- Compound names are names that are significant within one naming service, composed of more than one
name.
c:\temp\somedirectory\this.txt
- A composite name is a name that spans more than one naming service.
http://www.intertech-inc.com/somedirectory/this.txt
• In WebLogic JNDI is a straight forward.
- Every context is separated from its sub-context with a “.”.
- You can view the JNDI tree in WebLogic using the Console.
• In the below windows you can see two different views of the same resource.
- Locally Index.html is in C:\somedirectory\webco\store\Index.html.
- To the browsers c:\somedirectory is 127.0.0.1.
- This name Index.html makes sense in the context of 127.0.0.1\webco\store.
• Recapping the basic vocabulary of Naming services.
- Reference or Handle: A memory location or place.
- Name: A human readable mapping to a reference.
- Context: The environment where a name exists.
• JNDI is Java Naming and Directory services.
- JNDI represents a central location, or umbrella application that other Naming and Directory services
can use.
- The true power of JNDI is its flexibility and standardization.
- Like all standards, JNDI is only as strong as the industry acceptance behind it, and JNDI is very strong,
and well accepted.
• The JNDI architecture is a two-sided affair.
- Resources register with JNDI using the Service Provider Interface (SPI).
- Applications use JNDI API to discover resources registered through SPI.
• Sun and other industry leaders provide JNDI implementations for a variety of naming and directory
services.
- DSML, DNS, LDAP, File systems, COS Naming, RMI Registry, and others.
• JNDI supports many additional features that we won’t cover.
- Filtering searches
- Search Controls
- Events
- Support for NIS, NDS, LDAP, and advanced LDAP v3
• For more information on these topics, look in the API or the documentation provided by your vendor.
JNDI
Table of Contents
Copyright (c) 2008. Intertech, Inc. All Rights Reserved. This information is to be used exclusively as an
online learning aid. Any attempts to copy, reproduce, or use for training is strictly prohibited.
Courseware
Training Resources
Tutorials