javax.naming

Home
Java Source Code / Java Documentation
1.6.0 JDK Core
2.6.0 JDK Modules
3.6.0 JDK Modules com.sun
4.6.0 JDK Modules com.sun.java
5.6.0 JDK Modules sun
6.6.0 JDK Platform
7.Ajax
8.Apache Harmony Java SE
9.Aspect oriented
10.Authentication Authorization
11.Blogger System
12.Build
13.Byte Code
14.Cache
15.Chart
16.Chat
17.Code Analyzer
18.Collaboration
19.Content Management System
20.Database Client
21.Database DBMS
22.Database JDBC Connection Pool
23.Database ORM
24.Development
25.EJB Server
26.ERP CRM Financial
27.ESB
28.Forum
29.Game
30.GIS
31.Graphic 3D
32.Graphic Library
33.Groupware
34.HTML Parser
35.IDE
36.IDE Eclipse
37.IDE Netbeans
38.Installer
39.Internationalization Localization
40.Inversion of Control
41.Issue Tracking
42.J2EE
43.J2ME
44.JBoss
45.JMS
46.JMX
47.Library
48.Mail Clients
49.Music
50.Net
51.Parser
52.PDF
53.Portal
54.Profiler
55.Project Management
56.Report
57.RSS RDF
58.Rule Engine
59.Science
60.Scripting
61.Search Engine
62.Security
63.Sevlet Container
64.Source Control
65.Swing Library
66.Template Engine
67.Test Coverage
68.Testing
69.UML
70.Web Crawler
71.Web Framework
72.Web Mail
73.Web Server
74.Web Services
75.Web Services apache cxf 2.2.6
76.Web Services AXIS2
77.Wiki Engine
78.Workflow Engines
79.XML
80.XML UI
Java Source Code / Java Documentation » 6.0 JDK Core » naming » javax.naming 
javax.naming
Provides the classes and interfaces for accessing naming services.

This package defines the naming operations of the Java Naming and Directory InterfaceTM (JNDI).   JNDI provides naming and directory functionality to applications written in the Java programming language. It is designed to be independent of any specific naming or directory service implementation. Thus a variety of services--new, emerging, and already deployed ones--can be accessed in a common way.

Context

This package defines the notion of a context, represented by the Context interface. A context consists of a set of name-to-object bindings. Context is the core interface for looking up, binding, unbinding, and renaming objects, and for creating and destroying subcontexts.

lookup() is the most commonly used operation. You supply lookup() the name of the object you want to look up, and it returns the object bound to that name. For example, the following code fragment looks up a printer and sends a document to the printer object to be printed:

Printer printer = (Printer)ctx.lookup("treekiller");
printer.print(report);

Names

Every naming method in the Context interface has two overloads: one that accepts a Name argument and one that accepts a string name. Name is an interface that represents a generic name--an ordered sequence of zero of more components. For these methods, Name can be used to represent a composite name (CompositeName) so that you can name an object using a name which spans multiple namespaces.

The overloads that accept Name are useful for applications that need to manipulate names: composing them, comparing components, and so on. The overloads that accept string names are likely to be more useful for simple applications, such as those that simply read in a name and look up the corresponding object.

Bindings

The Binding class represents a name-to-object binding. It is a tuple containing the name of the bound object, the name of the object's class, and the object itself.

The Binding class is actually a subclass of NameClassPair, which consists simply of the object's name and the object's class name. The NameClassPair is useful when you only want information about the object's class and do not want to pay the extra cost of getting the object.

References

Objects are stored in naming and directory services in different ways. If an object store supports storing Java objects, it might support storing an object in its serialized form. However, some naming and directory services do not support the storing of Java objects. Furthermore, for some objects in the directory, Java programs are but one group of applications that access them. In this case, a serialized Java object might not be the most appropriate representation. JNDI defines a reference, represented by the Reference class, which contains information on how to construct a copy of the object. JNDI will attempt to turn references looked up from the directory into the Java objects they represent, so that JNDI clients have the illusion that what is stored in the directory are Java objects.

The Initial Context

In JNDI, all naming and directory operations are performed relative to a context. There are no absolute roots. Therefore JNDI defines an initial context, InitialContext, which provides a starting point for naming and directory operations. Once you have an initial context, you can use it to look up other contexts and objects.

Exceptions

