AlgoTraderAlgoTrader Documentation
Java Entities, Entity Interfaces and Value Objects are created by the means of the Hibernate Tools project using the hbm2java code exporter.
AlgoTrader provides a custom maven plugin called maven-codegen-plugin
which wraps the code generator.
<groupId>algotrader</groupId>
<artifactId>model-codegen-plugin</artifactId>
<name>Model code generator plugin</name>
<version>0.1.5</version>
The maven-codegen-plugin
has been added to the file
/algotrader/common/pom.xml
<plugin>
<groupId>algotrader</groupId>
<artifactId>model-codegen-plugin</artifactId>
<version>0.1.5</version>
<executions>
<execution>
<id>generate-model</id>
<goals>
<goal>codegen</goal>
</goals>
<configuration>
<templates>
<template>
<file>pojo/Pojo.ftl</file>
<pattern>{package-name}/{class-name}.java</pattern>
</template>
<template>
<file>pojo/Interface.ftl</file>
<pattern>{package-name}/{class-name}I.java</pattern>
</template>
<template>
<file>pojo/ValueObject.ftl</file>
<pattern>{package-name}/{class-name}VO.java</pattern>
</template>
<template>
<file>pojo/ValueObjectBuilder.ftl</file>
<pattern>{package-name}/{class-name}VOBuilder.java</pattern>
</template>
</templates>
</configuration>
</execution>
</executions>
</plugin>
The above configuration generates the following artifacts for each Java Entity defined in the Hibernate mapping files:
Entity
Entity interface
Value Object
Value Object Builder
The code generator uses Hibernate mapping files which are located in
/algotrader/common/src/main/resources
in combination with
Freemarker
templates which are located
in /algotrader/common/pojo
. These templates are based on the
original version supplied with the Hibernate Tools project but have been augmented to
produces Java code needed by AlgoTrader. For this purpose several custom attributes have
been added to Hibernate mapping files:
Table 5.1. Hibernate mapping files - custom meta attributes
Tag | Description |
---|---|
implements | The interface this Entity implements |
generated-class | Name of the main Entity class file |
class-code | Extra class code generated into Entity classes |
interface-code | Extra class code generated into Entity interfaces |
vo-code | Extra class code generated into Value Objects |
class-description | Javadoc comment for classes |
field-description | Javadoc comment for fields |
use-in-equals | should this property be used in the equals method |
property-type | the class to be used for this property |
Generated code is placed under the directory
/algotrader/common//target/generated-sources/main/java
.