equanda configuration

The configuration happens in a few places.

  • Generation configuration file
  • Maven plugin
  • persistence.xml

For the presentation layer, there is also some config in border.xml and config.properties.

Generation configuration file

This is a file which configures extra parameters which are read when generating from the domain model.
Each of the templates use the relevant section in this file.
The location for the file can be specified in the maven plugin configuration. The default is "dm.ini" in the directory where the domain model is found.


[config]
definition=dm.xml
generateAll=false

[ejb3]

[ddltool]
package=mypackage.myapp.ddltool

[import]
package=mypackage.myapp.ymport

[login]
package=mypackage.myapp.login

[extra]
security-role=LocalUser,LocalAdmin
security-role-remove=LocalUser,LocalAdmin
infrastructure=true
lazylist-cache-capacity=100
lazylist-cache-expiration=3000
fetch-batch-size=100
link-fetch-batch-size=100
multiple-fetch-batch-size=100
entity-manager-name=myapp-em
skip-jalopy=true
skip-xml-check=true
security-domain=myapp
ejb-package=mypackage.myapp.dm
default-role=LocalUser

[database]
type=firebird
convert=org.equanda.domain.db.Max31Convert

The "config" and "extra" sections contain parameters which may be used by all templates.
For "config" it specifies the name of the domain model definition file, and whether all files should allways be overwritten (default behaviour is to not touch files if there is no change in the object model which affects that file, when the templates themselves have changed you need to generate everything again either by doing a clean before the compile, or by setting "generateAll" to "true").

The "extra" section contains data source location, security information etc.

  • security-role : appserver roles which are allowed access to the table by default.
  • security-role-remove : appserver security roles which are allowed to delete records by default.
  • infrastructure : when true, the infrastructure tables are also included in the domain model.
  • lazylist-cache-capacity : number of records to cache (or fetch size) for lazy lists.
  • lazylist-cache-expiration : lazy list cache expiration time in milliseconds.
  • fetch-batch-size : Hibernate fetch batch size for tables.
  • link-fetch-batch-size : Hibernate fetch batch size for links.
  • multiple-fetch-batch-size : Hibernate fetch batch size for multiple fields.
  • skip-jalopy : when false jalopy is used to reformat the generated java code. Note that this slows down generation time.
  • skip-xml-check : when false the correctness of generated xml files is verified. This may be useful while modifying template files.
  • security-domain : appserver security domain to use.
  • ejb-package : base package for the persistence layer (when "package" is specified in the "ejb3" section, then this should be the same).
  • default-role : role which is assigned to users which have no role assigned.

The other sections describe the base package to be used for the classes which are generated.

Maven plugin configuration

Depending on the module, the configuration is different for the maven build plugin. For the main module, the documentation is generated. It can be included in the report plugin by having a link to "dm/index.html".
The defaults assume that the domain model is stored in the "src/main/dm" directory, and the generation configuration file is called "dm.ini".


...
<build>
<plugins>
...
<plugin>
<groupId>org.equanda</groupId>
<artifactId>equanda-maven-plugin</artifactId>
<configuration>
<outputDirectory>target/site/dm</outputDirectory>
<template>docs</template>
</configuration>
<executions>
<execution>
<phase>site</phase>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<inherited>false</inherited>
</plugin>
...
</plugins>
</build>
...

For the core module, where the persistence layer needs to be generated, with the import and login code, it looks like this.


<plugin>
<groupId>org.equanda</groupId>
<artifactId>equanda-maven-plugin</artifactId>
<configuration>
<sourceDirectory>${basedir}/../src/main/dm</sourceDirectory>
<template>ejb3,import,login</template>
<verifyLanguages>en;nl</verifyLanguages>
<translateTarget>${basedir}/src/main/resources/translations.txt</translateTarget>
</configuration>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>

The source directory is specified (relative to the module basedir).
The "verifyLanguages" and "translateTarget" settings are used for the "equanda:translate" target.

For the user interface (war module)


<plugin>
<groupId>org.equanda</groupId>
<artifactId>equanda-maven-plugin</artifactId>
<configuration>
<sourceDirectory>${basedir}/../src/main/dm</sourceDirectory>
<template>t5gui</template>
</configuration>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>

The resources setting indicates that everything should be generated to the generated resources instead of generated classes directory.

For the ddltool module


<plugin>
<groupId>org.equanda</groupId>
<artifactId>equanda-maven-plugin</artifactId>
<configuration>
<!-- generate ddltool parameters -->
<sourceDirectory>${basedir}/../src/main/dm</sourceDirectory>
<template>ddltool</template>
<!-- run ddltool parameters -->
<database>${synca.db.url}</database>
<dblogin>${synca.db.login}</dblogin>
<dbpassword>${synca.db.password}</dbpassword>
<dbmap>be.synergetics.ca.ddltool.EquandaMap</dbmap>
<ddltargets>update defaults indexes</ddltargets>
</configuration>
<executions>
<execution>
<id>generate</id>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>

Here you also have to specify the database connection details (to allow the "equanda:ddltool" target to actually update the database structure).
The "dbmap" setting is the classname which is generated, and "ddltarget" defines which of the ddltool updates should be performed.

persistence.xml

This is the normal EJB3/JPA persistence.xml file. An example is


<persistence>
<persistence-unit name="myapp-em">
<jta-data-source>java:/myappDS</jta-data-source>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.FirebirdDialect"/>
<!--<property name="hibernate.hbm2ddl.auto" value="create-drop"/>-->
<property name="hibernate.hbm2ddl.auto" value="check"/>
<property name="hibernate.cache.use_second_level_cache" value="true"/>
<property name="hibernate.cache.provider_class" value="org.jboss.ejb3.entity.TreeCacheProviderHook"/>
<property name="hibernate.treecache.mbean.object_name" value="jboss.cache:service=EJB3EntityTreeCache"/>
<property name="hibernate.cache.use_query_cache" value="true"/>
<property name="hibernate.max_fetch_depth" value="0"/>
</properties>
</persistence-unit>
</persistence>

Most importantly, you should configure the correct data source name and hibernate dialect.

  • 1. equanda configuration
  • 1.1. Generation configuration file
  • 1.2. Maven plugin configuration
  • 1.3. persistence.xml