directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Karasulu <akaras...@apache.org>
Subject Re: API evolution
Date Wed, 11 May 2011 16:40:15 GMT
On Wed, May 11, 2011 at 7:25 PM, Emmanuel Lecharny <elecharny@gmail.com>wrote:

> Hi guys,
>
> those last three days, I made some modifications in the API following the
> discussions we has 2 weeks ago. Namely :
> 1) The 'simple' requests are not anymore returning a Response. If somethng
> went wrong, an exception will be thrown.
>
> For instance, instead of doing :
>
> BindResponse bindResponse = connection.bing( "jdoe", secret" );
>
> if ( bindResponse.getResultCode() == ResultCodeEnum.SUCCESS )
> {
>    // do something
> }
>
> we now do :
>
> try
> {
>    connection.bing( "jdoe", secret" );
> }
> catch ( LdapException le )
> {
>    // Deal with the issue
> }
>
> Note that if you do a connection.bind( BindRequest ), then you get back a
> BindResponse.
>
>
> 2) The search request is now returning a EntryCursor for 'simple' searches.
>
> The code now looks like :
>
>         EntryCursor cursor = connection.search( "ou=system",
> "(objectClass=*)", SearchScope.SUBTREE, "*" );
>
>         while ( cursor.next() )
>         {
>             Entry result = cursor.get();
>             // do something with the Entry
>
>         }
>
> instead of :
>
>         Cursor<Response>  cursor = connection.search( "ou=system",
> "(objectClass=*)", SearchScope.SUBTREE, "*" );
>
>         while ( cursor.next() )
>         {
>             Entry result = ( ( SearchResultEntry ) cursor.get()
> ).getEntry();
>             // do something with the Entry
>         }
>
> Again, using a connection.search( SearchRequest ), you get back a
> Cursor<Response>  as a result.


This looks a lot cleaner. Great job Emmanuel.

Thanks,
Alex

Mime
View raw message