JNDI defines a class hierarchy for exceptions that can be thrown in the course of performing naming and directory operations. The root of this class hierarchy is NamingException. Programs interested in dealing with a particular exception can catch the corresponding subclass of the exception. Otherwise, programs should catch NamingException.

Package Specification

The JNDI API Specification and related documents can be found in the JNDI documentation. @since 1.3
Java Source File NameTypeComment
AuthenticationException.javaClass This exception is thrown when an authentication error occurs while accessing the naming or directory service. An authentication error can happen, for example, when the credentials supplied by the user program is invalid or otherwise fails to authenticate the user to the naming/directory service.

If the program wants to handle this exception in particular, it should catch AuthenticationException explicitly before attempting to catch NamingException.

AuthenticationNotSupportedException.javaClass This exception is thrown when the particular flavor of authentication requested is not supported. For example, if the program is attempting to use strong authentication but the directory/naming supports only simple authentication, this exception would be thrown. Identification of a particular flavor of authentication is provider- and server-specific.
BinaryRefAddr.javaClass This class represents the binary form of the address of a communications end-point.

A BinaryRefAddr consists of a type that describes the communication mechanism and an opaque buffer containing the address description specific to that communication mechanism.

Binding.javaClass This class represents a name-to-object binding found in a context.

A context consists of name-to-object bindings. The Binding class represents such a binding.

CannotProceedException.javaClass This exception is thrown to indicate that the operation reached a point in the name where the operation cannot proceed any further. When performing an operation on a composite name, a naming service provider may reach a part of the name that does not belong to its namespace.
CommunicationException.javaClass This exception is thrown when the client is unable to communicate with the directory or naming service.
CompositeName.javaClass This class represents a composite name -- a sequence of component names spanning multiple namespaces. Each component is a string name from the namespace of a naming system.
CompoundName.javaClass This class represents a compound name -- a name from a hierarchical name space.
ConfigurationException.javaClass This exception is thrown when there is a configuration problem. This can arise when installation of a provider was not done correctly, or if there are configuration problems with the server, or if configuration information required to access the provider or service is malformed or missing. For example, a request to use SSL as the security protocol when the service provider software was not configured with the SSL component would cause such an exception.
Context.javaInterface This interface represents a naming context, which consists of a set of name-to-object bindings. It contains methods for examining and updating these bindings.

Names

Each name passed as an argument to a Context method is relative to that context.
ContextNotEmptyException.javaClass This exception is thrown when attempting to destroy a context that is not empty.

If the program wants to handle this exception in particular, it should catch ContextNotEmptyException explicitly before attempting to catch NamingException.

InitialContext.javaClass This class is the starting context for performing naming operations.

All naming operations are relative to a context. The initial context implements the Context interface and provides the starting point for resolution of names.

When the initial context is constructed, its environment is initialized with properties defined in the environment parameter passed to the constructor, and in any application resource files. In addition, a small number of standard JNDI properties may be specified as system properties or as applet parameters (through the use of Context.APPLET ). These special properties are listed in the field detail sections of the Context and LdapContext interface documentation.

JNDI determines each property's value by merging the values from the following two sources, in order:

  1. The first occurrence of the property from the constructor's environment parameter and (for appropriate properties) the applet parameters and system properties.
  2. The application resource files (jndi.properties).
For each property found in both of these two sources, or in more than one application resource file, the property's value is determined as follows.
InsufficientResourcesException.javaClass This exception is thrown when resources are not available to complete the requested operation.
InterruptedNamingException.javaClass This exception is thrown when the naming operation being invoked has been interrupted.
InvalidNameException.javaClass This exception indicates that the name being specified does not conform to the naming syntax of a naming system.
LimitExceededException.javaClass This exception is thrown when a method terminates abnormally due to a user or system specified limit. This is different from a InsufficientResourceException in that LimitExceededException is due to a user/system specified limit. For example, running out of memory to complete the request would be an insufficient resource.
LinkException.javaClass This exception is used to describe problems encounter while resolving links. Addition information is added to the base NamingException for pinpointing the problem with the link.
LinkLoopException.javaClass This exception is thrown when a loop was detected will attempting to resolve a link, or an implementation specific limit on link counts has been reached.
LinkRef.javaClass This class represents a Reference whose contents is a name, called the link name, that is bound to an atomic name in a context.
MalformedLinkException.javaClass This exception is thrown when a malformed link was encountered while resolving or constructing a link.
Name.javaInterface The Name interface represents a generic name -- an ordered sequence of components.
NameAlreadyBoundException.javaClass This exception is thrown by methods to indicate that a binding cannot be added because the name is already bound to another object.
NameClassPair.javaClass This class represents the object name and class name pair of a binding found in a context.

