NetUI Compiler


The NetUI compiler layer consists of annotation processors for the following types of files:

Annotation processing runs under both apt and XDoclet, although apt (processing true Java 5 annotations) is currently the only supported tool.

The architecture involves several layers:


typesystem in compiler-core

The typesystem looks very much like Sun's Mirror interfaces. It contains the following sets of interfaces:

processor in compiler-core

The main annotation processors here are PageFlowAnnotationProcessor and FormBeanAnnotationProcessor. Each one kicks off the appropriate checker for the class declaration that is being processed. PageFlowAnnotationProcessor chooses the checker (e.g., PageFlowChecker) based on the class-level annotation (e.g., @Jpf.Controller) and the base class for the one being processed (e.g., PageFlowController).

Each checker (all extend BaseChecker) is the starting point for checking the class, which mostly consists of delegating to the right annotation grammar(s) for the class, and for each method as appropriate.

grammar in compiler-core

The classes here extend AnnotationGrammar, to provide rules for annotations, and AnnotationMemberType, to provide rules for attributes (members) in annotations. For example, ActionGrammar provides rules for the @Jpf.Action annotation, and JavaIdentifierType provides checking for an annotation attribute that must be a valid Java identifier, like returnAction on @Jpf.Forward.

In general, annotation grammars provide five main things, which are used by the base AnnotationGrammar class:

Annotation member types simply provide custom checking by overriding onCheck.

All of the grammar/type checking is kicked off during the check phase; see BaseAnnotationProcessor.

genmodel in compiler-core

During the generate phase of annotation processing (see BaseAnnotationProcessor), instances of classes in genmodel are created based on declarations for annotated classes being processed. As an example, see GenStrutsApp, which accepts a ClassDeclaration (the annotated page flow or shared flow class) in its constructor. It builds up a model based on the annotations, using its base class StrutsApp setters. Once the model is built up, it is written to XML using base class methods in StrutsApp.

Future Directions

As Eddie has suggested, some of this code could move to a Jakarta Commons-type project. This would include the typesystem package in compiler-core, some basic annotation grammar/type classes, and some skeleton code for apt AnnotationProcessors and XDoclet tasks from compiler-apt and compiler-xdoclet, respectively.

Design/NetUICompiler (last edited 2009-09-20 23:24:27 by localhost)