A service providers acts as the go-between for the application and the directory when the application stores or retrieves Java objects from the directory. When you write a service provider, you need to perform this go-between role by following the rules outlined for reading objects from the directory.
The following detailed description is intended for developers writing service providers. The insight it offers into the go-between role of service providers might also interest API users.
Relevant MethodsWhen returning objects to the JNDI client application, the service provider should use the guidelines described in this section. An object can be returned by using one of the following methods:
Framework SupportA service provider should use object factories configured with the provider and application. This allows the provider to be customized to support arbitrary types of objects (for which a corresponding object factory is available).
The JNDI framework provides utility methods that service providers can use to access object factories. A provider that implements only the Context interface should use NamingManager.getObjectInstance() . A service provider that implements the DirContext interface should use DirectoryManager.getObjectInstance() . These methods interact with the object factories to produce a Java object representing the information in the directory. Which object factories are used depends on the object read from the directory. If the object is a reference, then these methods use the object factory class named in the reference. If the reference contains a URL, then these methods use the corresponding URL context factory. Otherwise, they traverse the list of object factories specified in the Context.OBJECT_FACTORIES environment property and the provider resource file and try to find a factory that yields a non-null answer. (See the Beyond the Basics trail for details about environment properties and the provider resource file.)
FederationAs explained in the Other Uses section of this lesson, object factories also play a role in federation. How a service provider uses object factories to support federation is described in the Building a Service Provider trail.