Miscellaneous
Storing Objects
The Java Objects and the Directory trail showed you how to store and read Java objects from the directory. Specifically, the LDAP Directories section discussed how Java objects are represented as attributes in an LDAP directory. If you have not yet gone through that trail, then before going further you might want to at least read through that trail to understand some of the terminology used here.The LDAP Directories section and RFC 2713 describe the representation of a Reference as multiple 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 use another character. 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 this example to use the colon character (":") as the separator, as follows.
The modified program produces the following attributes.// Ask to use ":" as the encoding character env.put("java.naming.ldap.ref.separator", ":"); // Create the initial context DirContext ctx = new InitialDirContext(env); // Create the object to be bound Fruit fruit = new Fruit("orange"); // Perform the bind ctx.rebind("cn=favorite", fruit);objectclass: top, javaContainer, javaObject, javaNamingReference javaclassname: Fruit javafactory: FruitFactory javareferenceaddress: :0:fruit:orange cn: favorite