directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Emmanuel Lécharny <elecha...@gmail.com>
Subject Re: LDAP Entry implementation
Date Fri, 14 Nov 2014 16:43:28 GMT
Hi !

Le 14/11/14 14:15, cyberhawk@openmailbox.org a écrit :
> Dear Apache development team,
>
> I need your help working with the LDAP APache API. I am working on a
> big application that uses LDAP for saving/accessing useraccounts,
> groups and machines. To access LDAP I decided to use your API, because
> after testing and reading the guide and the javadocs it seemed very
> sane and flexible to me. However now I run into some problems I cannot
> explain or solve:
>
> The following code works as expected.
>
> DefaultEntry user = (DefaultEntry) ldapController.loadObject(...); //
> public Entry loadObject(...)
>
> user is now an object that is filled with attributes from the LDAP
> server and can be worked with normally.
>
> However, DefaultEntry is not sufficient for my application, I need to
> extend it. 

Can you explain why you do need to extend it ?

> Since DefaultEntry is a final class, I did the following:
>
> public interface UserLDAPInterface extends Entry {
>
> // some user-specific methods
>
> }

Ideally, what you should do is to create a class that is a proxy : it
contains an instance of the DefaultEntry class and every method of your
class route to the entry instance :

public class MyEntry impements Entry
{
    Entry realEntry;

    public void clear()
    {
        realEntry.clear();
    }

etc...

>
> public class UserLDAP implements UserLDAPInterface {
>
> // implementation of both Entry methods and UserLDAPInterface methods
>
> }
>
> Now it should have worked, however:
>
> UserLDAP user = (UserLDAP) ldapController.loadObject(...);
>
> produces a ClassCastException. 

Without your code, it's hard to tell what's going on here.

> The above example with DefaultEntry does not produce a
> ClassCastException, but works as expected. I copied all the methods
> from DefaultEntry... So really don't understand what is the issue there.

Me neither, but I don't have your code in front of my eyes, so there is
little I can do to help...


Mime
View raw message