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.

Apache Polygene™ 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 Polygene™ application. We also want the Book to be a ValueComposite.

Steps for this tutorial:

  1. Make the Book into a ValueComposite.
  2. Make the Library an interface with the same methods. We call this a Mixin Type
  3. Create a LibraryMixin class, which implements the Library interface.
  4. Create a LibraryService that binds the LibraryMixin.
  5. The LibraryMixin will need to be injected with the ValueBuilderFactory in the @Structure scope.