Adding URL Support |
The JNDI looks for URL context factories by examining the Context.URL_PKG_PREFIXES ("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 tut.foo.fooURLContextFactory. 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:
java.naming.factory.url.pkgs=tutThe 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:tut.ldap.ldapURLContextFactory com.sun.jndi.url.ldap.ldapURLContextFactoryFrom this ordered list of class names, the JNDI will instantiate each class in turn and invoke getObjectInstance() 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.tut.foo.fooURLContextFactory com.sun.jndi.url.foo.fooURLContextFactoryAs 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 jndi.properties file that contains a setting for the Context.URL_PKG_PREFIXES property, as shown in the earlier example. See the Environment Properties lesson for more information on how the JNDI reads and merges environment properties from different sources.
Adding URL Support |