Notice that this problem calls for the use of createSubContext instead of bind. I changed that AFTER coding up this exercise.
Exercise: You have some code that gets data from a JNDI directory. The directory could be available from the test client, or it might not. The code has the following methods:
1. a constructor, which takes a DirContext object to the root of the directory. 2. getConfiguration - looks up "cn=configuration,o=myorg" in the directory, returning an Object if this object exists. If cn=configuration or o=myorg does not exist(NameNotFoundException on creation), they are created, and the resulting Object is returned.
Unrecoverable exceptions are thrown higher. Unrecoverable exceptions would be: no rights to read or write to the directory(NoPermissionException), the directory is unreachable(CommunicationException).
In the case of no rights to read or write, getConfiguration will throw a new NoPermissionException, with message explaining "no rights to create cn=configuration,o=myorg", or "no rights to read cn=configuration,o=myorg"
To do a lookup of the directory object, use lookup(String), and use createSubcontext(String, Attributes) to create the object in the directory (with null attributes??)
We went through this code in the meeting:
