[ 
https://issues.apache.org/jira/browse/DIRSERVER-858?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12478354
 ] 

Emmanuel Lecharny commented on DIRSERVER-858:
---------------------------------------------

Parsing a DN is a pretty fast operation : on my desktop (pentium 3Ghz), I can 
parse 120 000 dc=example, dc=com DN per second. 

Your example is not correct. I assume it will work for "dc=example, dc=com" if 
you do a 
bytes = StringTools.getBytesUtf8(dn); 
but if you have a DN like : sn=lécharny, dc=example, dc=com, it's simply not 
enough. The 'é'  should be handled and escaped, and this is what the parser is 
doing.

Last point : LdapDN is not intended to be used out of the server.

However, if you propose a patch, we may consider to apply it. Don't forget to 
propose a patch for 1.0 and 1.5 version.

> Allow subclassing LdapDN
> ------------------------
>
>                 Key: DIRSERVER-858
>                 URL: https://issues.apache.org/jira/browse/DIRSERVER-858
>             Project: Directory ApacheDS
>          Issue Type: Improvement
>          Components: ldap
>    Affects Versions: 1.0.1, 1.5.0
>            Reporter: Endi S. Dewata
>
> Currently when you create an LdapDN object from a given DN string the code 
> will always parse the string into its RDN components.
>     LdapDN dn = new LdapDN("dc=example,dc=com");
> The parsing code, however, depending on your application, could take up to 5% 
> of the time.
> For applications that require high performance, it would be great if we could 
> create a subclass of LdapDN that will bypass the DN parsing code, or lazily 
> parse the DN only when needed. See the following code:
>     LdapDN dn = new MyLdapDN("dc=example,dc=com");
>     SearchResponseEntry response = new 
> SearchResponseEntryImpl(request.getMessageId());
>     response.setObjectName(dn);
>     response.setAttributes(attributes);
> The MyLdapDN class would be very simple:
>     public class MyLdapDN extends LdapDN {
>         public MyLdapDN(String dn) throws Exception {
>             bytes = StringTools.getBytesUtf8(dn);
>         }
>     }
> Unfortunately this code is currently doesn't work because the the "bytes" 
> field of LdapDN is private and the LdapDN.getNbBytes() and LdapDN.getBytes() 
> methods require direct access to the field.
> The solution is simple, here are some alternatives:
> 1. Change the field access to protected.
> 2. Add LdapDN.setBytes() method.
> 3. Add LdapDN.getBytes() that can be overridden by the subclass, and change 
> the LdapDN.getNbBytes() and LdapDN.getBytes() to call this method.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to