|
From: Olivier J. <oli...@pc...> - 2004-09-18 15:19:51
|
Hi, in reply to my ldap contribution proposition, here is an archive with the source code for it (I'm not sure if a diff would have been useful, as it is only new files). Sorry for the delay but I've been sick recently and couldn't make it as fast as I expected. As stated in earlier mails, there is no support for transactions at all. I tried to mimic as much as possible the jdbc implementation, in the names, javadoc and such. Obviously, there are some large differences, besides transactions. Operations in ldap aren't as homogeneous as with SQL. On a DirContext, you have different access point for creation, deletion, retrieving, ... I have provided a generic entry point in the LdapTemplate.execute which is parameterized by callback, where you implement a method which is given a DirContext which is automatically freed. The DirContext instance is taken from an implementation of ContextSource, which is similar to the DataSource in the JDBC world. It allows the LdapTemplate to be reusable as, a new DirContext is retrieved at each call. This DirContext is not only a connection to a server, but also a location inside the directory, it is thus interesting as it allows to bind a LdapTemplate to a given object via IoC (the UrlContextSource and RelativeContextSource been classical implementation parametrized by spring container). Next to the execute method, there is a couple of searching methods wrapper which takes a SearchResultCallbackHandler besides the usual arguments. This callback is then executed on each hit and a getResult method on the callback is used to make it the result of the search method. I find it interesting in terms of reduction of code needed to make most usual operations. Of course, exceptions are (normally) translated from the LDAP specific world into the generic dao ones (as soon as I'll have the class written, there is a placeholder for now). Since there are already categorized, I'm not even sure I need to offer a choice of translater as needed for JDBC. I also did a AttributeHelper class to work more easily with attribute retrieving. Nothing fancy there. I would like to know whether it is interesting enough to integrate the cvs and if the design suits you. I'm far from being the java experts who lurk on this list. I'm open to any suggestions to improve it. Best regards all Olivier |