Java LDAP Persistence API

I’ve started a project called LDAP Persistence API for Java, or LPA for short. It is a Java framework for interacting with LDAP entries using pure Java objects. It is based on Java annotations.

It is no were near to being complete, but the query functionality is working. I still have a lot of work to do, in order to make it be able to persist existing annotated Java objects to LDAP. I’m likely to create some sort of intermediate step, until I can finish that.

A quick example of how easy it is to use, pulled directly from one of our Classes and unit tests. The following class, is a portion of our LdapOrganization Class, showing how simple it is to annotate the class to be automatically loaded from LDAP.

/**
* This file is part of the Ldap Persistence API (LPA).
*
* Copyright Trenton D. Adams
*
* LPA is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* LPA is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with LPA. If not, see .
*
* See the COPYING file for more information.
*/packageca.tnt.ldaputils.impl;importca.tnt.ldaputils.ILdapGroup;importca.tnt.ldaputils.ILdapOrganization;importca.tnt.ldaputils.annotations.LdapAttribute;importca.tnt.ldaputils.annotations.LdapEntity;importca.tnt.ldaputils.annotations.TypeHandler;importorg.apache.commons.lang.builder.CompareToBuilder;importorg.apache.commons.lang.builder.EqualsBuilder;importorg.apache.commons.lang.builder.HashCodeBuilder;importorg.apache.log4j.Logger;importjava.util.*;/**
* Implements an LDAP organization object.
*
* Created : 16-Apr-2006 10:25:36 PM MST
*
* Modified : $Date$ UTC
*
* Revision : $Revision$
*
*
* @author Trenton D. Adams
*/
@LdapEntity(requiredObjectClasses ={"organization"})publicclass LdapOrganization extends LdapEntry
implements ILdapOrganization, Comparable, TypeHandler
{privatestaticfinal Logger logger = Logger.getLogger(
LdapOrganization.class);
@LdapAttribute(name ="businessCategory", aggregateClass = LdapGroup.class,
referencedDNMethod ="getCategoryDN"/*"cn=?,ou=bus-categories,dc=example,dc=com"*/)privateSortedMap businessCategories;
@LdapAttribute(name ="telephoneNumber")privateString telephoneNumber;
@LdapAttribute(name ="facsimileTelephoneNumber")privateString facsimileTelephoneNumber;
@LdapAttribute(name ="street")privateString street;
@LdapAttribute(name ="postOfficeBox")privateString postOfficeBox;
@LdapAttribute(name ="postalAddress")privateString postalAddress;
@LdapAttribute(name ="postalCode")privateString postalCode;
@LdapAttribute(name ="l")privateString locality;
@LdapAttribute(name ="o")privateString organization;// ... getters, setters, etc.}