|
From: Mattias A. <mat...@ja...> - 2007-01-08 08:45:23
|
Looks interesting. I'm sure it could be quite useful and would love to know more about the tool.
Cheers,
Mattias Arthursson
Spring LDAP Team
2007-01-08 Jasper Blues wrote:
Hello Spring Developers,
>
>Especially Spring-ldap developers may be interested in this post: I'veimplemented an "Object Directory Mapping" tool (not the one that comesup when you do a google search) based on ContextMapper &ContextAssembler that uses annotations on a Directory Entity. Forexample:
>
>@NamingAttribute("uid")
>@NamingSuffix({"ou=people"})
>@ObjectClasses({"top", "person", "organizationalPerson","inetorgperson"})
>public class TestPerson
>{
>/*********************************** Directory mapped fields************************************/
>@DirAttribute("uid")
>private String identifier;
>
>@DirAttribute("sn")
>private String lastName;
>
>@DirAttribute("givenName")
>private String givenName;
>
>@DirAttribute("cn")
>private String fullName;
>
>@DirAttribute("mail")
>private String emailAddress;
>
>@DirAttribute("userpassword")
>private byte[] password;
>
>@DirAttribute("active")
>private Boolean isActive;
>
>@DirAttribute("registrationDate")
>private Date registrationDate;
>
>@DirAttribute("rating")
>private Long rating;
>
>/************************************************************************************************/
>
>The interface for the DAOimplementation is as follows:
>
>public interface LdapDao
>{
>void create(Object dirObject);
>
>void update(Object dirObject);
>
>void delete(Object dirObject);
>
>Object findByNamingAttribute(String namingValue, Class returnType);
>
>public Object findByDn(Name dn, Class returnType);
>
>void createOrUpdate(Object dirObject);
>
>List findAll(Class ofType);
>
>List filterByBeanProperty(String value, String beanPropertyName,Class returnType);
>}
>
>Type translation is based onSpring's own BeanPropertyEditors with custom editors registered forGeneralizedTime and DistinguishedName.
>
>There is also support for for loading referenced entries. Ie a RoleObject containing a Person[] members field will populated / updated.
>
>public class TestRole
>{
>/*********************************** Directory mapped fields************************************/
>@DirAttribute("cn")
>private String roleName;
>
>@DirAttribute
>private String description;
>
>@DirAttribute("roleOccupant")
>private TestPerson[] members;
>
>/******************************
>}
>
>The whole thing ways in atjust 18 small class files, a few hundred lines of code and it's veryfast. I'm not sure if this is useful to more people than just myself,but if you'd like to know more, let me know.
>
>Best Regards,
>Jasper
>
>
>
>
>
>
>
>
>
>
>
> |