Previous | Next | Trail Map | Building a Service Provider | Adding URL Support

Making the Implementation Available

The JNDI looks for URL context factories by examining the Context.URL_PKG_PREFIXES(in the API reference documentation) ("java.naming.factory.url.pkgs") environment property. This property contains a colon-separated list of package prefixes of the class names for the URL context factories. The prefix "com.sun.jndi.url" is always appended to the possibly empty list of package prefixes.

In the foo URL example, the factory's fully qualified class name is Therefore, to include this factory in the list of URL context factories that the JNDI knows about, you set the Context.URL_PKG_PREFIXES property as follows:


The JNDI looks for a URL context factory based on its URL scheme id. Suppose that the JNDI is looking for a factory for the ldap URL scheme. It would look for the following classes:

Similarly, with the same property setting, the JNDI would look for the following classes for the foo URL scheme:
From this ordered list of class names, the JNDI will instantiate each class in turn and invoke getObjectInstance()(in the API reference documentation) on it until one class returns a non-null answer. The non-null answer becomes the URL context implementation that will be used for that URL scheme.

As a service provider developer, you typically package the components of your service provider (the context implementation for the naming/directory, URL context factory, and URL context implementation) into an archive (JAR) file. To make the URL context factory automatically available to any program that uses this JAR file, you should include in it a file that contains a setting for the Context.URL_PKG_PREFIXES property, as shown in the earlier example. See the Environment Properties (in the Beyond the Basics trail) lesson for more information on how the JNDI reads and merges environment properties from different sources.

Previous | Next | Trail Map | Building a Service Provider | Adding URL Support