Qi4j

Tutorial 2 - Creating a Composite

In this tutorial we will create a Composite interface that ties all pieces together. The Composite interface is a regular Java interface which extends the interfaces you want to expose from your domain model, and which uses various annotations to declare what Fragments to include. Fragments include Mixins, Concerns, SideEffects and Constraints. In this tutorial we will only use Mixins. When a Composite is instantiated at runtime the framework will inspect the interface to determine what the Composite instance should look like in terms of used Fragments.

Steps for this tutorial:

  1. Create an interface that extends the domain interface HelloWorld and Composite
  2. Add a @Mixins annotation to it with the name of the Mixin as argument

Solution

If you have successfully completed the task, you should end up with the following artifacts;

HelloWorld.javaexternal link
HelloWorldBehaviour.javaexternal link
HelloWorldComposite.javaexternal link
HelloWorldMixin.javaexternal link
HelloWorldState.javaexternal link

Powered by SiteVisionexternal link.