blob: 656be3c5b8f8276a9bc97d6dbd1f1b227633a2bc [file]
[[tut-services-step1,Step 1 - Creating a ServiceComposite]]
= Step 1 - Creating a ServiceComposite =
In this tutorial we start with basic Java classes, to simulate a very simple Library where you can borrow
and return books.
Qi4j relies heavily on the use of interfaces. This makes it possible for an object
to externally implement a number of interfaces which internally is backed by a number
of Mixins, some of which you may have written yourself, and some of which may have been
reused. This is also true for services, which we are to cover in this tutorial.
The first task is therefore to refactor the code so that the methods are implemented from an
interface instead, and to essentially make the identical "application" into a Qi4j application.
We also want the Book to be a ValueComposite.
Steps for this tutorial:
- Make the Book into a ValueComposite.
- Make the Library an interface with the same methods. We call this a MixinType.
- Create a LibraryMixin class, which implements the Library interface.
- Create a LibraryService that binds the LibraryMixin.
- The LibraryMixin will need to be injected with the ValueBuilderFactory in the @Structure scope.