Discussions

News: Extending Spring LDAP with an iBATIS- style XML Data Mapper

  1. "Extending Spring LDAP with an iBATIS-style XML Data Mapper" by Colin Lu explains how to use Spring's LDAP integration with an XML data mapper to make LDAP access from within Spring trivial.
    If you have ever used Spring-LDAP, you may be impressed by its simple Java API of accessing data in LDAP. Spring-LDAP is built on the pattern of Spring’s LdapTemplate, which relieves user from JNDI programming, LDAP Context managing, and the transaction management. In addition, it provides easier data manipulating using JavaBean and DAO pattern. However, there are two main downsides to this mechanism:
    • First, it requires writing Java code to implement the mappings between JavaBean object and LDAP entry. This leads to the unpleasant situation of tight coupling between your Java application and LDAP schema.
    • Furthermore, it lacks an easy way to manipulate an LDAP hierarchical sub-tree (LDAP entry and its children) with a single JavaBean object.
    This article explains how to extend Spring-LDAP with an iBATIS-style XML Data Mapper to access LDAP data through intuitive JavaBean operations.

    Threaded Messages (10)

  2. This article explains how to extend Spring-LDAP with an iBATIS-style XML Data Mapper to access LDAP data through intuitive JavaBean operations.
    Intersting article. Of course it does impose a dependency on Spring-LDAP. An alternative, using no proprietary API would be to access (and persist) your data in LDAP using standardised JDO/JPA APIs using DataNucleus Access Platform --Andy DataNucleus
  3. Hi Andy, Access LDAP data with a standard JDO/JPA API is a very good solution. My XML dta mapper not only hides the Spring LDAP API from developer, but also supports JavaBean nest properties with mapped recursive operations (i.e. JDO 1-N relationships). Since I cannot find an extensive LDAP data access example of DataNucleus, so I have following questions: 1. How does DataNucleus support ORM between Java object and LDAP 'objectClass'? 2. Does DataNucleus support 1-N relationship model for LDAP entries? I guess DataNucleus only have a limited JDO support for LDAP data access so far. Thanks, Colin
  4. Hi Colin, yes I noticed that you hide Spring details from the user, which is a good thing. DataNucleus does support 1-N collection relations (but not Map). As for a specific example you'd have to look in our SVN (under test/test.jdo.ldap/trunk). As you guessed, support for LDAP is not considered "complete", but currently provides basic persistence of objects, 1-1, 1-N, and simple JDOQL querying - see the Wiki. All contributions welcome :-) Regards --Andy DataNucleus
  5. 1. How does DataNucleus support ORM between Java object and LDAP 'objectClass'?
    2. Does DataNucleus support 1-N relationship model for LDAP entries?
    Colin, you can read a metadata mapping file: https://datanucleus.svn.sourceforge.net/svnroot/datanucleus/test/test.jdo.ldap/trunk/src/resources/org/jpox/samples/directory/package.jdo I don't have an example of JPA or annotations mapping but should be similar.
  6. jar link[ Go to top ]

    The link to XML Data Map Engine that you gave is not working.
  7. Re: jar link[ Go to top ]

    Hi Gerard, I just tested with the link, it works. You have two options to run the engine. A. From IDE (e.g. eclipse, JBuilder, etc.) 1. Download the spring-ldap-xml-datamapper.rar from the link, and save to your local folder. 2. Extract the .rar file to somewhere. 3. User your IDE (e.g. eclipse) to create a java project, load the sample source files and all jar files from dist/ and lib/ 4. Configure ldap.properties under src\com\ldapmapper\sample to provide correct parameters for your LDAP connection 5. Build your project 6. Run the client file (e.g. CreateCompanyClient) from IDE B. Run by a bat file as below: 1. follow step 1-5 as option A. 2. Copy the compiled .class files to somewhere. In my sample, it is '%TEST_HOME%\classes' 3. Run the test.bat set _JAVACMD=%JAVACMD% set TEST_HOME=C:\papers\test\sample if "%JAVA_HOME%" == "" set JAVA_HOME=C:\bea816\jdk142_11 set _JAVACMD=%JAVA_HOME%\bin\java.exe if not exist "%JAVA_HOME%\bin\java.exe" set _JAVACMD=java.exe set SYSTEM_LIBPATH=%TEST_HOME%\classes set SYSTEM_LIBPATH=%SYSTEM_LIBPATH%;C:\papers\test\sample\dist\spring-ldap-xml-datamapper.jar set SYSTEM_LIBPATH=%SYSTEM_LIBPATH%;C:\papers\test\sample\lib\aopalliance.jar set SYSTEM_LIBPATH=%SYSTEM_LIBPATH%;C:\papers\test\sample\lib\commons-beanutils.jar set SYSTEM_LIBPATH=%SYSTEM_LIBPATH%;C:\papers\test\sample\lib\commons-collections.jar set SYSTEM_LIBPATH=%SYSTEM_LIBPATH%;C:\papers\test\sample\lib\commons-lang.jar set SYSTEM_LIBPATH=%SYSTEM_LIBPATH%;C:\papers\test\sample\lib\commons-logging.jar set SYSTEM_LIBPATH=%SYSTEM_LIBPATH%;C:\papers\test\sample\lib\commons-pool.jar set SYSTEM_LIBPATH=%SYSTEM_LIBPATH%;C:\papers\test\sample\lib\ldapbp.jar set SYSTEM_LIBPATH=%SYSTEM_LIBPATH%;C:\papers\test\sample\lib\log4j-1.2.14.jar set SYSTEM_LIBPATH=%SYSTEM_LIBPATH%;C:\papers\test\sample\lib\spring-ldap-1.2.1.jar set SYSTEM_LIBPATH=%SYSTEM_LIBPATH%;C:\papers\test\sample\lib\spring.jar set SYSTEM_LIBPATH=%SYSTEM_LIBPATH%;C:\papers\test\sample\lib\xpp3_min-1.1.3.4.O.jar set SYSTEM_LIBPATH=%SYSTEM_LIBPATH%;C:\papers\test\sample\lib\xstream-1.2.2.jar "%_JAVACMD%" -classpath "%SYSTEM_LIBPATH%" com.ldapmapper.sample.client.CreateCompanyClient Hope it helps. Colin
  8. RAR Download[ Go to top ]

    Colin, Thank you. I've downloaded and extracted the contents. I shall try it in my application this week.
  9. Souce code download[ Go to top ]

    I have got several requests for source code of the data mapper engine. Here is the link: http://cid-8ae608a3a35448f3.skydrive.live.com/self.aspx/Public/articles/spring-ldap-xml-datamapper-src.rar Colin
  10. Broken Link[ Go to top ]

    Hi, I was not able to find the source code at the specified location. Can you please please post the source code again. Thanks Kedar/-
  11. Attribute Filters?[ Go to top ]

    Colin, Thanks for this library, it certainly is useful. I had a request - could you enhance the search API to support Attribute Filters? Spring LDAP has this API: public java.util.List search(javax.naming.Name base, java.lang.String filter, int searchScope, java.lang.String[] attrs, AttributesMapper mapper) This is useful for performance reasons when you don't necessarily want to retrieve all attributes...