![]() ![]() ![]() ![]() |
Miscellaneous |
In the Objectstrail, you saw how to store and read Java objects from the directory. Specifically, in the LDAP Directories
section, you learned how Java objects are presented as attributes in an LDAP directory. If you have not yet gone through that trail, you might want to at least read through it to understand some of the terminology before going further.
The LDAP Directories
section and RFC 2713 describe the representation of a Reference
as LDAP attributes. By default, the hash character ("#") is used to encode the RefAddr
in the Reference. If this character already appears in the contents of the RefAddr, then you need to choose another character to use. You do this by setting the "java.naming.ldap.ref.separator" environment property to a string containing the separator character. Here's an example.
If you run the reference example
, and then examine the "cn=favorite" entry in the directory, you will see the following attributes:
objectclass: top, javaContainer, javaObject, javaNamingReference javaclassname: Fruit javafactory: FruitFactory javareferenceaddress: #0#fruit#orange cn: favoriteYou can modify that example to use the colon character (":") as the separator, as follows:
The modified program produces attributes that look as follows:// Ask to use ':' as the encoding character env.put("java.naming.ldap.ref.separator", ":"); // Create the initial context DirContext ctx = new InitialDirContext(env); // Create object to be bound Fruit fruit = new Fruit("orange"); // Perform bind ctx.rebind("cn=favorite", fruit);objectclass: top, javaContainer, javaObject, javaNamingReference javaclassname: Fruit javafactory: FruitFactory javareferenceaddress: :0:fruit:orange cn: favorite
![]() ![]() ![]() ![]() |
Miscellaneous |