1. Divide interfaces into Context and DirContext
JNDI has two core interfaces: Context and DirContext. Context contains basic name operations, and DirContext extends these operations to the directory service. These operations are divided into two packages. On the one hand, they are modularized, and on the other hand, they can reduce unnecessary overhead of services. The name is a basic function in the computing service. Using the basic name service, you can obtain functions such as the file system, workbook, and calendar services. DirContext extends the Context, provides basic directory service operations, maintenance of name object attributes, and attribute-based name search.
2. Divide JNDI into multiple feature packages.
JNDI is divided into two client packages (javax. naming, javax. naming. directory) and one server package (javax. naming. spi ). This is also done to reduce unnecessary overhead of the application, so that the application only needs to include the necessary package.
3. Separate the client API from the Server API
JNDI separates the client interface from the interface required by the service provider into different packages. For example, the client program only needs to use the classes provided in the javax. naming package, and the service provider may need the javax. naming and javax. naming. spi packages. In this way, the customer and the server can focus only on their own class information.
4. Multiple methods of context list
In general, there are two kinds of applications for context list: the application for context browsing and the application for actual operations on objects in the context.
Generally, a context browser only needs to display the name of the content contained in the context, or obtain information such as the object type. This type of application is generally interactive and allows users to select some of the listed context lists for further display.
In addition, some applications need to perform actual operations on objects in the context. For example, a backup program needs to perform operations on the statuses of all files in the directory, or a printer administrator may need to reset all the printers in the building. To perform this operation, the program needs to obtain the actual object in the context.
For these two types of applications, the context interface provides two context list methods: List () and listbindings (). Here, list () Only returns a series of name/class ing, while listbindings () returns the name, class, and object itself. Obviously, list () is used for context browsing and listbindings () is used for applications that require actual operations on objects.
5. Support for Federation
Federation is a basic concept of JNDI. The client interface supports names that span multiple namespaces. The program that calls the name interface does not need to know the details, but only needs to specify the relevant name, the issue about how to resolve compound names in several name systems is left to the service provider for resolution and has nothing to do with the customer.
6 dircontext and dirobject
For the implementation of the directory service, if you do not need to extend the dircontext interface of context, you can also use an interface that contains all directory-related methods, such as dirobject, in this way, if the application only uses the directory service, it can only include dirobject. If both the name service and the Directory Service are used, context and dirobject can be included. This is clear, but it is not convenient for some mixed operations, such as operations that are effective for directories and names. Therefore, the dircontext instead of dirobject is used for JNDI.
7. schema support
The dircontext interface supports schema. For example, you can use the dircontext object to obtain the schema object pointing to the schema definition space of the dircontext instance, or obtain the class definition of the schema object. The attribute class further supports methods for obtaining attribute type information and attribute definitions. The service provider can either dynamically return the schema information or statically prepare the schema information in advance.
8 context and dircontext
Each method in the Context and DirContext interfaces that accepts the Name parameter has a method that accepts the same Name as the string parameter. The reason for designing the string-based method is that many applications only access these objects through the object name. For these applications, directly using the name to access these methods is of course the most intuitive.
The motivation for designing a method that uses Name-class objects as parameters is also because many applications that maintain names do not have a literal expression of names, so Name objects must be used as parameters. In JNDI, both methods can be called to facilitate different applications.
9 Reference
JNDI supports multiple methods to use directories to locate objects. For example, some applications directly bind objects to directories. Some applications may dynamically generate directory trees, when the application exits, it deletes the tree. Other applications may only store URLs pointing to objects in the namespace. Other systems may bind some reference information to the tree, use this information to access the actual object.
For these different methods, JNDI defines a Reference class to provide a uniform way for the expression of application information. The Reference class contains information such as addresses and types used to access specific objects. To bind an object reference to a directory tree, the class of this object must implement the Referenceable interface, which includes the getReference () method (). The Serializable interface and the Referenceable interface have many similarities, the difference is that the referenced object only contains some information for creating the actual object, and Serializable will contain more or even less suitable information stored in the directory structure.
10 automatic positioning of referenced objects for objects bound to the directory tree as references, jndi spi specifies the creation of actual objects for references. Therefore, in a program, you only need to think that the object returned by the lookup () method is the actual object, instead of calling any method to convert the reference to the actual object, all work is done internally by JNDI.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service