Interface Lifecycle

All Known Implementing Classes:
BaseLifecycle, ClassInvariantLifecycle, PostconditionLifecycle, PreconditionLifecycle

public interface Lifecycle

Specifies life-cycle hook-ins for applying AST transformation logic before and after the annotation processors have been run.

During execution of GContracts AST transformations, the following process is applied on each ClassNode instance which qualifies for contract annotations:

  1. Generation of closure classes.
  2. Handling of AnnotationProcessor implementation classes
  3. Domain Model Conversion and Injection

Generation of closure classes

In order to support Groovy 1.7.x GContracts backported Groovy 1.8 handling of annotation closures. This is done by extracting ClosureExpression from annotations and creating Closure implementation classes.

Handling of AnnotationProcessor implementation classes

AnnotationProcessor implementations are used to modify domain classes found in org.apache.groovy.contracts.domain. For that reason, concrete annotation processor often don't modify AST nodes directly, but simply work with domain classes like Contract. Whenever an annotation processor is done, it has finished its work on the underlying domain model.

beforeProcessingClassNode(ProcessingContextInformation, org.codehaus.groovy.ast.ClassNode), beforeProcessingMethodNode(ProcessingContextInformation, org.codehaus.groovy.ast.ClassNode, org.codehaus.groovy.ast.MethodNode), beforeProcessingConstructorNode(ProcessingContextInformation, org.codehaus.groovy.ast.ClassNode, org.codehaus.groovy.ast.MethodNode) are fired before annotation processors are executed.

Domain Model Conversion and Injection

Takes a look at the domain model instances and generates the corresponding AST transformation code.

afterProcessingClassNode(ProcessingContextInformation, org.codehaus.groovy.ast.ClassNode), afterProcessingMethodNode(ProcessingContextInformation, org.codehaus.groovy.ast.ClassNode, org.codehaus.groovy.ast.MethodNode), afterProcessingConstructorNode(ProcessingContextInformation, org.codehaus.groovy.ast.ClassNode, org.codehaus.groovy.ast.MethodNode) are fired after domain model conversion and injection is done.