I will present this interface later in this article. It's also important to understand how existing naming services differ, since JNDI must provide a workable abstraction that gets around those differences. Aside from functional differences, the most noticeable difference is the way each naming service requires names to be specified -- its naming convention. A few examples should illustrate the problem. In DNS, names are built from components that are separated by dots ". They read from right to left.
The name "www. Likewise, the name "etcee. In LDAP, the situation is slightly more complicated. Names are built from components that are separated by commas ",". Like DNS names, they read from right to left. As the examples above illustrate, a naming service's naming convention alone has the potential to introduce a significant amount of the flavor of the underlying naming service into JNDI. This is not a feature an implementation-independent interface should have.
JNDI solves this problem with the Name class and its subclasses and helper classes. The Name class represents a name composed of an ordered sequences of subnames, and provides methods for working with names independent of the underlying naming service. As I mentioned above, it's important to remember that JNDI is an interface rather than an implementation. This fact has some disadvantages -- you need access to an existing naming service such as an LDAP service and you need to understand something about how it works in order to play with JNDI.
On the other hand, it does allow JNDI to integrate seamlessly into an existing computing environment where an established naming service holds sway. JNDI naming revolves around a small set of classes and a handful of operations. Let's take a look at them. A context represents a set of bindings within a naming service that all share the same naming convention. A Context object provides the methods for binding names to objects and unbinding names from objects, for renaming objects, and for listing the bindings.
Some naming services also provide subcontext functionality. Much like a directory in a filesystem, a subcontext is a context within a context. This hierarchical structure permits better organization of information. For naming services that support subcontexts, the Context class also provides methods for creating and destroying subcontexts. JNDI performs all naming operations relative to a context.
This class is instantiated with properties that define the type of naming service in use and, for naming services that provide security, the ID and password to use when connecting. For those of you familiar with the RMI Naming class, many of the methods provided by the Context interface outlined below will look familiar.
Let's take a look at Context 's methods:. The name must not be bound to another object. All intermediate contexts must already exist. NamingEnumeration listBindings String stringName : Returns an enumeration containing the names bound to the specified context, along with the objects and the class names of the objects bound to them.
Each of these methods has a sibling that takes a Name object instead of a String object. A Name object represents a generic name. The Name class allows a program to manipulate names without having to know as much about the specific naming service in use.
The example below illustrates how to connect to a naming service, list all of the bindings, or list a specific binding. It uses the filesystem service provider, which is one of the reference JNDI service-provider implementations provided by Sun. What's the main purpose of using it? Purpose of custom hook in react?
React purpose of custom hooks What is the purpose of doing bind this while handling the events in React. What is the purpose of double curly braces in React's JSX syntax? What's the purpose of using classes in React? What is the purpose of using demo or root What is the purpose of form in React JS. Related Questions. Storing objects for locating by x,y coordinates Make a client server java application Difference between Arrays.
After the jndi. The best way is to add the jndi. When the object is loaded, JNDI provides a path to the object. If you are using Java 1. It can also be used to create a multitier connection to another naming service through a WebLogic Server.
Therefore, it is important to understand the implications of binding an object to the JNDI tree in a clustered environment.
0コメント