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
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