How it works at Runtime
Master and Metacode
Master - is a Java type that uses an annotation and is processed by Jeta. For each master, Jeta generates a Metacode class. This class is located in the same package as its master and named as
Metasitory is a short for Meta Code Repository. This class holds all the required information about generated code. During the annotation processing, Metasitory Writer creates a meta storage. The storage contains the necessary information about the masters, their metacodes and annotations they use.
Currenlty Jeta provides
The Criteria provides a way to determine queries to metasitory. In most cases, Criteria is used for querying metacode by its master. It’s allowed to query for a single instance, which generated for a given master, or for the all tree including the metacodes generated for parent masters as well. It gives you the ability to invoke a controller once in a base class and it will apply metacode to the child classes as well.
Controller searches for the required metacode using Criteria and applies it to the master. Well, it’s just a common case and some controllers do more complex work.
Let’s continue to observe the Hello, World! example, from the previous guide, and find out how to apply the metacode to the sample class.
At first, we need to declare an interface that will be implemented by metacodes generated for
Secondly, create the controller:
Note This controller creates a Criteria and searches for the metacode by itself for demonstration. The better way is to extend
Finally, we need to create a helper method in our MetaHelper class:
What the MetaHelper is for and how to organize it in your project is explained in the next article
How it works: