Each directory is a sub-context which is accessed as a path. Directories are branch nodes that each contain a .bindings as their leaf node. Each branch can have exactly one leaf and zero or more additional branches.
How you do this depends on the tool you are using. I can provide examples from WebSphere MQ's JMSAdmin tool but others will have slightly (or wildly) different syntax. Since Sun's FSContext is used in both our examples, the context traversal works the same although our administrative tools may differ in syntax.
Using JMSAdmin you can DEFINE CTX(subcontext_name)
and this creates a directory under which will reside a .bindings file. You can then CHANGE CTX(subcontext_name)
to make that subcontext the current one. Anything you define will now be in the .bindings file within that subcontext.
In your code you refer to the subcontext as a path. For example, after opening the initial context you can lookup an object as subcontext_name/foo
.
There's more on the IBM implementation of this in the WebSphere MQ Using Java manual under Manipulating Subcontexts. Although the syntax may differ from what you are using, the tool is JMS compliant and uses com.sun.jndi.fscontext.RefFSContextFactory
so the principles will be the same.