directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lucas Theisen <>
Subject Re: Oid class
Date Fri, 02 Jan 2015 20:50:48 GMT
On Fri, Jan 2, 2015 at 10:58 AM, Kiran Ayyagari <>

> On Fri, Jan 2, 2015 at 11:19 PM, Lucas Theisen <>
> wrote:
>> I was thinking about optimizing Oid...  The Oid class represents OID
>> values.  There is a relatively small finite set of OID values.  I was
>> thinking we could get rid of the constructors and use factory methods
>> instead.  One for getting an Oid by String and one by byte[].  I would then
>> remove the setters, do the conversion to byte[]/String at construction
>> time, store both values, and change getOid to return a copy of the byte[]
>> to make it immutable.  Then, the first time an Oid is requested, it would
>> be constructed, and every following request would get the same object.
>> This would make comparisons faster and remove conversion time altogether
>> (other than the first request).
>> The main problem of doing this is that the current methods/constructors
>> are public so there is no telling if anybody is using them other than us.
>> Also, they would all remain in memory (though given the relatively small
>> number and their small size it should be relatively negligible).
>> My current reason for wanting to do this is i need to check all extended
>> requests to see if they are startTLS
> you mean if the request issues by client is a StartTLS request or not?
> where do you intend to intercept these
> requests?

I would wrap the LdapConnection class and override all (4) of the extended
methods and check the oid:

        public ExtendedResponse extended( Oid oid ) throws LdapException
            if ( StartTlsRequest.EXTENSION_OID_OBJECT.equals( oid ) ) {
                startTlsCalled = true;
            return connection.extended( oid );

then i would know if a startTLS was requested so i can unbind/rebind the
connection before returning it to the pool.

requests.  In order to do that, I have to wrap the connection and intercept
>> the exteneded function and check the oid.  In the case where an OID object
>> is supplied i need to verify it so I have to either construct an OID and
>> use equals, or toString the oid and do a string compare.  Both would have
>> cost.
>> This is almost certainly a premature optimization, but sometimes you just
>> feel like doing things as efficiently as you can think...
>> What do you think?
> --
> Kiran Ayyagari

View raw message