JNDI, Context.OBJECT_FACTORIES, and subclasses

S

Steve Nakhla

I'm trying to learn more about JNDI and LDAP by writing a simple
little program to create users in an LDAP directory. However, I'd
ideally like to be able to create users and subclasses of users using
DirObjectFactory objects.

For example, in OpenLDAP I can create a "person", or a "inetOrgPerson"
which is a subclass of "person". I've created 2 objects: Person,
which implements DirContext; and, InetOrgPerson which extends Person.
My problem comes when trying to do a lookup on the objects I've just
created. I've noticed if I put the InetOrgPersonFactory first in
Context.OBJECT_FACTORIES, it is able to read an InetOrgPerson object
with no problem. But, if I put PersonFactory first the cast fails.
Obviously, it is because it is using the PersonFactory to create the
object instead of the InetOrgPersonFactory.

My question is, what is the best way to handle these object factories
so that subclasses are created by the appropriate factory, and not by
the super class's factory? Is there a good strategy to use? Any
thoughts?

Steve
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,539
Members
45,024
Latest member
ARDU_PROgrammER

Latest Threads

Top