![]() ![]() ![]() ![]() |
URLs |
Federation is the process of "hooking" together naming systems so that the aggregate can process composite names--names that span the naming systems. One basic means by which you hook together two naming systems is to bind the reference of one naming system into a context in another naming system. The Storing Objects in the Directorylesson contains descriptions of the Reference
class and how to store and read references from the directory.
Although the contents of a reference used for federation is unrestricted, one useful and common type of reference is one that contains a URL string. You can create a Reference for a URL string by creating a StringRefAddr
whose type is "URL" and whose contents is the URL string. Here is an example of a reference to a file system context:
You can then bind this reference into another naming system, such as the LDAP:// Create the file system reference Reference fsRef = new Reference("javax.naming.Context", new StringRefAddr("URL", "file:/tmp"));The LDAP and file system are now federated: you can supply a name to the LDAP service provider that spans into the file system:ldapCtx.bind("cn=fs", fsRef);Although the name cn=fs is in the LDAP naming system, it is effectively naming an object in the file system--the object named by the URL string file:/tmp.Object obj = ldapCtx.lookup("cn=fs/tutorial/report.txt");When the LDAP service provider processes the cn=fs entry, it will ask the JNDI to return the context identified by the cn=fs entry so that it can continue the operation. The service provider does this by using the NamingManager.getContinuationContext()
and DirectoryManager.getContinuationDirContext()
methods, which are explained in the Building a Service Provider
trail. The JNDI, when given a reference that contains a "URL" StringRefAddr and no factory class name, will turn the URL string in the reference into a context using the same algorithm used for locating a URL context implementation, as explained in the Initial Context section of this lesson. In the above example, the JNDI uses the file URL context implementation to process the URL string file:/tmp. It then uses the resulting context to process the remainder of the name, tutorial/report.txt.
![]() ![]() ![]() ![]() |
URLs |