A context consists of name-to-object bindings. The NameClassPair class represents the name and the class of the bound object.

NameImpl.javaClass The implementation class for CompoundName and CompositeName.
NameNotFoundException.javaClass This exception is thrown when a component of the name cannot be resolved because it is not bound.
NameParser.javaInterface This interface is used for parsing names from a hierarchical namespace.
NamingEnumeration.javaInterface This interface is for enumerating lists returned by methods in the javax.naming and javax.naming.directory packages. It extends Enumeration to allow as exceptions to be thrown during the enumeration.

When a method such as list(), listBindings(), or search() returns a NamingEnumeration, any exceptions encountered are reserved until all results have been returned.

NamingException.javaClass This is the superclass of all exceptions thrown by operations in the Context and DirContext interfaces. The nature of the failure is described by the name of the subclass. This exception captures the information pinpointing where the operation failed, such as where resolution last proceeded to.
  • Resolved Name.
NamingSecurityException.javaClass This is the superclass of security-related exceptions thrown by operations in the Context and DirContext interfaces. The nature of the failure is described by the name of the subclass.

If the program wants to handle this exception in particular, it should catch NamingSecurityException explicitly before attempting to catch NamingException.

NoInitialContextException.javaClass This exception is thrown when no initial context implementation can be created.
NoPermissionException.javaClass This exception is thrown when attempting to perform an operation for which the client has no permission.
NotContextException.javaClass This exception is thrown when a naming operation proceeds to a point where a context is required to continue the operation, but the resolved object is not a context.
OperationNotSupportedException.javaClass This exception is thrown when a context implementation does not support the operation being invoked.
PartialResultException.javaClass This exception is thrown to indicate that the result being returned or returned so far is partial, and that the operation cannot be completed.
RefAddr.javaClass This class represents the address of a communications end-point. It consists of a type that describes the communication mechanism and an address contents determined by an RefAddr subclass.

For example, an address type could be "BSD Printer Address", which specifies that it is an address to be used with the BSD printing protocol.

Reference.javaClass This class represents a reference to an object that is found outside of the naming/directory system.

Reference provides a way of recording address information about objects which themselves are not directly bound to the naming/directory system.

A Reference consists of an ordered list of addresses and class information about the object being referenced. Each address in the list identifies a communications endpoint for the same conceptual object.

Referenceable.javaInterface This interface is implemented by an object that can provide a Reference to itself.

A Reference represents a way of recording address information about objects which themselves are not directly bound to the naming system. Such objects can implement the Referenceable interface as a way for programs that use that object to determine what its Reference is. For example, when binding a object, if an object implements the Referenceable interface, getReference() can be invoked on the object to get its Reference to use for binding.
author:
   Rosanna Lee
author:
   Scott Seligman
author:
   R.

ReferralException.javaClass This abstract class is used to represent a referral exception, which is generated in response to a referral such as that returned by LDAP v3 servers.

A service provider provides a subclass of ReferralException by providing implementations for getReferralInfo() and getReferralContext() (and appropriate constructors and/or corresponding "set" methods).

The following code sample shows how ReferralException can be used.

 while (true) {
 try {
 bindings = ctx.listBindings(name);
 while (bindings.hasMore()) {
 b = bindings.next();
 ...
 }
 break;
 } catch (ReferralException e) {
 ctx = e.getReferralContext();
 }
 }
 

ReferralException is an abstract class.

ServiceUnavailableException.javaClass This exception is thrown when attempting to communicate with a directory or naming service and that service is not available. It might be unavailable for different reasons.
SizeLimitExceededException.javaClass This exception is thrown when a method produces a result that exceeds a size-related limit.
StringRefAddr.javaClass This class represents the string form of the address of a communications end-point. It consists of a type that describes the communication mechanism and a string contents specific to that communication mechanism. The format and interpretation of the address type and the contents of the address are based on the agreement of three parties: the client that uses the address, the object/server that can be reached using the address, and the administrator or program that creates the address.

An example of a string reference address is a host name. Another example of a string reference address is a URL.

A string reference address is immutable: once created, it cannot be changed.

TimeLimitExceededException.javaClass This exception is thrown when a method does not terminate within the specified time limit.
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.