This project has been discontinued in favor of enforcing module boundaries by using Maven Multi-Module projects.
Archer is a pre-defined set of Architectural Enforcement Rules. The aspect-oriented enforcement of rules is guided by annotations and any violation is reported early at compile time.
- prevents bad code from compiling
- lightweight API
- retroactively applicable
- independent of package structure
Archer defines several different layers:
| Layer/Annotation | Description |
|---|---|
@Gateway |
External service client |
@Library |
Shared code between any of the layers |
@Logic |
Business logic |
@Model |
Business or domain model |
@Persistence |
Database access layer |
@Queue |
Asynchronous message queue client |
@Resource |
Web Service/API |
@Scheduler |
Background Job |
- Java 8
- AspectJ compiler
Add the following dependencies to your project:
<dependency>
<groupId>io.github.whiskeysierra</groupId>
<artifactId>archer-annotations</artifactId>
<version>${archer.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.github.whiskeysierra</groupId>
<artifactId>archer-aspectj</artifactId>
<version>${archer.version}</version>
<scope>provided</scope>
</dependency>And configure the AspectJ compiler accordingly:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.8</version>
<configuration>
<aspectLibraries>
<aspectLibrary>
<groupId>io.github.whiskeysierra</groupId>
<artifactId>archer-aspectj</artifactId>
</aspectLibrary>
</aspectLibraries>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>Archer requires you to annotate every class with one of the layer annotations:
@Model
public class Person {
}
@Persistence
public class PersonRepository {
}
@Logic
public class PersonService {
}
@Resource
public class PersonResource {
}Any call between two layers that is not allowed by a rule will result in a compiler error. The same is true if a class is missing an annotation.
- No support for package-level annotations, see here
If you have questions, concerns, bug reports, etc, please file an issue in this repository's Issue Tracker.
To contribute, simply make a pull request and add a brief description (1-2 sentences) of your addition or change. For more details check the contribution guidelines.
- Mattias Severson, Architectural Enforcement with Aid of AspectJ
- Martin Fowler, Testing Strategies in a Microservice Architecture
