Home About Download Tutorial Papers About the author Documentation Home About Download Tutorial Papers About the author

Daileon allows Java-based applications to be developed using the concept of domain annotations. Essentially, it provides two main functionalities: i) it allows frameworks to be created with the capability of interpreting
domain annotations; and ii) it also allows domain annotations to represent annotations of frameworks that do not support such a concept. Therefore, Daileon allows frameworks to support the concept of domain annotations and it also allows domain annotations to be created even when using frameworks that are not able to recognize annotations other than their own.

What are domain annotations?

Domain annotations are annotations that are created by the developer and that make sense in a particular domain. In simple terms, a domain annotation is a custom annotation. Therefore, instead of using annotations provided by a framework, one can define an annotation and use it. For instance, instead of using annotations provided by the EJB3 API, users can instead define their own annotations and use them. Obviously, this type of annotation requires a special treatment, so the application can run correctly. This treatment can be applied by using the Daileon framework.

Domain Annotations for New Frameworks

A framework that is capable of interpreting a domain annotation is a framework that is able to identify which
known annotations a domain annotation corresponds to. That means that, even if an element is annotated with an annotation that is not known by the framework, it is still able to recognize it and verify which known annotations it represents, as long as this annotation is annotated with annotations known by the framework. Listing 1 ilustrates the technique to be applied with Daileon for such cases.

Listing 1. Domain annotations for new frameworks.
 /* The definition of the domain annotation */
 public @interface Administrative {
     // This annotation does not actually have
     // attributes. The code that consumes this
     // annotation only uses the annotations
     // defined in it.

 // A method of a domain class,
 // annotated with the domain annotation
 public void placeCurrentOffer() {
     // A business method of a domain class.

Listing 1 shows how a domain annotation can be defined when frameworks use Daileon to support their creation. An annotation is annotated with two annotations of a framework that is external to the domain. Since this annotation is not known by the framework, some mechanism to recognize it is required. In this case, frameworks can use the first functionality provided by Daileon. This functionality provides several ways to recognize annotations that are not known by frameworks and identify which known annotations they correspond to. The DomainAnnotationsHelper class provides several static methods that frameworks can use to identify domain annotations and recognize which known annotations they represent. More about this feature can be found here.

Domain Annotations for Existing Frameworks

Currently, most part of frameworks still does not support the concept of domain annotations, which means that
they are not able to interpret annotations that are not known by them. Consequently, replacing their annotations by domain annotations does not have any effect in their environment, even if the domain annotations represent
annotations already known by them.

For these cases, the second main functionality provided by Daileon can be used. Essentially, this functionality allows translating domain annotations to their corresponding annotations in the bytecode level. Hence, each domain annotation must indicate a class or class element in which their corresponding annotations can be found. More about this feature can be found here.

Daileon's Internal Behavior

When defining domain annotations to be used with existing frameworks, Daileon acts in the application classes
after the compilation process. It changes the classes’ bytecodes to incorporate the annotations of the original frameworks. The order of Daileon actions are shown in Figure 1. The configuration file indicates the classes that are annotated with domain annotations. In this case, each domain annotation indicates where the annotations of the original frameworks are located. The domain annotations are then evaluated properly (that is, translated to the corresponding annotations of the original frameworks) and are finally placed in the classes’ bytecodes, adding the corresponding annotations. Classes are then saved in a different directory, so that the domain annotations are not replaced in the original class files, allowing them to be replaced by other annotations when necessary.

Daileon uses the ASM bytecode engineering tool to manipulate the classes’ bytecodes. Essentially, each
domain annotation is evaluated to annotations of existing frameworks that do not support the creation of domain annotations at all. After the manipulation, the external annotations are added to their corresponding elements in the code. For frameworks that use Daileon to support the creation of domain annotations, it provides a class called DomainAnnotationsHelper, in order to recognize a domain annotation and inform which known annotations it corresponds to.

Daileon's Steps
Figure 1. Daileon actions, when translating domain annotations
in the bytecode.