You are viewing a plain text version of this content. The canonical link for it is here.
Posted to api@directory.apache.org by Emmanuel Lécharny <el...@gmail.com> on 2017/03/04 07:02:03 UTC

AttriuteType/ObjectClass mutable/immutable status

Hi !

last week, while looking at the AttributeType class, I realized that it
comes with two flavors : immutable (AttributeType) and mutable
(MutableAttribuetType). The problem being that the immutable class
cannot be initialized at all, except if you just want to set its OID.

This is problematic, especially since we don't have a factory to
generate an immutable instance (remember that such object is very
unlikely to be changed).


I think there is a design issue here, and this is also true for the
ObjectClass/MutableObjectClass classes. There are some solutions :


1) Create a SchemaObject factory, that creates immutable classes.
Mutable classes can still be created directly

2) Get rid of the immutable classes, that aren't used anywhere. We
currently use the MutableAttributeType/MutableObjectClass when we parse
schema elements strings anyway.


In order to limit the visibility of setters, we could also make the
mutable class an interface, and only expose getters.


IMHO, I don't think that having immutable classes is really a must, and
it makes everything a bit too complex. We could add a factory, for the
sake of simplicity. This factory can take a schema object description (a
String) as a parameter, or a set of parameters :

    SchemaObjectFactory.create( "attributetype ( 1.2.3.4 NAME
'name0'\n\tEQUALITY matchingRule0\n\tSYNTAX
2.3.4.5{512}\n\tCOLLECTIVE\n\tUSAGE userApplications )" )


or


    SchemaObjectFactory.createAttributeType( "1.2.3.4", "matchingRule0",
"2.3.4.5{512}", TypeEnum.COLLECTIVE, UsageEnum.USER_APPLICATION, "name0" );


(you get the idea).

wdyt ?

Side note : that would be for 2.0

-- 
Emmanuel Lecharny

Symas.com
directory.apache.org