|
JAC project AOPSYS CEDRIC & LIP6 labs |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.objectweb.jac.core.AspectComponent | +--org.objectweb.jac.aspects.integrity.IntegrityAC
This aspect handle different kinds of data integrity among objects sets.
Field Summary | |
static String |
CONSTRAINTS
|
static String |
DISABLE_ADD_TO_REPOSITORY
|
Fields inherited from class org.objectweb.jac.core.AspectComponent |
application, blockKeywords, firstCall, NOT_SHARED, SHARED, startWeavingCCount, startWeavingCount, startWeavingMethod, startWeavingType, systemListener, wrappers |
Fields inherited from interface org.objectweb.jac.core.BaseProgramListener |
FOUND_OBJECT |
Constructor Summary | |
IntegrityAC()
|
Method Summary | |
void |
addPostCondition(ClassItem cl,
String fieldName,
MethodItem constraint,
Object[] params,
String errorMsg)
Use this configuration method to add a postcondition on a object's field. |
void |
addPreCondition(ClassItem cl,
String fieldName,
MethodItem constraint,
Object[] params,
String errorMsg)
Use this configuration method to add a precondition on a object's field. |
void |
declareAssociation(ClassItem classA,
String fieldNameA,
ClassItem classB,
String fieldNameB)
Declares an association made of two roles. |
void |
declareConstraint(ClassItem cl,
String relationName,
FieldItem target,
String constraint)
Declare a referential integrity contraint. |
void |
declareDirectionalAssociation(ClassItem classA,
String fieldNameA,
ClassItem classB,
String fieldNameB)
Same as declareAssociation but integrity will only take place when the field of classA is modified. |
void |
declareRepository(String repositoryName,
CollectionItem collection,
FieldItem field)
This method declares a repository collection. |
protected void |
doCheck()
Activates constraints checking. |
void |
whenConfigured()
This method should be defined by the programmer when specific actions are needed once the aspect component has be configured. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final String CONSTRAINTS
public static final String DISABLE_ADD_TO_REPOSITORY
Constructor Detail |
public IntegrityAC()
Method Detail |
public void declareAssociation(ClassItem classA, String fieldNameA, ClassItem classB, String fieldNameB)
IntegrityConf
When declared, the relations that constitutes the
association's roles are tagged in the RTTI by the
RttiAC.OPPOSITE_RELATION
attribute (then they can
be interpreted by other aspects such as GUI or Persistence).
If two relations are declared to constitue an association, modifications on one relation should be reflected in the other.
For instance, if you have a Customer class and an Order class:
,----------. 1 n ,-------. | Customer |--------| Order | `----------' `-------'
You can declare an association made of Cutomer.orders and Order.customer, so that setting the cutomer of an order will automatically add this order in the customer's list of orders. And vice-versa.
declareAssociation
in interface IntegrityConf
classA
- the starting class (e.g. Customer)fieldNameA
- the starting role (e.g. orders)classB
- the ending class (e.g. Order)fieldNameB
- the ending role (e.g. customer)IntegrityConf.declareDirectionalAssociation(ClassItem,String,ClassItem,String)
public void declareDirectionalAssociation(ClassItem classA, String fieldNameA, ClassItem classB, String fieldNameB)
IntegrityConf
Same as declareAssociation but integrity will only take place when the field of classA is modified. This is useful in the situation where two roles on one entity are associated with te same role on an other entity:
start ,----------. 1 n ,-------. | Relation |----+----| Class | `-----+----' | `-------' end 1`---------'
In the exemple shown above, if you do aClass.addRelation(aRelation), you cannot tell if the opposite role to update is end or start.
declareDirectionalAssociation
in interface IntegrityConf
classA
- the starting class (e.g. Customer)fieldNameA
- the starting role (e.g. orders)classB
- the ending class (e.g. Order)fieldNameB
- the ending role (e.g. customer)IntegrityConf.declareAssociation(ClassItem,String,ClassItem,String)
public void declareRepository(String repositoryName, CollectionItem collection, FieldItem field)
IntegrityConf
When an object is added to a relation, it will be automatically added to the collection of the repository.
declareRepository
in interface IntegrityConf
repositoryName
- the JAC object's name of the repositorycollection
- the collection to add into (on the instance
given as the first parameter)field
- objects that are set or added to this field are
added to the repositorypublic void declareConstraint(ClassItem cl, String relationName, FieldItem target, String constraint)
IntegrityConf
Declare a referential integrity contraint.
When an object is removed from the target collection, it will be checked wether it can be allowed.
Suppose you have Customer class and an Invoice class :
,-----------. 1 * ,----------. 1 * ,---------. | Customers |-------| Customer |-----------| Invoice | `-----------' `----------' `---------'
You do not want to allow the removal of a customer from the Customers repository if there are invoices for that customer. So you would add the following constraint:
declareConstraint Invoice customer Customers.customers FORBIDDEN;
declareConstraint
in interface IntegrityConf
cl
- relationName
- target
- the collection on which checking will occur on
remove, or the reference on which checking will occur when
setting another value.public void addPostCondition(ClassItem cl, String fieldName, MethodItem constraint, Object[] params, String errorMsg)
IntegrityConf
It means that the final value of the field will be tested with the added constraint and if it is not valid, it will be rejected.
Constraint methods must return a Boolean that is Boolean.TRUE
if the test has been validated (passed), Boolean.FALSE else. The
class org.objectweb.jac.aspects.integrity.GenericConditions
contains basic tests such as fordiddenValues
or
authorizedValues
.
addPostCondition
in interface IntegrityConf
cl
- the class that contains the fieldfieldName
- the field to constrainconstraint
- the constraint method used to check the
field's valueparams
- the parameters passed to the contraint methoderrorMsg
- the error message displayed if the checking has
not been passedIntegrityConf.addPreCondition(ClassItem,String,MethodItem,Object[],String)
public void addPreCondition(ClassItem cl, String fieldName, MethodItem constraint, Object[] params, String errorMsg)
IntegrityConf
It means that the initial value of the field will be tested with the added constraint and if it is not valid, it will be rejected.
Constraint methods must return a Boolean that is Boolean.TRUE
if the test has been validated (passed), Boolean.FALSE else. The
class org.objectweb.jac.aspects.integrity.GenericConditions
contains basic tests such as fordiddenValues
or
authorizedValues
.
addPreCondition
in interface IntegrityConf
cl
- the class that contains the fieldfieldName
- the field to constrainconstraint
- the constraint method used to check the
field's valueparams
- the parameters passed to the contraint methoderrorMsg
- the error message displayed if the checking has
not been passedIntegrityConf.addPostCondition(ClassItem,String,MethodItem,Object[],String)
protected void doCheck()
This method must be called once after all calls to
addPreCondition
and addPostCondition
to effectively add pointcuts for these methods.
addPreCondition(ClassItem,String,MethodItem,Object[],String)
,
addPostCondition(ClassItem,String,MethodItem,Object[],String)
public void whenConfigured()
AspectComponent
whenConfigured
in class AspectComponent
|
Contact JAC development team: Renaud Pawlak Lionel Seinturier Laurent Martelli |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |