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:This article explains how to extend Spring-LDAP with an iBATIS-style XML Data Mapper to access LDAP data through intuitive JavaBean operations.
- 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.
-
Extending Spring LDAP with an iBATIS- style XML Data Mapper (10 messages)
- Posted by: Joseph Ottinger
- Posted on: May 20 2008 11:29 EDT
"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.Threaded Messages (10)
- Re: Extending Spring LDAP with an iBATIS- style XML Data Mapper by ^C^ ^C^ on May 20 2008 13:47 EDT
- Re: Extending Spring LDAP with an iBATIS- style XML Data Mapper by Colin Lu on May 20 2008 21:06 EDT
- Re: Extending Spring LDAP with an iBATIS- style XML Data Mapper by ^C^ ^C^ on May 21 2008 01:35 EDT
- Re: Extending Spring LDAP with an iBATIS- style XML Data Mapper by Erik Bengtson on May 21 2008 03:19 EDT
- Re: Extending Spring LDAP with an iBATIS- style XML Data Mapper by Colin Lu on May 20 2008 21:06 EDT
- jar link by Gerard Fisher on May 22 2008 12:48 EDT
- Re: jar link by Chun Lu on May 22 2008 14:39 EDT
- RAR Download by Gerard Fisher on May 26 2008 10:42 EDT
- Re: jar link by Chun Lu on May 22 2008 14:39 EDT
- Souce code download by Colin Lu on June 02 2008 15:54 EDT
- Broken Link by Kedar Ambardekar on April 29 2009 08:37 EDT
- Attribute Filters? by Vinodh J on December 05 2008 13:03 EST
-
Re: Extending Spring LDAP with an iBATIS- style XML Data Mapper[ Go to top ]
- Posted by: ^C^ ^C^
- Posted on: May 20 2008 13:47 EDT
- in response to Joseph Ottinger
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 -
Re: Extending Spring LDAP with an iBATIS- style XML Data Mapper[ Go to top ]
- Posted by: Colin Lu
- Posted on: May 20 2008 21:06 EDT
- in response to ^C^ ^C^
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 -
Re: Extending Spring LDAP with an iBATIS- style XML Data Mapper[ Go to top ]
- Posted by: ^C^ ^C^
- Posted on: May 21 2008 01:35 EDT
- in response to Colin Lu
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 -
Re: Extending Spring LDAP with an iBATIS- style XML Data Mapper[ Go to top ]
- Posted by: Erik Bengtson
- Posted on: May 21 2008 03:19 EDT
- in response to Colin Lu
1. How does DataNucleus support ORM between Java object and LDAP 'objectClass'?
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.
2. Does DataNucleus support 1-N relationship model for LDAP entries? -
jar link[ Go to top ]
- Posted by: Gerard Fisher
- Posted on: May 22 2008 12:48 EDT
- in response to Joseph Ottinger
The link to XML Data Map Engine that you gave is not working. -
Re: jar link[ Go to top ]
- Posted by: Chun Lu
- Posted on: May 22 2008 14:39 EDT
- in response to Gerard Fisher
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 -
RAR Download[ Go to top ]
- Posted by: Gerard Fisher
- Posted on: May 26 2008 10:42 EDT
- in response to Chun Lu
Colin, Thank you. I've downloaded and extracted the contents. I shall try it in my application this week. -
Souce code download[ Go to top ]
- Posted by: Colin Lu
- Posted on: June 02 2008 15:54 EDT
- in response to Joseph Ottinger
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 -
Broken Link[ Go to top ]
- Posted by: Kedar Ambardekar
- Posted on: April 29 2009 08:37 EDT
- in response to Colin Lu
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/- -
Attribute Filters?[ Go to top ]
- Posted by: Vinodh J
- Posted on: December 05 2008 13:03 EST
- in response to Joseph Ottinger
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...