TRIMM 1.0.1 Snapshot is available with support for CQRS and AxonFramework
EA是企业架构师Enterprise Architect的简称,如果你玩过Borland的Together,两者都差不多。(Enterprise Architect UML 9.3 官方安装中文版(含注册码))
在EA中可打开AddressBook model.eap,这个项目其实就是Axon AddressBook example的UML设计项目。
项目在EA中图示:

聚合根是Contact,围绕聚合根有一系列Command和Event,如下图:

通过EA的输出 XMI 可以将这个项目输出为AddressBook.xml.
通过Maven配置TrimmCQRSMavenPlugin 加入到这个java项目:
<plugin> <groupId>dk.tigerteam</groupId> <artifactId>TrimmCQRSMavenPlugin</artifactId> <version>1.0.1-SNAPSHOT</version> <executions> <execution> <id>generate</id> <phase>generate-sources</phase> <goals> <goal>generate</goal> </goals> <configuration> <yamlFile>model/CQRSConfiguration.yml</yamlFile> </configuration> </execution> </executions> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>2.6</version> </dependency> </dependencies> </plugin>
|
配置 CQRSConfiguration.yml:
# The path to the XMI model file. e.g. model/MyModel.xml xmiModelPath: model/AddressBook.xml # The UML tool used. Example: EA, MagicDraw16, MagicDraw17 or FQCN/.groovy script (implementing the XmiReader interface) umlTool: EA # The optional base package name that should be appended to all generated code. Example: dk.tigerteam.myproject basePackageName: dk.tigerteam.cqrs.axon # Paths # The required path where base-classes (classes generated each time) will generated to. generateBaseClassesToPath: target/generated-sources/model # The required path where extension-classes (classes generated only once and only if missing) will generated to. generateExtensionClassesToPath: src/main/model-extensions # The path where interfaces (similar to base-classes, generated every time) will generated to. generateInterfacesToPath: target/generated-sources/model
|
加入Axon包依赖:
<dependency> <groupId>org.axonframework</groupId> <artifactId>axon-core</artifactId> <version>2.0.5</version> </dependency> <dependency> <groupId>commons-lang</groupId> <artifactId>commons-lang</artifactId> <version>2.6</version> </dependency>
|
最后,运行:
mvn generate-sources
将你的EA用UML设计的CQRS项目转变为Axon框架支持的Java源码,产生的代码项目如下:

以上配置可以在 trimm-examples找到。