You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@directory.apache.org by Emmanuel Lecharny <el...@gmail.com> on 2007/12/11 11:43:19 UTC

ServerEntry usage

Hi,

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
www.iktek.com
directory.apache.org