directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Emmanuel Lecharny <>
Subject ServerEntry usage
Date Tue, 11 Dec 2007 10:43:19 GMT

I'm in the process of reimplementing the ModificationItem class. It's 
all done, but I now face some little problems with Unit tests. Nothing 
serious, but I was wondering if we can do something to alleviate the 
burden of such usage :

        Modification mod = new ServerModification( 
ModificationOperation.ADD_ATTRIBUTE );
        AttributeType cnat = new AT( SchemaConstants.CN_AT_OID );
        EntryAttribute<ServerValue<?>> entry = new BasicServerAttribute( 
cnat, "test" );
        mod.setAttribute( entry );

As you can see, I have to first create an AttributeType before being 
able to create a ServerAttribute, which is not cool (to do so, I had to 
declare a private AT class in my unitTest).  The second burden is the 
EntryAttribute declaration : EntryAttribute<ServerValue<?>> is not 
exactly the less verbose declaration we can think of ... I would prefer 
EntryAttribute instead, as an Attribute "knows" which kind of 
ServerValue it holds.

What about using a factory to create entries ? Something like :

EntryAttribute entry = EntryFactory.createEntry( "cn", "test" );

This factory will determine the AttributeType given the attribute ID and 
also determine the value type based on the attribute type HR 
characteristic. This would make the creation of entries much easier :

        Modification mod = new ServerModification( 
ModificationOperation.ADD_ATTRIBUTE );
        mod.setAttribute( EntryFactory.createntry( "cn", "test" ) );

wdyt ? Does it seems to be a good idea ?

cordialement, regards,
Emmanuel L├ęcharny

View raw message