THE Java™ Programming Language, Fourth Edition

(Jeff_L) #1

The overloads that accept Name arguments 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.


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.


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


In JNDI, all naming and directory operations are performed relative to a contextthere are no absolute roots.
Therefore, JNDI defines an InitialContext class that 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.


The DirContext interface represents a directory context. It defines methods for examining and updating
attributes associated with a directory object, or directory entry as it is sometimes called. You use
getAttributes to retrieve the attributes associated with a directory object (for which you supply the
name). You can add, replace, or remove attributes and/or attribute values with the modifyAttributes
method.


DirContext also behaves as a naming context by extending the Context interface. This means that any
directory object can also provide a naming context. For example, the directory object for a person might
contain the attributes of that person, and also provide a context for naming objects relative to that person such
as printers and home directory.


DirContext contains methods for performing content-based searching of the directory. In the simplest and
most common form of usage, the application specifies a set of attributespossibly with specific valuesto match,
and submits this attribute set to the search method. Other overloads of search support more sophisticated
search filters.


The subpackage javax.naming.event supports event notification for directory and naming services.
Events include adding or removing objects, as well as events signifying changes in the stored objects
themselves.


The subpackage javax.naming.spi defines the Service Provider Interface (SPI) which allows for
dynamically plugging in support for using JNDI.


25.13. javax.sound Sound Manipulation


The javax.sound package consists only of subpackages. javax.sound.midi provides interfaces for
reading, writing, sequencing, and synthesizing data that conforms to the Musical Instrument Digital Interface
(MIDI) format. javax.sound.sampled provides classes and interfaces for capturing, processing, and
playing back digital (sampled) audio data. Each of these has a SPI subpackage to support the dynamic

Free download pdf