Creating the Change Handler Class
A Business Entity may have more than one Change Handler. The framework will call each handler associated with an entity when an attempt is made to modify the state of the underlying entity. The following are the important parts of a Change Handler class:
- The class should extend the AbstractChangeHandler class and have a class name ending with "_CHandler".
- The @ChangeHandler class annotation. This tells the framework which entity to attach the change handler to at runtime.
- Implement any "handle" methods. These are methods that can implement any cascading effects of the proposed change to the entity's state.
- Construct Validation Rules that are returned by public static methods on the change handler class. There should be one static method per rule. The reason for exposing these methods is to facilitate testing (see below). Static methods are used instead of static variables to prevent timing problems associated with the static initialization of static variables.
- Return an array of the rules created above via the getValidationRules() method. The framework invokes this method at runtime to retrieve the rules.
- Make sure to run the artifact generator and rebuild source code after adding a Change Handler or modifying its annotation.