org.objectweb.jac.aspects.integrity
Interface IntegrityConf

All Known Implementing Classes:
IntegrityAC

public interface IntegrityConf


Method Summary
 void addPostCondition(FieldItem field, MethodItem constraint, Object[] params, String errorMsg)
          Use this configuration method to add a postcondition on a object's field.
 void addPreCondition(FieldItem field, MethodItem constraint, Object[] params, String errorMsg)
          Use this configuration method to add a precondition on a object's field.
 void declareConstraint(FieldItem relation, FieldItem target, String constraint)
          Declare a referential integrity contraint.
 void declareRepository(String repositoryName, CollectionItem collection, FieldItem field)
          This method declares a repository collection.
 void updateAssociations()
          Tells that the integrity aspect should maintain integrity between the roles of associations.
 

Method Detail

updateAssociations

public void updateAssociations()
Tells that the integrity aspect should maintain integrity between the roles of associations.

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.

See Also:
RttiAC.declareAssociation(FieldItem,FieldItem)

declareRepository

public void declareRepository(String repositoryName,
                              CollectionItem collection,
                              FieldItem field)
This method declares a repository collection.

When an object is added to a relation, it will be automatically added to the collection of the repository.

Parameters:
repositoryName - the JAC object's name of the repository
collection - 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 repository

declareConstraint

public void declareConstraint(FieldItem relation,
                              FieldItem target,
                              String constraint)

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;

Parameters:
relation -
target - the collection on which checking will occur on remove, or the reference on which checking will occur when setting another value.
constraint - the type of the constraint. It may be "DELETE_CASCADE" (delete the object holding the reference on the object to be deleted), "SET_NULL" (set the reference to null, or remove the object from the collection), FORBIDDEN" (raise an exception).

addPreCondition

public void addPreCondition(FieldItem field,
                            MethodItem constraint,
                            Object[] params,
                            String errorMsg)
Use this configuration method to add a precondition on a object's field.

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 forbiddenValues or authorizedValues.

Parameters:
field - the field to constrain
constraint - the constraint method used to check the field's value
params - the parameters passed to the contraint method
errorMsg - the error message displayed if the checking has not been passed
See Also:
addPostCondition(FieldItem,MethodItem,Object[],String)

addPostCondition

public void addPostCondition(FieldItem field,
                             MethodItem constraint,
                             Object[] params,
                             String errorMsg)
Use this configuration method to add a postcondition on a object's field.

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 forbiddenValues or authorizedValues.

Parameters:
field - the field to constrain
constraint - the constraint method used to check the field's value
params - the parameters passed to the contraint method
errorMsg - the error message displayed if the checking has not been passed
See Also:
addPreCondition(FieldItem,MethodItem,Object[],String)