-
Notifications
You must be signed in to change notification settings - Fork 0
Annomark Example
Roman Stumm edited this page Mar 13, 2015
·
1 revision
This is a project that demonstrates the features of "annomark". It creates some classes and xml files based on various annotations.
Some of the features demonstrated by the example project:
- launch annomark with groovy (!JAMLauncher.groovy)
- process own annotations (DTO, DTOs)
- use all templates provided with annomark (POJO, Dozer-mapping, xml-metadata)
- generate different objects for same class with relationships between them
-
Checkout the annomark-example from Source with SVN.
-
Build the project mvn clean package
-
Look into the target/generated/src/main directory
-
Download annomark-example-project.zip and extract
-
Build the project mvn clean package
-
Look into the target/generated/src/main directory
- The pom launches a groovy script that contains all instructions and configurations
pom.xml:
<java classname="org.codehaus.gram.Gram" fork="true"
failonerror="true">
<classpath refid="maven.test.classpath"/>
<arg value="${basedir}/src/main/java/com/agimatec"/>
<arg value="src/main/groovy/JAMLauncher.groovy"/>
</java>
- the first parameter is the source directory to parse
- the second parameter is the groovy script to launch
- The groovy script configures annomark:
JAMLancher.groovy
import java.util.**;
import com.agimatec.annotations.jam.**;
import com.agimatec.annotations.*;
def dtoClasses = new HashSet();
dtoClasses.addAll(classes.findAll { it.getAnnotation(DTO.class) != null });
dtoClasses.addAll(classes.findAll { it.getAnnotation(DTOs.class) != null });
generator = new JAMDtoGenerator();
generator.setTemplateDir("../annomark/templates");
generator.addInstruction("java-pojo", "target/generated/src/main/java", null)
.setUsageQualifier("Edit")
.setPrefix("Transfer")
.setSuffix(".java")
.setDefaultPackage("com.agimatec.annomark.example.transfer");
// ... more instructions here ...
generator.generate(dtoClasses);
- getAnnotation filters classes by annotations (here: DTO and DTOs). You can use own annotations as well.
- *JAMDtoGenerator assists in invoking freemarker to generate !DataTransferObjects *
- refer to documentation of JAMGenInstruction
- Study the example
- *Take a look at the the annotated model classes and experiment with the @DTO, @DTOAttribute annotations if you need !TransferObjects *
- Create own annotations or own templates to generate the artifacts you need