Martin Alderson wrote:
This sounds much more reasonable than having overloads for everything. I use
jLDAP quite a lot at work and I always shudder when I look a the javadoc for
it. It looks far more complex then it really is, with so many overloads for
each operation. Their bind operation has 12 overloads! Okay, 4 are
deprecated, but still...
I was thinking of something more along the lines of having two overloads for
every operation, one with just the required arguments and the other with an
extra Options argument which would be an object containing all options specific
to that operation. The options would include the constraints, the controls and
even the listener for non-blocking calls.
An example:
BindOptions bindOptions = new BindOptions();
bindOptions.setPassword(password);
bindOptions.setTimeLimit(10000);
bindOptions.setControls(controls);
connection.bind(userDN, bindOptions);
I like this BindOption class, it's much better than LDAPConstraints. But
I think it should be associated with the BindRequest object, to keep the
bind() method as simplest as possible. Using your sample, that would gives :
BindOptions bindOptions = new BindOptions();
bindOptions.setTimeLimit(10000);
bindOptions.setControls(controls);
BindRequest bindRequest = connection.createBindRequest();
bindRequest.setOptions( bindOptions );
bindRequest.setName( userDN );
bindRequest.setPassword( password );
connection.bind( bindRequest );
For a simple bind, it would be much simpler :
connection.bind( userDN, password );
One thing that could be done to make it easier for the user to specify these
extra arguments is to use chainable setters as popularised by jQuery (I think!)
which could give us something like:
connection.bind(userDN, new
BindOptions().setPassword(password).setTimeLimit(10000).setControls(controls));
Yuk ... Never liked it... but it may be just me ;)
--
--
cordialement, regards,
Emmanuel Lécharny
www.iktek.com
directory.apache.org