Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Applied Java™ Patterns - Stephen Stelting, Olav Maassen.pdf
Скачиваний:
202
Добавлен:
24.05.2014
Размер:
2.84 Mб
Скачать

 

Table 7-1. Packages and corresponding use

Package

Use

javax.naming

Provides the basic JNDI framework.

javax.naming.directory

Provides extensions for directory services.

javax.naming.event

Provides extensions for event handling.

javax.naming.ldap

Provides extensions to support LDAP v.3.

javax.naming.spi

Service-provider interface. It’s the core model that is extended to provide an

 

underlying service that JNDI uses.

Pattern Use

The following patterns are features of certain kinds of JNDI resources:

Factory Method (see page 21): The Factory Method pattern provides a standard method to create some product, so this pattern is typically encountered for any JNDI resource that is capable of producing a connection. This pattern is typically encountered for any JNDI resource capable of producing a connection. One of the best illustrations is the JDBC DataSource, often stored in JNDI as part of a J2EE solution. The DataSource class is actually a Factory for Connection objects enabling clients to communicate with a RDBMS.

Factory patterns are very much in evidence in the service provider interface. Underlying service implementations that are paired with JNDI require factories so that API calls can be paired to implementations that map to the

underlying service structure. The DirObjectFactory, DirStateFactory, InitialContextFactory,

ObjectFactory, and StateFactory all provide Factory Method implementations that subsequently produce concrete products which are associated with specific kinds of services.

HOPP (see page 189): Many distributed communication technologies can support division of functionality between local and remote objects, so it's no surprise that RMI, CORBA and EJB technologies are all capable of supporting a HOPP implementation. Of course, JNDI itself does not directly support or implement the pattern, but since it provides a channel for these remote objects, it aids in the distribution.

Prototype (see page 28): The JNDI architecture provides a few Prototype implementations to support the duplication of objects. In JNDI, this pattern mostly applies to lookup resources, the objects used to keep track of resource names or directory attributes:

javax.naming: Reference, Name, CompoundName, CompositeName

javax.naming.directory: BasicAttribute, Attributes, Attribute, BasicAttributes

200