0% found this document useful (0 votes)
41 views

A Model To Enable The Reuse of Metadata-Based Frameworks in Adaptive Object Model Architectures

This article proposes a model that enables reusing frameworks designed for classic object models in adaptive object model architectures. It presents a reference implementation in an AOM framework and evaluates the feasibility through a case study using an ORM framework and an experiment with developers. The evaluations found the approach can successfully enable framework reuse and reduced effort in adopting AOM, at the cost of a learning curve.

Uploaded by

bkdwnld37
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views

A Model To Enable The Reuse of Metadata-Based Frameworks in Adaptive Object Model Architectures

This article proposes a model that enables reusing frameworks designed for classic object models in adaptive object model architectures. It presents a reference implementation in an AOM framework and evaluates the feasibility through a case study using an ORM framework and an experiment with developers. The evaluations found the approach can successfully enable framework reuse and reduced effort in adopting AOM, at the cost of a learning curve.

Uploaded by

bkdwnld37
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

This article has been accepted for publication in a future issue of this journal, but has not been

fully edited. Content may change prior to final publication. Citation information: DOI
10.1109/ACCESS.2021.3087795, IEEE Access

Date of submission September 17, 2020, date of current version December 7, 2020.
Digital Object Identifier 10.1109/ACCESS.2017.DOI

A Model to Enable the Reuse of


Metadata-based Frameworks in Adaptive
Object Model Architectures
EDUARDO GUERRA1 , ANTONIO DIAS2 , LUIZ GUSTAVO VERAS3 , ADEMAR AGUIAR4 ,
JOELMA CHOMA2 , and TIAGO SILVA DA SILVA 5
1
Free University of Bozen-Bolzano, Bolzano, Italy
2
National Institute for Space Research (INPE), São José dos Campos, Brazil
3
Instituto Federal de São Paulo, Campus Bragança Paulista, Brazil
4
Faculdade de Engenharia da Universidade do Porto (FEUP), Porto, Portugal
5
Federal University of São Paulo, São José dos Campos, Brazil
Corresponding author: Eduardo Guerra (e-mail: [email protected]).
This work is financed by National Funds through the Portuguese funding agency, FCT - Fundação para a Ciência e a Tecnologia, under
research grant SFRH/BD/115358/2016 and within the project UIDB/50014/2020. This work is also part of the ASICASM project financed
by Free University of Bozen-Bolzano.

ABSTRACT Context: The Adaptive Object Model (AOM) is an architectural style in which domain
entity types are represented as instances that can be changed at runtime. It can be used to achieve higher
flexibility in domain classes. Due to AOM entities having a distinct structure, they are not compatible
with most popular frameworks, especially those that use reflection and code annotations. Objective:
To solve such limitations, this work aims to propose a model that enables the reuse of frameworks
designed for classic object-oriented domain models in an AOM application. Methods: The proposed model
uses dynamically-generated adapters for AOM entities that encapsulate them in a class with the format
expected by the frameworks. A reference implementation was developed in the Esfinge AOM RoleMapper
framework to evaluate the viability of the proposed model. Initially, to evaluate the solution feasibility,
a case study was carried out using the Hibernate framework. Further, an experiment was conducted to
assess how the participants perceived the framework functionality reuse through the proposed model.
Results: The feasibility study revealed that the solution could be applied in a complex setting for the
chosen object-relational mapping frame. It raised some difficulties that can be addressed in future studies.
In the experiment, the development time did not present a significant difference compared to the competing
approach. Despite the considerable learning curve, most participants considered that the proposed approach
has more advantages than the alternative. Conclusion: Based on the evaluations, we can conclude that the
proposed model can be successfully employed to use AOM entities with frameworks that were not designed
for AOM applications. The possibility of reusing existing frameworks can reduce the effort required to
adopt an AOM architecture and, consequently, be a facilitator in implementing more flexible and adaptive
approaches.

INDEX TERMS Adaptive Architecture, Adaptive Object Model, Metadata, Object-Oriented Design, Run-
time environment, Software architecture , Software engineering, Software Framework, Software reusability,
Software tools.

I. INTRODUCTION and existing types can be modified, enabling the application


to be adapted to new requirements. Some classic examples of
Adaptive Object Models (AOM) can be considered an ar- domains in which this kind of architecture has already been
chitectural style for creating flexible applications [1]. Based implemented successfully are insurance [2] and health care
on design patterns, such as Type Object, Properties, and [1].
Type Square, AOMs represent types as instances that can be
manipulated at runtime. Therefore, new types can be created,

VOLUME X, 20XX 1

This work is licensed under a Creative Commons Attribution 4.0 License. For more information, see https://creativecommons.org/licenses/by/4.0/
This article has been accepted for publication in a future issue of this journal, but has not been fully edited. Content may change prior to final publication. Citation information: DOI
10.1109/ACCESS.2021.3087795, IEEE Access

Guerra et al.

Several more recent studies employed AOM concepts for work, and also in an experiment, in which the participants had
several applications and domains, such as for economy me- to implement data validation for entities based on a given set
chanics in digital games [3], model-driven architectures [4], of constraints. In the case study, the goals was to evaluate
[5], data evolution in digital ecosystems [6], meta-modeling the feasibility of the proposed approach in more complex
architectures [7], and dynamic web services [8], [9]. That can scenarios. The goals of the experiment are: (i) to assess if
be considered an evidence that this architectural style is still the proposed approach requires more time of development
relevant and applied in recent works. than an approach using imperative code; and (ii) to verify
To handle the entities and entity types defined in a different the perception of the developers to its ease of use, useful-
structure, an AOM architecture often needs custom-tailored ness, and benefits. Half of the participants implemented the
software components [1]. These components are necessary, constraints for each type of entity directly retrieving and
for instance, to persist entities and present them in the user in- checking the values, and the other half defined additional
terfaces. The effort required to develop such components can metadata mapped to Hibernate Validator annotations. As a
be considered a drawback of AOM systems since, for regular result, the case study showed that it is possible to use the pro-
information systems, some components and frameworks can posed solution with composed entities in an object-relational
be reused in several systems layers. mapping framework. Additionally, all participants were able
As an attempt to enable the reuse of AOM components to complete the experiment, the difference in development
among applications, some AOM frameworks, like Oghma time was not significant, and 86% of them would choose the
[10] and Ink [11], provide ready-to-use classes that can be proposed approach, highlighting the improved maintainabil-
used to define entity types and create entities. Since these ity and the increase in the reuse of existing frameworks.
classes are not attached to any specific domain, we call This work’s main contribution is the proposed AOM
this approach as domain-independent in this article. The framework model that allows the reuse of frameworks de-
solutions also provide components for the architecture of signed to be used in regular classes. There is no other work
AOM applications based on their own AOM structure. A in the literature that provides a solution to this problem.
drawback of this approach for AOM frameworks is that it Additionally, a reference implementation of this solution was
is not possible to add domain-specific features in the AOM implemented in the AOM framework Esfinge RoleMapper
model, which is very common in AOM applications since and used for two different evaluations: a more complex case
it drives implementation towards application requirements, study to assess the feasibility and a controlled experiment
especially for business rules that handle the entities directly. with developers.
The adoption of an AOM architectural style also prevents This article is organized as follows: Section II presents
the usage of frameworks created for regular static classes. the main concepts about AOMs and reflective and metadata-
For instance, the Java Beans standard [12] defines in the based frameworks; Sections III and IV present respectively
Java language a way to define application entities by us- the proposed AOM framework model and the Esfinge AOM
ing the prefix "get" and "set" for access methods. Several RoleMapper implementation; Section V presents a case study
frameworks that use reflection and code annotations [13] with Hibernate; Sections VI and VII respectively report how
consider this standard for processing entities. Since AOM the experiment was designed and its results; Section VIII
entities do not provide this same API style, none of those discuss the results; Section compares the proposed approach
frameworks can be reused when this architectural style is with other existing AOM frameworks; finally, Section X
adopted. The AOM frameworks previously mentioned [10], concludes the work.
[11] provide their components. Nevertheless, the applications
are limited to them. This lack of reuse increases the cost
II. BACKGROUND
of developing AOM applications since the functionality of
several components that could be reused would need to be A. ADAPTIVE OBJECT MODELS
developed from scratch. Adaptive Object Model is an architectural style for systems
The goal of this work is to propose a framework model for in which classes, attributes, relationships, and behaviors are
AOM architectures that aims to increase the reuse of com- represented as metadata consumed at runtime [1]. Moreover,
ponents and frameworks created for static class models. The the same code can process different entities unknown at
proposed framework model was implemented in an existing compile time. This architecture enables systems to be flexible
Java AOM framework named Esfinge AOM RoleMapper and easily adaptable at runtime, not only by programmers
[14]. Our approach uses bytecode manipulation to create but also by business analysts and end-users. Consequently,
at runtime an adapter for the AOM entity that is based on this flexibility allows changes to be very quickly made and
the Java Beans standard [12]. A mapping between AOM released, enabling the domain to evolve smoothly as part of
entity type metadata and code annotations is performed to the business.
enable the addition of the reused framework annotations in The AOM structure is created based on patterns, such as
the dynamically generated class. Type Object, Property, Type Square, Accountability. This
The proposed approach was evaluated through a case section aims to present these main patterns that are important
study, where the solution was applied with a complex frame- to understand how an AOM application works. A complete
2 VOLUME X, 20XX

This work is licensed under a Creative Commons Attribution 4.0 License. For more information, see https://creativecommons.org/licenses/by/4.0/
This article has been accepted for publication in a future issue of this journal, but has not been fully edited. Content may change prior to final publication. Citation information: DOI
10.1109/ACCESS.2021.3087795, IEEE Access

Guerra et al.: A Model to Enable the Reuse of Metadata-based Frameworks in Adaptive Object Model Architectures

set of patterns to create an AOM Pattern Language is pro- Likewise, existing entity types can be changed at runtime,
posed on [15]. since modeling is done at the instance level.
The Type Object [16] is used in situations where the num-
ber of subclasses that a class may need cannot be determined
during the system development. This pattern represents the
subtypes that are not known at development time as instances
of a class that represents a type.
In Fig. 1, the class Sensor is composed of an instance
of the class SensorType. The SensorType instance contains
information about the type of the Sensor. The class-instance
relationship that existed in a classic object-oriented model
is now represented as a composition, where the Sensor in-
stances have a reference to instances of SensorType. New
instances of SensorType might be created at runtime to
represent new types of sensors. FIGURE 3. Type Square pattern sample

The pattern Accountability [1] is focused on the rela-


tionship between AOM entities. Although, this pattern is
not the only approach for representing these relationships.
Each Accountability object is associated with an Account-
abilityType object, as presented in Fig. 4, which represents
the relationship type. This instance has information about
this relationship, such as the cardinality on each side. Since
associations between entities are represented at the instance
FIGURE 1. Type Object pattern sample.
level, the types of relationships between entities can also be
created and modified at runtime.
The Property pattern [17] can be applied in situations
where instances of the same class can have different types
of properties. It solves this problem by representing an en-
tity’s properties with a collection of instances of a class that
represents a property. Fig. 2 presents an example of pattern
Property in which each instance of class Measurement repre-
sents one property of a Sensor. A collection of Measurement
can replace the Sensor’s attributes with only the necessary
measurements that apply for that specific sensor.

FIGURE 4. Accountability pattern sample.

B. AOM SYSTEM ARCHITECTURE


Fig. 5 presents the conceptual model of the AOM architec-
ture. In this diagram, the XML/XMI files store the types’
FIGURE 2. Property pattern sample. information parsed and interpreted to be stored at runtime
in a metadata repository. The application domain model is
The Type Object and Property patterns can be used to- retrieved from that repository, and the domain objects are
gether twice, resulting in a structure called Type Square created and used based on the entity types metadata. To
[1]. The Type Object is used twice: to represent the entities retrieve and store application data, a Persistence Mechanism
and entity types, and twice to represent the properties and can retrieve data from the domain objects and use metadata
property types. Fig. 3 represents the pattern structure in the in the repository to map them to database tables.
Sensor example. Using Type Square, new types of entities The conceptual model presented in Fig. 5 is the first repre-
with different types of properties can be created. With this sentation of an AOM architecture in the literature. Further,
structure, it is possible to define what types of measurement this model was adapted to implement an AOM for other
are expected for a given type of sensor. The consistence of systems. For instance, new solutions implemented compo-
the types with the entities is verified in its internal methods. nents that can read and store metadata and domain data from
VOLUME X, 20XX 3

This work is licensed under a Creative Commons Attribution 4.0 License. For more information, see https://creativecommons.org/licenses/by/4.0/
This article has been accepted for publication in a future issue of this journal, but has not been fully edited. Content may change prior to final publication. Citation information: DOI
10.1109/ACCESS.2021.3087795, IEEE Access

Guerra et al.

information. Additionally, the framework might also need


a way to parameterize its execution for different code ele-
ments. As a solution, several frameworks use the definition of
additional domain-specific metadata, which usually is done
through external configuration files or code annotations. The
frameworks that use this strategy are called Metadata-based
Frameworks [13].
In this kind of framework, instead of invoking methods or
implementing abstractions, the application developer inter-
action is mostly done by defining domain-specific metadata.
For instance, in an object-relational mapping framework such
as Hibernate [24], the class application should be configured
with metadata that defines how the framework should persist
FIGURE 5. Adaptive Object Model [1].
and retrieve it from the database. That approach changes
the way that frameworks are built [25] and instantiated by
applications [26], [27].
different sources and in different formats. Depending on how Metadata-based Frameworks became popular when some
sophisticated the model is, it might need a specialized builder programming languages started the native support for adding
to assembly the entities and the entity types [18]. metadata directly in the code elements. This feature is known
Graphical components are examples of parts of the soft- as "annotations" in Java [28] and "attributes" in C# [29]. The
ware that should be adapted to the AOM structure since forms usage of code annotations is also known as attribute-oriented
and tables need to adapt to changes in the types. There are programming [30], [31]. This approach makes it easier to
some patterns for representing AOM entities in graphical define and configure framework domain-specific metadata,
interfaces [19]. Another requirement that can change the especially when compared to metadata definition in external
AOM infrastructure is when different versions of the same files, such as XML or JSON, where the respective code
type need to coexist at runtime. To handle this kind of element to be configured needs to be explicitly referenced.
requirement, several patterns about domain model evolution In Java language, the usage of annotations also became
could be implemented [20], [21]. popular with its adoption by the main APIs for enterprise de-
velopment in Java EE 5, like EJB 3.0 (Enterprise Java Beans)
C. REFLECTIVE AND METADATA-BASED [32], JPA (Java Persistence API) [33], and CDI (Context and
FRAMEWORKS Dependency Injection) [34]. Several other frameworks for
An accepted definition of a framework in the context of testing and mobile development also adopted the metadata-
object-oriented design is that it can be considered an in- based approach. The wide adoption of code annotations can
complete software with extension points that can be spe- be confirmed with recent studies investigating the code of
cialized to add application-specific behavior [22]. Moreover, several open-source projects [35]–[37].
it can be considered a set of classes representing an ab- The fact that entity types in AOM architectures are not
stract design for a family of related problems. A classical represented as classes makes the direct usage of code anno-
object-oriented framework instantiation should compose and tations not viable. Based on that, it is not possible to benefit
specialize its extension points to create an executable and from metadata-based APIs and frameworks focused on the
complete application. The classes used for its composition usage of code annotations. Accordingly, it is hard for AOM
can be application-specific or part of the framework class applications to reuse existing components, and usually, it
library. needs to create specific ones tailored for its entity structure.
Reflective frameworks use introspection to access meta- Consequently, it increases the effort and the cost for the
data from the application classes in runtime, accessing data development of applications that follow that architectural
as its superclasses, methods, and attributes. This approach style.
reduces the coupling between the application classes and the
framework since they do not need to extend its superclasses D. AOM FRAMEWORKS
nor implement its interfaces. For example, a framework Most of the applications that adopt AOMs implements their
might search among the application class methods for the patterns in their own classes. For instance, in the examples
right method to invoke, such as one that follows a defined given in section II-A, the classes Sensor and SensorType
code convention. This technique gives the application more are specific from one domain. These are called domain-
flexibility to modify classes since its binding with the frame- specific AOMs since they have elements that couple them
work happens in runtime [23]. with the application domain. This approach’s benefit is that
For some scenarios, the intrinsic class metadata and code the classes might have specific domain logic and contain the
conventions are not enough for the framework to find the implementation of the patterns tailored for the application
right method to invoke or the right attribute to retrieve needs.
4 VOLUME X, 20XX

This work is licensed under a Creative Commons Attribution 4.0 License. For more information, see https://creativecommons.org/licenses/by/4.0/
This article has been accepted for publication in a future issue of this journal, but has not been fully edited. Content may change prior to final publication. Citation information: DOI
10.1109/ACCESS.2021.3087795, IEEE Access

Guerra et al.: A Model to Enable the Reuse of Metadata-based Frameworks in Adaptive Object Model Architectures

domain-specific AOM using his classes. These classes can


contain elements that play roles for the AOM patterns; how-
ever it can also contain domain-specific elements, such as
methods and attributes used by the application. This model
should be used, especially when necessary a custom AOM
model tailored to application needs.
The AOM framework also provides an API for a domain-
independent AOM model. This API has two different imple-
mentations: one that provides a generic AOM implementa-
tion and another that provides adapters to domain-specific
AOMs. A domain-specific AOM needs to contain additional
metadata that identify the code elements’ roles based on the
AOM patterns. With this metadata, the AOM framework can
recognize the role of methods and attributes, invoking the
respective ones for each access in the adapters. Therefore,
framework users might adapt their own AOM implementa-
tion or can use the framework domain-independent model.
This second option should be used when it is unnecessary to
have custom domain-specific elements in the AOM classes.
FIGURE 6. AOM Framework Model Representation.
Reusable components for the AOM model should rely on
the domain-independent model. For instance, a component
that persists the entities and the entity types should retrieve
However, using a domain-specific AOM prevents the reuse this information based on the framework provided interface.
of software components in other AOM applications. Since the Since domain-specific AOMs can be adapted to those inter-
peculiar structure of AOM entities also prevents the reuse of faces, these components might be reused for all of them.
several reflective and metadata-based frameworks, it creates Finally, the AOM framework should also have mecha-
a drawback that is a demand for the development of a specific nisms to generate adapters for AOM entities that emulate
set of software components for that application. Examples of static APIs. Since the class structure depends on entity type
these components are for persistence and graphical interface. dynamic information, the adapter classes should be generated
This drawback increases the cost and development time of at runtime using reflective capabilities available in the lan-
such applications. guage and platform. For instance, a generated access method
There are two AOM frameworks found in literature that in the adapter (e.g., "String getName()") should handle the
were created to provide a structure that can be reused by entity property with the same name (e.g., a text property
several applications. The frameworks Oghma [10] and Ink "name"). An essential point of this model is that existing
[11] are the closest related work to the one presented in this custom metadata in the AOM model should be translated to
article. To the best of our knowledge, there are no other AOM code annotations in the generated classes. That is required to
frameworks per se documented in the literature. enable the usage of metadata-based frameworks.
These frameworks provide a general AOM structure to The goal of the adapters based on static APIs is to en-
be used by any application, independent of its domain. Be- able the entity to be recognized by components and frame-
cause of that, these frameworks can be classified as domain- works that invoke class methods using reflection and read
independent. This concept is essential because the framework its metadata in code annotations. That increases the number
model proposed in this work and its respective implemen- of components that can be reused in an AOM application.
tation also allows the application to create its own domain- Since a domain-specific AOM might be adapted to a domain-
specific AOM. These frameworks are described with more independent AOM, both of them might use these adapters to
detail in section IX static classes.
Summarizing, the framework model defines three different
III. PROPOSED AOM FRAMEWORK MODEL
APIs for application entities and defines adapters among
This section aims to present the proposed framework model
them. These adapters enable entities defined in one model
for AOM applications. This model’s two main requirements
to be accessed by components that work with other API. De-
are: (1) to enable the reuse of components made for a domain-
spite the flexibility, this model also enables creating a hybrid
independent AOM for domain-specific AOMs; (2) to enable
model, in which the application can have AOM entities and
the reuse of reflection-based and metadata-based frameworks
static domain classes being manipulated transparently by the
created for static classes to the AOM entities. A graphic
same framework or component.
representation of the proposed model is presented in Fig. 6.
Following this model, the framework user can define a
VOLUME X, 20XX 5

This work is licensed under a Creative Commons Attribution 4.0 License. For more information, see https://creativecommons.org/licenses/by/4.0/
This article has been accepted for publication in a future issue of this journal, but has not been fully edited. Content may change prior to final publication. Citation information: DOI
10.1109/ACCESS.2021.3087795, IEEE Access

Guerra et al.

IV. ESFINGE AOM ROLEMAPPER


This section presents the framework that was used as a
reference implementation for the proposed AOM framework
model. It is called Esfinge AOM RoleMapper, it is imple-
mented in Java, and it is available open-source1 . This is
part of a larger project called Esfinge that embraces several
innovative metadata-based frameworks.
Previous work on Esfinge AOM RoleMapper focused
on different issues, such as the primary mapping between
domain-specific and domain-independent classes [38] and
the support to incrementally refactor towards the AOM pat-
terns [39]. A preliminary solution for the generation of static
class adapters was first presented in [40] but without support
for code annotations, which is essential to reuse metadata-
based frameworks. Additionally, there is a recent work fo- FIGURE 7. Classes from the Domain-Independent Model.
cused on the use of Esfinge AOM RoleMapper for creating
dynamic web services [8].
This section describes the functionality provided by Es-
A simple use of the domain-independent AOM classes is
finge AOM RoleMapper with the main focus on how the
presented in List. 1.It is presented the use of them to create
models and the adapters are implemented to support reflec-
an entity type with two properties and an entity with values
tive and metadata-based framework reuse.
for the respective properties.
A. DOMAIN-INDEPENDENT AOM MODEL
The framework provides a set of interfaces that define 12 //Creating Entity Type
IEntityType sensorType = new GenericEntityType("Sensor");
a domain-independent API. These interfaces are imple- 3 sensorType.addPropertyType(new
mented by a domain-independent implementation and by the 4 GenericPropertyType("name", String.class));
sensorType.addPropertyType(new
adapters for domain-specific models. All the external frame- GenericPropertyType("type", String.class));
work APIs and components should rely on these interfaces 56 //Creating Entity
unless they are explicitly dedicated to one of the models. 7 IEntity sensor = sensorType.createNewEntity();
The dependence on the interfaces guarantees that it will be 89 sensor.setProperty("name", "radiometerX");
sensor.setProperty("type", "radiometer");
compatible with entity types created based on the domain-
independent implementation and based on adapted domain-
LISTING 1. Creating entity type and entity using the domain-independent
specific models. AOM model.
There are four interfaces that map directly the elements
from the Type Square pattern: IEntityType, IEntity, General AOM frameworks should use the domain-
IPropertyType, and IProperty. All these interfaces independent AOM interfaces to create reusable components
extends the HasProperties interface, introduced to allow compatible with applications from different domains. For
all elements to receive additional custom metadata. This instance, the Esfinge AOM RoleMapper framework provides
metadata can me used for framework processing, and can components that persist entities and entity types in databases
also be transformed in code annotations when the AOM based on this model.
entity is adapted to a static class. Finally, an interface called As a design choice, the framework provides a simple
RuleObject is used to represent entity type operations. AOM model. The Accountability pattern is not used for
The domain-independent implementation classes enable relationships among entities, which is implemented with
creating entities and their properties without the need for property types that receive an entity type as its target type.
a domain-specific AOM model. This option should be used Similarly, a relationship with a multiplicity of more than one
for a simple AOM implementation when no domain-specific is also simply implemented using collections as the types.
information is needed on the AOM classes. Fig. 7 presents The main reason for this choice for simplicity in the domain-
the main classes that are part of this implementation. independent model is the support for mapping domain-
The interface HasProperties is implemented by all specific models, presented in section IV-B. These domain-
the classes in this model to enable all of them to have addi- specific models can implement more advanced features and
tional custom metadata. The class ThingWithProperties relationship consistency rules, mapping the core structure to
provides a basic implementation for this functionality and is be compatible with other components.
used as a superclass. Besides that, it can be seen that the For instance, Esfinge AOM RoleMapper does not provide
model basically implements the Type Square pattern. direct support for entity type inheritance, but it is possible
1 http://esfinge.sourceforge.net/AOM.html - documentation available in to implement it in a domain-specific model and still map
portuguese the core structure. Additional information for these more
6 VOLUME X, 20XX

This work is licensed under a Creative Commons Attribution 4.0 License. For more information, see https://creativecommons.org/licenses/by/4.0/
This article has been accepted for publication in a future issue of this journal, but has not been fully edited. Content may change prior to final publication. Citation information: DOI
10.1109/ACCESS.2021.3087795, IEEE Access

Guerra et al.: A Model to Enable the Reuse of Metadata-based Frameworks in Adaptive Object Model Architectures

advanced features might be mapped as custom metadata, • @PropertyType: (Class) classes that play the Prop-
which can be retrieved and processed by AOM components erty Type role in the AOM architecture; (Field) the
that use the domain-independent model. Following this ap- attribute that refers to a Property Type corresponding to
proach, the framework AOM model might remain simple and a Property;
with the features that are more frequently needed in AOM • @EntityProperties: (Field) the attribute that
applications, but without limiting the applications only to refers to Properties of an Entity;
these features. • @FixedEntityProperty: (Field) attributes corre-
sponding to fixed properties in an Entity class;
B. MAPPING DOMAIN-SPECIFIC AOM MODELS • @Name: (Field) the attribute containing the name of an
The framework also supports the usage of domain-specific Entity Type or a Property Type;
AOM classes. The application classes that play a role in the • @PropertyTypeType: (Field) the attribute contain-
AOM architecture should receive code annotations for the ing the type of a Property Type;
framework to identify these roles and create adapters based • @PropertyValue: (Field) the attribute containing
on the domain-independent AOM model. This approach en- the value of a Property;
ables the reuse of AOM components created for the domain- • @CreateEntityMethod: (Method) the method of
independent AOM model in the application that defines its an Entity Type class that handles with the creation of
own AOM classes. an Entity with this type;
Another benefit of allowing the application to define its • @Metadata: (Field) a metadata list of a class that
own domain-specific AOM classes is that it has more free- represents an Entity Type or a Property Type.
dom to define a more suitable structure based on its adapt- • @FixedMetadata: (Field) a fixed metadata variable
ability requirements. As presented by a previous work [39], of a class that represents an Entity Type or a Property
the mapping enables the model to start simple and be evolved Type.
to implement more patterns. That also allows the specific • @MetadataMap: (Field) a metadata map of a class that
AOM model to contain more specific business rules and to represents an Entity Type or a Property Type.
have features not implemented by the framework domain- List. 3 presents an example of how the framework cre-
independent AOM model, such as entity type inheritance. ate adapters from mapped domain-specific AOM classes
List. 2 presents a domain-specific class that represents to its domain-independent API. The classes SensorType
an AOM entity configured with Esfinge AOM RoleMapper and Sensor are application-specific implementations of an
annotations. The annotation @Entity specifies that the AOM. The presented code create adapters to the framework
class plays the Entity role in AOM. Its attributes also receive API that can be reused by several applications with its own
annotations to map to what they represent. AOM model.
As expected, using the adapters will generate a perfor-
1 @Entity mance overhead introduced by the new layer introduced.
2 public class Sensor implements ISensor { This overhead is higher in creating the adapter when the
3
4 @EntityType framework search for annotations in the class elements using
5 private SensorType SensorType; reflection. In the adapter’s usage, the overhead will be mainly
6
7 @FixedEntityProperty an additional dynamic invocation to the adapted class mem-
8 private String owner; bers. An analysis of the adapters’ overhead from a domain-
9
10 @EntityProperty specific API to a domain-independent API was performed in
11 private List<SensorProperty> properties a previous study [38].
12 = new ArrayList<SensorProperty>();
13
14 //access methods omitted C. ADAPTING ENTITIES TO JAVA BEANS
15 }
The Esfinge AOM RoleMapper framework is able to adapt
AOM Entities to classes following the Java Bean specifica-
LISTING 2. Mapping domain-specific class that represents an entity. tion. For each property in the AOM entity, getter and setter
methods that handle the property value will be created in
The following list describes the core mapping annotations the Bean adapter. Additionally, if the entity type or an entity
defined by the framework. The annotation description ex- property has metadata, the generated adapter class might be
plains how the framework interprets it based on whether it created with a respective annotation. This section describes
is present in a class, field, or method: how the Esfinge AOM RoleMapper framework generates the
• @EntityType: (Class) classes that play the Entity Java Bean adapters.
Type role in the AOM architecture; (Field) an attribute The adapter is generated using bytecode manipulation. The
that references the Entity Type corresponding to an implementation used the ASM library. The class responsible
Entity; for generating the adapters is the AdapterFactory. When
• @Entity: (Class) classes that play the Entity role in an instance of the AdapterFactory is created, it is possi-
the AOM architecture; ble to pass as a parameter a file name with the annotation
VOLUME X, 20XX 7

This work is licensed under a Creative Commons Attribution 4.0 License. For more information, see https://creativecommons.org/licenses/by/4.0/
This article has been accepted for publication in a future issue of this journal, but has not been fully edited. Content may change prior to final publication. Citation information: DOI
10.1109/ACCESS.2021.3087795, IEEE Access

Guerra et al.

1 //create Entity Type 1 //Create adapter factory


2 SensorType sensorType = new SensorType(); 2 String fileName = "JsonMapTest.json";
3 SensorPropertyType sensorPropertyType = new 3 AdapterFactory af = AdapterFactory.getInstance(fileName);
SensorPropertyType(); 4
4 sensorPropertyType.setName("radiometerX"); 5 //AOM Entity Creation
5 sensorPropertyType.setPropertyType(double.class); 6 IEntityType contactType = new
6 sensorType.addPropertyTypes(sensorPropertyType); GenericEntityType("Contact");
7 7 // Details ommited
8 //create Entity 8 IEntity home = contactType.createNewEntity();
9 Sensor sensor = new Sensor(); 9 home.setProperty("phone", "1232312312");
10 sensor.setSensorType(sensorType); 10
11 11 //Adapter creation
12 // create adapted Entity Type 12 clientBean = af.generate(home);
13 IEntityType adaptedEntityType =
AdapterEntityType.getAdapter(sensorType);
14
15 // create adapted Entity LISTING 5. Creating a adapter entity with AdapterFactory.
16 IEntity entity =
AdapterEntity.getAdapter(adaptedEntityType, sensor);
17
18 // setting a value in the adapted entity each property type present in the target entity type, respective
19 entity.setProperty("radiometerX", value);
getter and setter methods based on the property name are
generated. The implementation of these methods accesses
LISTING 3. Adapting a domain-specific AOM model to the framework
domain-independent AOM model. the respective property in the IEntity instance adapted.
Similarly, for each RuleObject, a method that invokes the
respective execute() method on it is generated.
mapping configuration in a JSON format. List. 4 presents During the code generation, the algorithm searches for
an example of the annotation mapping file, where names of metadata mapped to code annotations. For the entity type,
metadata properties configured in AOM are associated with for each property type, and for each rule object present,
annotation class names. it will be verified if it contains a metadata entry with a
name present in the JSON file passed as a parameter for
1 "oneToOne":[ the AdapterFactory class. If an annotation mapping is
2 {"target":"method"},
3 {"annotationPath":"javax.persistence.OneToOne"}, found, the respective code annotation bytecode is generated
4 {"parameter_1": "mappedBy"}, for that element. That annotation will be present in the
5 {"parameter_2": "cascade"},
6 {"parameter_3": "fetch"} adapter class if a framework uses reflection to search for its
7 ], presence.
8
9 "joinColumn":[ List. 6 presents a code example that illustrates how would
10 {"target":"method"},
11 {"annotationPath":"javax.persistence.JoinColumn"},
be the generated adapter; however, it is generated directly in
12 {"parameter_1": "name"} bytecode and not in Java as illustrated in the listing. Consider
13 ]
that the annotations present on the listing were generated
based on the metadata on entity type and property type and
LISTING 4. Example of a JSON Annotation Mapping File. its respective mapping.
The framework supports the generation of properties of
The method generate() from AdapterFactory returns primitive types as well as specific class types. Besides, these
an instance of the adapter class that encapsulates an instance types may also be other AOM entities, which would trigger
of IEntity passed as a parameter. List. 5 presents an another adapter’s generation by the framework.
example of how the adapter is created. The framework checks After the adapter class is finished, it is added to the current
if there is already an adapter class generated for that entity thread classloader and stored in the Esfinge AOM RoleMap-
type. In case an adapter is already created, the method creates per cache. If an adapter of the same Entity Type is further
an instance of it that encapsulates the target entity and only needed, the framework will use the same generated class. If
returns it. Otherwise, a new adapter class for that entity the target Entity Type class is changed, the framework will
type is generated before that. Then, an instance of the class invalidate the cache and create an updated adapter the next
is created via reflection and returned by the generate() time needed.
method. The impact in performance caused by the Java Bean
The class adapter generated follows the naming standard adapter is mainly caused by the adapter generation when
entityTypeName+"AOMBeanAdapter". The adapter the AOM Entity Type structure is read, the bytecode of the
generation process consists in going through each of the adapter is generated, and the new class is dynamically loaded.
entity type elements and generate the respective Java Bean As presented in List. 6 the adapter class uses simple method
code. The code is generated directly in bytecode using the invocation and not reflection as in the adapter described in the
ASM library calling methods that generate the respective previous section. Consequently, it is expected an overhead
command. Initially, it is generated the base class code with by adding an additional processing layer, however not a very
an instance variable for the adapted IEntity object. For significant one.
8 VOLUME X, 20XX

This work is licensed under a Creative Commons Attribution 4.0 License. For more information, see https://creativecommons.org/licenses/by/4.0/
This article has been accepted for publication in a future issue of this journal, but has not been fully edited. Content may change prior to final publication. Citation information: DOI
10.1109/ACCESS.2021.3087795, IEEE Access

Guerra et al.: A Model to Enable the Reuse of Metadata-based Frameworks in Adaptive Object Model Architectures

1 @Entity by a descriptor that contains references to the get, set,


2 @Table(name = "sensor") add, and remove methods for each object field.
3 public class SensorOMBeanAdapter {
4 • Metadata Reader: implements the Metadata Reader
5 private IEntity entity; Strategy pattern [25]. A default metadata reader strategy
6
7 public SensorAOMBeanAdapter(IEntity entity) { was implemented to read the framework core annota-
8 this.entity = entity; tions to configure the AOM elements’ roles in domain-
9 }
10 specific models. It is an extension point that can receive
11 @Column(name = "radiometerX", nullable= true) other implementations from reading metadata in other
12 public String getRadiometerX() {
13 try { formats.
14 if(entity!=null){ • Metadata Repository: implements the Metadata Reposi-
15 return (String)entity.getProperty("radiometerX")
16 .getValue(); tory pattern [25], providing a memory cache of metadata
17 }else{ already retrieved.
18 return null;
19 } • Annotations: contains the Java annotations presented in
20 } catch (EsfingeAOMException e) { Section IV-B that allow the identification of the roles of
21 throw new RuntimeException(e);
22 } AOM elements in domain-specific AOM applications.
23 } In the diagram it is represented by the Metadata compo-
24 public void setRadiometerX(String a) {
25 try { nent.
26 if(entity != null){
27 entity.setProperty("radiometerX", a);
The AOM Core API includes a set of interfaces represent-
28 } ing the standard structure of the AOM model provided by
29 } catch (EsfingeAOMException e) {
30 throw new RuntimeException(e);
the framework. AOM Core Implementations contains imple-
31 } mentations of these interfaces, containing both the domain-
32 }
33 }
independent implementation and the adapters. Each adapter
contains an attribute to store the application AOM object for
the specific domain they adapt.
LISTING 6. Example of the structure of an adapter class constructed by
Esfinge AOM RoleMapper. The Model Manager is responsible for instantiating the
model and managing the AOM Core API instances created
by the framework. The main class of this component is the
D. INTERNAL STRUCTURE ModelManager. All operations involving manipulating the
The proposed framework’s internal structure is composed of model, including the persistence and loading, must be done
four components: Metadata Handler, AOM Core API, AOM through this class.
Core Implementations, and Model Manager. Fig. 8 presents One of the ModelManager class’s primary responsibili-
the main components of the Esfinge AOM RoleMapper ties is to ensure that a logical element is not instantiated twice
framework. in the framework. It contains two maps of objects - one to
store the entities loaded by their IDs and another to store the
entity types loaded by their IDs.

V. CASE STUDY WITH HIBERNATE


Aiming to verify if the proposed solution could be used
to reuse a complex framework for an adapted AOM, we
conducted a case study in which the goal was to persist a
group of entities using the Hibernate framework [24]. The
objective is to perform a functional evaluation if the proposed
AOM framework model’s implementation can be used with a
real-world framework. In this case study, we exercised the
generation of the Java Bean adapter, converting the AOM
metadata into code annotations. It was also verified if the
adapter works well when the entity has relationships with
another one. Hibernate was chosen for being a well known
FIGURE 8. Core Components of Esfinge AOM RoleMapper Framework. metadata-based framework with a complex metadata schema
composed of several annotations. The HSQLDB was the
database system selected for the case study; however it can
Metadata Handler is responsible for retrieving metadata be easily reproduced for other relational databases.
from application classes. In its internal structure, the com- The case study consisted of persisting with Hibernate two
ponent is organized in the following parts: related AOM entities. We created two entity types named
• Descriptors: implement the Metadata Container pattern Client and Contact, in which the entity type Client
[25]. Each role in an AOM architecture is represented has a property named mainContact of the entity type
VOLUME X, 20XX 9

This work is licensed under a Creative Commons Attribution 4.0 License. For more information, see https://creativecommons.org/licenses/by/4.0/
This article has been accepted for publication in a future issue of this journal, but has not been fully edited. Content may change prior to final publication. Citation information: DOI
10.1109/ACCESS.2021.3087795, IEEE Access

Guerra et al.

Contact. The metadata were added in the AOM structure 1 //Creating entity type and property of COntact type
mapping a one-to-one relationship, as if there was a Client 2 IEntityType clientType = new
GenericEntityType("Client");
class with the @OneToOne Hibernate annotation. The entity 3 IPropertyType contactPropertyType = new
types were created using the domain-independent API of the GenericPropertyType("mainContact", contact);
4 clientType.addPropertyType(contactPropertyType);
Esfinge AOM RoleMapper framework. The code snippets 5

presented in this section aim to illustrate the process, and 6 //Configuring one to one relationship metadata
7 Map<String, Object> oneToOneParams = new HashMap<>();
parts of it might be omitted to focus on the most important 8 oneToOneParams.put("cascade", CascadeType.REMOVE);
parts. 9 oneToOneParams.put("fetch", FetchType.EAGER);
10 contactPropertyType.setProperty("oneToOne",
oneToOneParams);
11 Map<String, Object> joinColParams = new HashMap<>();
A. CODE DESCRIPTION 12 joinColParams.put("name", "fk_contact");
13 contactPropertyType.setProperty("joinColumn",
The Contact entity type should be created first, since it joinColParams);
would be used as the type of a property from the Client
entity type. A sample of the code that generates Contact
entity type is presented in List. 7. In this code, the metadata LISTING 8. Creation of Client entity with mapped Hibernate annotations.

mapped to the annotations @Table and @Entity are added


into the entity type. For annotations that receive parameters 1 //create Client entity
like @Table, a map should be used for their configuration. 2 IEntity client = client.createNewEntity();
3 client.setProperty("id", 55L);
4 client.setProperty("name", "Guerra");
5 client.setProperty("weight", 110.55);
1 //Contact annotation parameters 6
2 IEntityType contactType = new 7 //create Contact entity
GenericEntityType("Contact"); 8 IEntity home = contact.createNewEntity();
3 IPropertyType idPropertyType = new 9 home.setProperty("id", 100L);
GenericPropertyType("id", Long.class); 10 home.setProperty("phone", "1232312312");
4 contactType.addPropertyType(idPropertyType); 11 home.setProperty("type", "work");
5 IPropertyType phonePropertyType = new 12
GenericPropertyType("phone", String.class); 13 //set bidirectional relationship
6 contactType.addPropertyType(phonePropertyType); 14 home.setProperty("client", client);
7 IPropertyType typePropertyType = new 15 client.setProperty("mainContact", home);
GenericPropertyType("type", String.class); 16
8 contactType.addPropertyType(typePropertyType); 17 //adapter generation
9 18 AdapterFactory af =
10 //Contact annotation configuration AdapterFactory.getInstance("AnnotationMapping.json");
11 Map<String, Object> parametersPerson = new HashMap<>();
12 parametersPerson.put("name", "tb_contato"); 19 Object clientBean = af.generate(client);
13 contactType.setProperty("table", parametersPerson);
14 contactType.setProperty("entity", true);
LISTING 9. Creation of enitities and its adapters.

LISTING 7. Creation of Contact entity type with respective metadata.

Finally, the last step is to invoke Hibernate functionality


Code to create the Client entity type, whose a snippet
to persist the adapter, as presented in List. 10. To config-
is presented on List. 8, is similar to the one for creating
ure Hibernate, it is necessary to add the target classes in
Contact. The property mainContact receives the entity
its Configuration object, which is used to create the
type as its type, creating a relationship. Further, it is config-
Session instance. After that, the framework functionality
ured metadata for mapping the relationship in the database
was invoked in the adapter to persist its data. As a result,
tables, and it is added in the property type. With a similar
it was verified in the HSQLDB database that the data was
code, because Hibernate mapped relationships need to be
persisted as expected.
bidirectional, it was also added a property type in Contact
with the Client type. It is essential to highlight that the
1 //Configuring classes in Hibernate
entity types were created directly on code for this case study, 2 Configuration configuration = new Configuration().
but usually, they are created loading data from metadata 3 configuration.addAnnotatedClass(clientBean.getClass());
4 configuration.addAnnotatedClass(clientBean.getClass().
sources. 5 getMethod("getMainContact").getReturnType());
After configuring the entity types, the next step is to 6
7 //Persisting entities
create the entities themselves. List. 9 presents the code that 8 SessionFactory sessionFactory =
creates and sets the properties data for each entity and fol- configuration.buildSessionFactory();
9 Session session = sessionFactory.openSession();
lows configuring the bidirectional relationship. After that, the 10 session.getTransaction().begin();
AdapterFactory is created, receiving the name of the file 11 session.save(clientBean);
12 session.getTransaction().commit();
that contains the annotation mapping. The content of this file 13 session.close();
has the same format as the one presented in List. 4. Finally,
the method generate() receiving the AOM entity as an
LISTING 10. Persistence of AOM entities using adapters in Hibernate.
argument is used to create the Java Bean adapter.
10 VOLUME X, 20XX

This work is licensed under a Creative Commons Attribution 4.0 License. For more information, see https://creativecommons.org/licenses/by/4.0/
This article has been accepted for publication in a future issue of this journal, but has not been fully edited. Content may change prior to final publication. Citation information: DOI
10.1109/ACCESS.2021.3087795, IEEE Access

Guerra et al.: A Model to Enable the Reuse of Metadata-based Frameworks in Adaptive Object Model Architectures

B. CASE STUDY ANALYSIS VI. EXPERIMENT DESIGN


The main result of the case study was to demonstrate the This section outlines the design of the experimental study
feasibility of the proposed model and its respective imple- used to assess our framework model proposal implemented
mentation. By being able to use the Hibernate framework by Esfinge AOM RoleMapper. In this experiment, a solution
functionality based on the adapter generated, it was shown reusing an existing metadata-based framework created for
that is possible to reuse a metadata-based framework for regular classes is compared to another that creates an specific
AOM entities. However, some particular difficulties were logic accessing directly the AOM model. Since this second
encountered during the development of this experiment. This approach instead of metadata configuration uses method in-
practical knowledge is reported in this section to enable vocations to retrieve data from the entities, it is referred as
insights for future works and studies. the one that uses imperative code.
The first issue was about the Configuration class in- We have performed this experiment based on the guide-
stantiated in List. 10. Usually, applications create this object lines provided by Wholin [41]. From this experiment, the
based on external configuration files. Since it needs to receive following research questions were investigated:
the classes that would be persisted by the framework, and • RQ1: How does the development time differ by compar-
because the adapter classes are available only in runtime, this ing both approaches?
configuration needs to be done in code. That raises a relevant • RQ2: Are developers able to understand the proposed
issue about the suitability of the framework for this kind of approach based on the documentation provided, and
reuse based on the moment that it reads the class annotations. successfully implement the functionality required?
The framework should receive that class to be processed in • RQ3: What were the main difficulties encountered by
runtime to enable its reuse in this scenario. If it only supports the developers in both approaches?
classes received in configuration files, since the adapters are • RQ4: What are the benefits and drawbacks of the pro-
only available in runtime, it can be an impediment. posed approach to reuse the framework functionality
Another limitation found during the case study was that the from the developers’ point of view?
adapter classes must be loaded in the same ClassLoader • RQ5: What is the developers’ level of acceptance con-
used by Hibernate; otherwise the framework does not find cerning the approach proposed to reusing the function-
the classes allocated in the ClassLoader cache. The so- ality of a framework that uses the generated adapter for
lution used was to set the ClassLoader used to create the AOM entity?
the adapters in the current Thread from the application.
Depending on how the target framework locates and uses A. GOAL
the classes it manipulates in runtime, sharing the same
Following Basili’s Goal-Question-Metric-GQM [42], the
ClassLoader might be critical to making the solution
goal of this experiment is: to analyze an approach for reusing
work.
functionality of a framework that uses the generated adapter
Hibernate is a complex framework that uses resources
for the AOM entity, for the purpose of evaluating it with
that manipulates the bytecode from the application classes
regard to the amount of time spent completing a task, the
and manage the object’s life cycle. Because of that, we
perceived ease of use, usefulness and benefits from the view-
found some problems in using some of its functionality,
point of software developers, in the context of software design
such as the processes triggered by the methods merge()
and postgraduate course from the National Institute of Space
and persist(), and the usage of some options for
Research.
CascadeType. In the end, we made it work by using the
save() method that does not rely on any of these resources;
B. VARIABLES, TREATMENTS AND OBJECTS
however, that also raises a relevant issue about the interaction
between the internal framework functionality and the adapter There are two independent variables: the two validation ap-
implementation. Future studies might investigate what might proaches (treatments) and the experimental objects (Task 1
prevent the framework reuse and identify possible solutions and Task 2). One objective dependent variable is the amount
to overcome each issue. of time spent completing a task (response variable). Also,
In conclusion, on the one hand, the case study demon- there are two dependent subjective variables: developers’
strated the feasibility of the proposed approach; on the other perceived ease of use and usefulness, calculated by closed-
hand, it also has shown that there are some complex in- questions and open-questions to obtain feedback from the
teractions between the adapters and the internal framework participants.
solutions that might prevent its reuse. Load-time metadata
reading, ClassLoader compatibility, control of object C. PARTICIPANTS
lifecycle, and usage of bytecode manipulation were some of We selected 21 participants among students enrolled in grad-
the issues found in this case study. These findings are going to uate courses in software design from the National Institute
be used to guide more studies and the evolution of the current of Space Research. As a requirement to participate in the
solution. experiment, the participant needed to have experience in
programming using the Java language and have knowledge
VOLUME X, 20XX 11

This work is licensed under a Creative Commons Attribution 4.0 License. For more information, see https://creativecommons.org/licenses/by/4.0/
This article has been accepted for publication in a future issue of this journal, but has not been fully edited. Content may change prior to final publication. Citation information: DOI
10.1109/ACCESS.2021.3087795, IEEE Access

Guerra et al.

TABLE 1. Participants background reused.


Based on these requirements, we decided to use the im-
Experience Group Min Mean Max StDev plementation of validation constraints for a given entity
Programming G1 1 9.83 20 6.18 type. The target framework to be reused was the Hibernate
G2 2 7.89 25 7.24 Validator, which uses annotations on the class properties to
Java Language G1 0 6.25 16 5.05
G2 1 4.11 10 3.10 define such constraints. For example, the annotation @Max
can be used to define a constraint about a numeric property’s
maximum value. Based on this example, it is possible to
observe that the code to verify the maximum value of a
about reflection and code annotations. Despite Master and
property would not be much more complicated them the
Ph.D. students were participating, most of the participants
configuration of this constraint using metadata. Although the
at that moment were working in industry and attending the
chosen framework has "Hibernate" in its name, it has an
course as external students. The 21 participants were split
entirely different scope than the one used in Section V.
into two groups, which 12 were assigned to Group 1, and the
The participants’ tasks were designed with the following
remaining 9 were assigned to Group 2. Table 1 shows some
format: it was defined an entity type with 7 properties and a
statistics about participants’ background in terms of years of
validation constraint for each one of them. For each property,
experience as programmers and with the Java language. The
it was given an automated test suit that verifies the constraints
inferential statistic shows that the two groups are balanced in
using the required interfaces for the solution. Two different
terms of their experiences because no significant differences
tasks with a similar format but with different entities and
were found between groups regards these two requirements
constraints were specified.
– p-values 0.474 and 0.247, respectively.
Summarizing, the participants of the experiment devel-
As for participants’ expertise on frameworks and annota- oped the source code to validate constraints in their attributes
tions, most of them – about 80% (16) – had some experience for two different AOM entities. For one entity, participants
about it. Nevertheless, all the participants received training should develop the validation by accessing the property
about reflection and code annotations in order to homogenize values and verifying the constraints with imperative code
their knowledge. This training involved theoretical classes (Approach 1). For the other entity, they should configure
and practical code exercises. metadata in the AOM entity type, generating the adapter and
reusing the Hibernate Validator functionality (Approach 2).
D. TASK DESIGN AND DESCRIPTION The choice to use a single entity type was based on the
The current alternatives to the proposed approach in a Java fact that Esfinge framework process dependencies in an auto-
AOM application are: to develop an application-specific mated way, as presented in section V, and a more complex
AOM framework tailored to the application AOM model; or structure would bring complexity only for the competing
to create a logic that access directly the entity information. approach, in which it is needed to browse the AOM entity
The other existing frameworks found in the literature, pre- structure. Since the experiment goal is to evaluate the reuse
sented in section IX are implemented in other languages and of existing metadata-based framework and it does not intend
differ also in other matters, making a comparison to them to to evaluate the usage of the AOM structure, we considered
present several other factors that could influence in the result, that more complex entities could bring undesired interference
taking away the focus from the framework reuse solution. to the results. To evaluate the task complexity in terms of
Including the development of an specific AOM framework metadata configuration, the metric Unique Annotations in
in the experiment would generate a high effort only for one Class (UAC) [36] was considered. Based on an analysis
of the competing approaches, and creating that framework considering the 90 percentile, the study identified 3, 4 and
as part of the setup would generate a solution that would be 9 as reference values for very frequent, frequent and less
similar to the usage of the adapted framework. frequent. Considering that the tasks required the usage of
Given these alternatives, we decided to compare the pro- 7 different mapped framework annotations, and this value
posed approach with the creation of imperative logic that is between the percentiles frequent and less frequent, we
access directly the entity information. To design the activities argue that the task complexity suitably represents a realistic
for the experiment, we considered the following require- scenario in terms of the amount of metadata that would be
ments: (a) the functionality that would be reused from the necessary in a real system.
existing framework should be easy to be performed using
directly imperative code; (b) the framework used should E. PROCEDURE
be based on metadata and well known by the development We carried out an experiment in which study units were
community. The first requirement was considered to make assigned to experimental groups nonrandomly; therefore, it
possible the fairest comparison with the competing approach. is considered a quasi-experiment [43]. As shown in Table 2,
We searched for tasks where the imperative code to create the experiment was designed in a way so that each subject
the functionality would have the same amount of code as the group uses the two treatments – first using imperative code
declarative definition of metadata for the framework to be (Approach 1) and other using Esfinge AOM RoleMapper and
12 VOLUME X, 20XX

This work is licensed under a Creative Commons Attribution 4.0 License. For more information, see https://creativecommons.org/licenses/by/4.0/
This article has been accepted for publication in a future issue of this journal, but has not been fully edited. Content may change prior to final publication. Citation information: DOI
10.1109/ACCESS.2021.3087795, IEEE Access

Guerra et al.: A Model to Enable the Reuse of Metadata-based Frameworks in Adaptive Object Model Architectures

TABLE 2. Experimental design a: Internal Validity


Threats to internal validity concern analyses if the treatment
Approach 1 Approach 2 causes the results (the effect) [41]. We have avoided some
Group N Task 1 Task 2 Task 1 Task 2 social threats to internal validity – e.g., compensatory ri-
G1 12 X X valry and resentful demoralization – since all participants
G2 9 X X experienced both treatments. We elaborated on two different
tasks that were applied in a cross-over way to distinguish
the groups and mitigate the effect of diffusion or imitation
Hibernate Validator (Approach 2) – on two objects – Person of treatments that occurs when a group learns about the
entity (Task1) and Billing entity (Task 2). treatment from another group. Our sample includes partici-
After completing the tasks, the participants had to fulfill pants with a similar background – master and Ph.D. students
a questionnaire to answer questions about their experience with knowledge in Java Programming – but with different
using both approaches. experiences. However, the two groups were balanced in terms
of background knowledge. All participants were qualified for
F. EVALUATION the experiment. We provided the same training in order to
The evaluation was performed based on the questionnaire align their knowledge about reflection and code annotations.
filled by the participants. In the first part of the questionnaire, All subjects were guided by the same experimental proce-
the participants had to answer the following topics regarding dure, including the instructions to allocate a period seeking
the execution of the tasks in both approaches: to avoid interruptions and choose a comfortable environment
to perform their tasks.
• the time spent to complete each task;
• the needs to interrupt the activities, and why;
b: External Validity
• the difficulties in completing the tasks;
Threats to external validity is concerned with the generaliza-
• the needs for additional information, and what sort of
tion of the results to industrial practice [41]. All participants
information.
are regular students of masters or doctorate programmes who
In the last part of the questionnaire, the participants had have attended the Design Patterns course. Notwithstanding,
to highlight each approach’s benefits and drawbacks. Addi- at that moment, most of them were working on industry.
tionally, they needed to report which of the two approaches Furthermore, the experiment occurred in the developer en-
they would choose in a real AOM application, giving reasons vironment to reproduce a more realistic and comfortable
for its choice. There was also a field on this form in which situation. Although we believe that results can be generalized
participants could add any other comments. to industrial practice, it is ideal that the experiment can be
In order to evaluate our results, we defined the following replicated in an industrial environment involving professional
metrics for each Research Question (RQ). Research Question developers and in communities of Java developers. The tasks
1 (RQ1) is answered by comparing the amount of time spent were small because our goal was to create and validate
completing tasks using both approaches, using descriptive two single AOM entities allowing a more straightforward
and inferential statistical, which is detailed in the Results experiment to avoid the fatigue to the participants (internal
section. To answer RQ2, we combined the tests results for validity). Such tasks, however, represent only a part of the
each task with the participants’ answers to the questionnaire. actual software-building activity. In order to have a sce-
RQ3 is answered by analyzing the participants’ answers with nario closer to building a complete software system, more
regards to the type of difficulties encountered, using descrip- complete experiments can be conducted, such as making a
tive and inferential statistical. RQ4 is answered according to complete system functionality or implementing a complete
the participants’ answers to the question related to perceived use case with its primary and alternative flows being tested.
benefits and drawbacks, using descriptive and inferential Of course, we still need to assess the cost of this.
statistical. Finally, RQ5 is answered by analyzing the par-
ticipants’ answers to the question related their acceptance c: Construct Validity
concerning the approach proposed of reusing functionality Threats to construct validity are the analysis of the relation-
of a framework that uses the generated adapter for the AOM ship between theory and observation [41]. We have mitigated
entity. This qualitative analysis consisted of mapping the rea- the mono-operation bias by elaborating on two different
sons related by participants with the difficulties, advantages, tasks with an equivalent number of requirements and fea-
and drawbacks. tures. Nevertheless, the experiment was subject to the mono-
method bias because it involved a single objective measure
G. THREATS TO VALIDITY – spent time to perform the tasks. Other measures could be
In this subsection, it is discussed possible threats to our ex- considered, such as productivity and effectiveness. Neverthe-
periment in terms of internal validity, external validity, con- less, the code to use the framework and the integration tests
struct validity, and conclusion validity, according to Wohlin had already been previously prepared, and the tasks were
et al. [41]. small. Thus, the number of lines of code produced by the
VOLUME X, 20XX 13

This work is licensed under a Creative Commons Attribution 4.0 License. For more information, see https://creativecommons.org/licenses/by/4.0/
This article has been accepted for publication in a future issue of this journal, but has not been fully edited. Content may change prior to final publication. Citation information: DOI
10.1109/ACCESS.2021.3087795, IEEE Access

Guerra et al.

TABLE 3. Descriptive statistics on time spent on each approach and task.

Group Task Approach Mean StDev Min Median Max N


G1 T1 A1 34.25 30.23 9.00 23.50 120.00 12
G2 T1 A2 58.44 27.60 15.00 50.00 102.00 9
G1 T2 A2 39.83 29.76 8.00 25.00 110.00 12
G2 T2 A1 45.67 25.32 17.00 40.00 84.00 9

participants were very similar. Regarding the experimental


design, we could have also adopted the treatments cross-
over to verify if the order of application is a factor that can
influence the results.
FIGURE 9. Box plot representing development time per task and approach

d: Conclusion Validity
TABLE 4. Hypothesis testing on time spent on each approach and task.
Threats to conclusion validity concern issues that could af-
fect our analysis about the outcomes of the experiment, for
Group Task Approach Shappiro-Wilk t-Test Wilcoxon
instance, choice of sample sizes, choice of statistical tests,
care taken in the implementation and measurement of an G1 T1 A1 .001 N/A .556
T2 A2 .038
experiment [41]. This experiment has low statistical power of G2 T2 A1 .299 .215 N/A
the tests since the number of participants is not enough to ob- T1 A2 .777
tain a significant effect. Hence, we have considered the data
as indicators rather than conclusive. Regarding the choice
of statistical tests, we have verified the normality of data adapter for the AOM entity than performing the same task
before choosing them. Thus, we used both parametric and using imperative code.
non-parametric statistics to test our hypotheses, considering The results of our analysis are presented in Table 4.
that our analysis was carried out in paired samples. Besides, As showed in Table 4, the result of the t-Test (p-value =
we chose an appropriate level of significance when testing 0.215) and the result of the Wilcoxon test (p-value = 0.556)
the null hypotheses. revealed no statistically significant differences at the 0.05
level of alpha. This indicated that the null hypothesis could
VII. EXPERIMENT RESULTS not be rejected. Therefore, the time required to complete the
This section presents the experimental study results, and it is tasks in both approaches is similar. The small differences
organized to answer tour five Research Questions (RQ), as between the two approaches may be related to other factors,
follows. such as the participants’ experience.

A. DEVELOPMENT TIME (RQ1) B. PROPER DOCUMENTATION (RQ2)


The results of the time spent (in minutes) in each task per To complete the task using an imperative code (A1), about
group are reported in Table 3. It presents average values 48% of the participants (10 of 21) stated that they had to
(Mean), standard deviation (StDev), minimal value (Min), consult information about validation methods and some con-
median value (Median), and maximal value (Max). By ex- tent on regular expressions. Regarding the proposed approach
amining the spent time per task, Task 1, on average, required (A2), only one-third (7 of 21) of the participants searched for
more time when performed with our approach (A2) than with additional information about the Esfinge (3) and Hibernate
the approach using imperative code (A1). However, Task 2 (4) frameworks. A single participant stated that he could
was performed in less time with the proposed approach (A2). not complete the task with approach A1, claiming a lack
The box plots presented in Fig. 9 graphically compare the of programming experience. However, the same participant
time spent. The graphs show two outliers, which we have completed the task with the proposed approach (A2) based
opted not to exclude since it is an event that may occur again on the provided documentation and a short search on the web.
if subjects with little experience are recruited. Thus, we found that most participants could understand the
To verify statistical significance between the two ap- proposed approach based on the documentation provided to
proaches, we first used the Shapiro-Wilk test to check successfully implement the functionality required, including
whether or not the data were normally distributed. From the the less-experienced developers.
normality test results, we compared two samples using the
Paired t-Test and two others using the Wilcoxon test. We test C. DIFFICULTIES ENCOUNTERED (RQ3)
the following null hypothesis H01: There is no significant As for the developers’ difficulties, 14 participants reported
difference in thee tasks reusing functionality of time spent some difficulty using the approach A1; 18 participants re-
between performing tha framework that uses the generated ported some difficulty using the proposed approach A2. Table
14 VOLUME X, 20XX

This work is licensed under a Creative Commons Attribution 4.0 License. For more information, see https://creativecommons.org/licenses/by/4.0/
This article has been accepted for publication in a future issue of this journal, but has not been fully edited. Content may change prior to final publication. Citation information: DOI
10.1109/ACCESS.2021.3087795, IEEE Access

Guerra et al.: A Model to Enable the Reuse of Metadata-based Frameworks in Adaptive Object Model Architectures

5 presents the contingency table for difficulties encountered showed that there is no association between the perceived
by them. drawbacks and the approaches or tasks.
As shown in Table 5, about 29% of the participants en-
countered difficulties in understanding the specification and E. ACCEPTANCE LEVEL (RQ5)
documentation in both approaches. Specifically, concerning As mentioned earlier, we questioned the participants on
the proposed approach, 52.38% of the participants (11 of which of the two approaches they would choose to implement
21) stated that the main difficulty was to define metadata a given validation feature. Also, we asked them to provide
in AOM entities. Difficulties in knowing methods related to the reason for their choices. This question intended to collect
String (14.29%) and Date (28.57%) were issues exclusively the level of acceptance of the developers concerning the
encountered when some participants used the imperative approach proposed of reusing functionality of a framework
code (A1), while to handle the Java Bean Adapter was an that uses the generated adapter for the AOM entity. Analysis
issue encountered when 6 participants (28.57%) were using of the qualitative data consisted of mapping the reasons
the proposed approach (A2). related by participants with the difficulties, advantages, and
For each question about the difficulties, we applied drawbacks, which were mentioned in previous sessions.
Fisher’s exact test to verify the following null hypothesis Only three participants chose approach A1. One of the
H02: The difficulties encountered are not associated with the participants (P1) justified his choice by highlighting two
approaches or task type. Fisher’s exact test showed only an difficulties of approach A2: (i) difficulties to handle the Java
association between the difficulty to work with the Hibernate Bean; and (ii) difficulties in defining and mapping metadata.
Validator framework and the approach (A2) related to Task As a justification, the second participant (P15) highlighted
1 that was performed by the G2 group (p ≤ 0.05). That two benefits of approach A1: flexibility and greater control
is, the group that performed Task 1 using Esfinge AOM in development. Moreover, the third participant justified his
Role Mapper, reported that it was more difficult to use the choice also because of the difficulty of defining and mapping
metadata-based framework used. However, since both tasks metadata. Such reasons may be related to the participants’
used similar constraint types, we did not find any particular length of professional experience since productivity seems to
reason for this association. be a key measure.
The other 18 participants (85.7%) chose the proposed
D. PERCEIVED BENEFITS AND DRAWBACKS (RQ4) approach (A2). Despite a learning curve required to under-
Table 6 the contingency table for benefits of both approaches stand how to do (P20) and other difficulties encountered,
perceived by participants. Regarding approach A1, the main some participants perceived the usefulness of the approach
benefit pointed out by 8 participants was simplicity, which due to reusing the code (P2, P6). After the learning period,
was not mentioned by any participant regarding the proposed some participants perceived that the result could be easier to
approach (A2). However, some participants recognized as maintain (P3, P4, P8, P14). Several participants mentioned
benefits of the proposed approach (A2) the ease of mainte- the simplicity and efficiency of the approach to insert and
nance (5 of 21), the fact on reusing an existing framework change validations consistently (P5, P7, P8, P9, P10, P11,
(6 of 21), and the possibility to store and quickly change the P13, P16, P18, P20), as well as code flexibility with the
validation metadata (6 of 21). creation of adapters (P8, P18) and its readability (P17). One
For each question about the benefits, we applied Fisher’s of the participants (P9) stated that, from understanding how
exact test to verify the following null hypothesis H03: The to do the transformation for Java Beans, writing the specifica-
benefits pointed out are not with the approaches or task tions became very intuitive. So, he took only 8 minutes – the
type. Fisher’s exact test showed that there is no association shortest time reported – to complete the task using approach
between the benefits pointed out and the approaches or tasks. A2. Furthermore, one of the participants (P5) suggested
Table 7 presents the contingency table for drawbacks per- creating a set of validation rules to avoid parameterizations
ceived by participants. About 43% of the participants (9 of as much as possible.
21) reported that the main drawback is the repetitive code
generated for various entities in approach A1. Moreover, 6 VIII. DISCUSSION
participants (28.57%) reported that the validation informa- As previously explained, we carried out a case study aimed
tion is “hard-coded”. As for approach A2, about 52% of the to evaluate the feasibility of the solution persisting two enti-
participants (11 of 21) reported that the main drawback was ties with a relationship using the Hibernate framework. The
due to a learning curve required to understand how to do; feasibility was confirmed since the functionality was able to
and 6 participants (28.57%) reported that the task to define be implemented successfully. Additionally, the study iden-
metadata is complex. tified some limitations that can prevent using the proposed
For each question about the perceived drawbacks, we model according to the metadata-based framework’s internal
also applied Fisher’s exact test to verify the following null solutions. Some features that can be incompatible are load-
hypothesis H04: Drawbacks perceived are not associated time metadata reading, ClassLoader compatibility, control of
with the approaches or task type. And, Fisher’s exact test object lifecycle, and bytecode manipulation.
VOLUME X, 20XX 15

This work is licensed under a Creative Commons Attribution 4.0 License. For more information, see https://creativecommons.org/licenses/by/4.0/
This article has been accepted for publication in a future issue of this journal, but has not been fully edited. Content may change prior to final publication. Citation information: DOI
10.1109/ACCESS.2021.3087795, IEEE Access

Guerra et al.

TABLE 5. Contingency table for difficulties encountered

Approach 1 Approach 2
Difficulties Task 1 Task 2 Total p* Task 1 Task 2 Total p*
To understand the specification and documentation Yes 3 3 6 4 3 7
No 9 6 15 1.000 5 9 14 0.350
To understand unit tests Yes 1 0 1 0 0 0
1.000 1.000
No 11 9 20 9 12 21
To work with the Esfinge AOM Role Mapper classes Yes 2 4 6 3 2 5
0.331 0.611
No 10 5 15 6 10 16
To know methods related to String Yes 2 1 3 N/A N/A N/A N/A
1.000
No 10 8 18 N/A N/A N/A N/A
To know methods related to Date Yes 3 3 6 N/A N/A N/A N/A
1.000
No 9 6 15 N/A N/A N/A N/A
To work with the Hibernate framework Yes N/A N/A N/A N/A 6 1 7
0.016*
No N/A N/A N/A N/A 3 11 14
To define metadata in AOM entities Yes N/A N/A N/A N/A 5 6 11
1.000
No N/A N/A N/A N/A 4 6 10
To understand and know with Java Bean adapter Yes N/A N/A N/A N/A 3 3 6
No N/A N/A N/A N/A 6 9 15 1.000

* Fisher’s Exact Test

TABLE 6. Contingency table for perceived benefits

Approach 1 Approach 2
Benefits Task 1 Task 2 Total p* Task 1 Task 2 Total p*
Simplicity Yes 4 4 8 0 0 0
0.673 1.000
No 8 5 13 9 12 21
Development speed as benefit Yes 0 1 1 3 1 4
0.429 0.272
No 12 8 20 6 11 17
Ease of maintenance Yes 0 1 1 1 4 5
0.429 0.338
No 12 8 20 8 8 16
Do not require prior knowledge of the developer Yes 4 2 6 N/A N/A N/A N/A
0.659
No 8 7 15 N/A N/A N/A N/A
Flexibility (any kind of validation can be done) Yes 3 0 3 N/A N/A N/A N/A
0.229
No 9 9 18 N/A N/A N/A N/A
Reusing an existing framework Yes N/A N/A N/A N/A 2 4 6
0.659
No N/A N/A N/A N/A 7 8 15
Validation metadata can be stored and changed quickly Yes N/A N/A N/A N/A 3 3 6
No N/A N/A N/A N/A 6 9 15 1.000

* Fisher’s Exact Test

TABLE 7. Contingency table for perceived drawbacks

Approach 1 Approach 2
Drawbacks Task 1 Task 2 Total p* Task 1 Task 2 Total p*
The generated code is more complex Yes 0 2 2 1 2 3
No 12 7 19 0.171 8 10 18 1.000
Development speed as a drawback Yes 0 1 1 1 0 1
0.429 0.429
No 12 8 20 8 12 20
A repetitive code would be generated for various entities Yes 5 4 9 N/A N/A N/A N/A
1.000
No 7 5 12 N/A N/A N/A N/A
The validation information is hard-coded Yes 4 2 6 N/A N/A N/A N/A
0.659
No 8 7 15 N/A N/A N/A N/A
It is difficult to reuse Yes 2 0 2 N/A N/A N/A N/A
0.486
No 10 9 19 N/A N/A N/A N/A
It is hard to understand Java Bean adapter Yes N/A N/A N/A N/A 0 1 1
1.000
No N/A N/A N/A N/A 9 11 20
It is complex to define Metadata Yes N/A N/A N/A N/A 2 3 5
0.882
No N/A N/A N/A N/A 7 9 16
A great learning curve to understand how to do Yes N/A N/A N/A N/A 5 6 11
No N/A N/A N/A N/A 4 6 10 1.000

* Fisher’s Exact Test

16 VOLUME X, 20XX

This work is licensed under a Creative Commons Attribution 4.0 License. For more information, see https://creativecommons.org/licenses/by/4.0/
This article has been accepted for publication in a future issue of this journal, but has not been fully edited. Content may change prior to final publication. Citation information: DOI
10.1109/ACCESS.2021.3087795, IEEE Access

Guerra et al.: A Model to Enable the Reuse of Metadata-based Frameworks in Adaptive Object Model Architectures

Thus, we carried out an experiment aiming to assess


whether the proposed approach requires more time than the
development of an approach using imperative code and verify
the developers’ perception as to their ease of use, usefulness,
and benefits. Our approach, reusing functionality of a frame-
work that uses the generated adapter for the AOM entity,
is similar to the approach using an imperative code since
the statistical tests did not point at significant differences
between the two approaches regarding the time spent by the
developers when completing the tasks. Further experiments FIGURE 10. Metamodel from Oghma Framework [10] .
are needed to verify whether such findings can be extended
to cases involving (i) more complex tasks, including not only
the framework functionality, that better reproduce the reality the reuse of frameworks that were not created specifically
of the developers; (ii) an audience including only industry for AOM applications. The fact that recent works applied
practitioners and the community of Java developers; (iii) the concepts of AOM for different kinds of applications [3]–
use of other types of frameworks; and (iv) the collection of [9] highlights the relevance to contribute to the state-of-art
other objective measures. in the design of this kind of architecture. Thus, we do not
Regarding the developers’ perception as to ease of use, consider a demerit for our work the fact that there were not
usefulness, and benefits of the proposed approach, we found recent publications that relate directly to our contributions.
that despite the difficulties, all participants were able to Moreover, we are proposing a new solution to a relevant
complete the task using the proposed approach based on pro- problem in a well-established architectural style.
vided documentation. The main difficulty mentioned by them
was the definition of metadata in AOM entities. Moreover, A. OGHMA
the main drawback of the proposed approach, according to Oghma [10] is a framework based on the AOM architecture
52% of participants, refers to the learning curve needed to written in C#, which addresses several problems found in the
understand the solution. However, about 86% of participants development of AOM systems, such as integrity, runtime co-
would use the approach again, realizing its main benefits: evolution, persistence, user interface generation, communi-
(i) improves code maintainability, (ii) increases reuse of cation, and competition. It supports creating models similar
frameworks, and (iii) increases the speed to change and store to MOF (Meta-Object Facility) and UML (Unified Modeling
the validation metadata. Language), covering the entire cycle of system creation and
evolution.
IX. RELATED WORK Oghma allows changes in the system at runtime, providing
The relevance about studies about AOM can be confirmed a development style directed to an adaptation driven by
by some recent works found in the literature that used the end-user. Besides, the framework provides a structure
directly or were based on this architectural style, such as that supports the system evolution, having features such as
for economy mechanics in digital games [3], model-driven auditing the system and time travel to an arbitrary point
architectures [4], [5], data evolution in digital ecosystems [6], during its evolution. That means that it is possible to set the
meta-modeling architectures [7], and creating dynamic web system back into a past state.
services [8], [9]. But besides this architectural style is still The Oghma framework includes a set of interchangeable
applied, to the best of our knowledge, except for our previous components designed to have a high degree of flexibility.
work with Esfinge AOM Role Mapper [38]–[40], there are no It supports several types of persistence engines, including
other works in the last five years that focused on advances for relational, object-oriented, key-value and document-oriented,
the design of AOM architectures. and architectural styles such as single-process, client-server,
The two AOM frameworks found in the literature, Oghma and distributed.
[10] and Ink [11], are the closest related work to the one Fig. 10 presents the metamodel used by Oghma frame-
presented in this article. Considering that both works were work. This model provides a flexible basis for creating the
published around ten years ago, it is possible to conclude that application AOM structure. Even though not much flexibility
using frameworks for implemented AOMs was an approach is necessary when instantiating it in a system, several model
that did not become popular in the last years. However, we classes should be instantiated, and the developers should
believed that the reason for that is because these frameworks clearly understand the model. That complexity brought to the
enforce the usage of their own AOM structure and do not application can be considered one of the main drawbacks of
provide the possibility to integrate with other object-oriented adopting this framework.
frameworks. The next subsections present these two solutions In comparison to the solution presented in this article,
in more detail. Oghma has a higher number of components that can be used
The contribution of the present work focuses precisely on by the application if it instantiates the AOM model provided
the direction of eliminating one of these limitations, enabling by the framework. One of the differences of Esfinge AOM
VOLUME X, 20XX 17

This work is licensed under a Creative Commons Attribution 4.0 License. For more information, see https://creativecommons.org/licenses/by/4.0/
This article has been accepted for publication in a future issue of this journal, but has not been fully edited. Content may change prior to final publication. Citation information: DOI
10.1109/ACCESS.2021.3087795, IEEE Access

Guerra et al.

this language is to describe the logic associated with the


entities.

1 Metaclass id="Movie" class="ink.core:InkClass"


super="ink.core:InkClass" {
2 java_path ""
3 java_mapping "State_Behavior_Interface"
4 properties {
5 property class="ink.core:StringAttribute" {
6 name "title"
7 mandatory true
8 }
9 property class="ink.core:StringAttribute" {
10 name "rating"
11 mandatory true
12 }
FIGURE 11. Class Diagram from Ink Framework Metamodel [11] . 13 }
14 }

Role Mapper is that it allows the application to define its FIGURE 12. Example for Entity Definition in Ink.
own AOM model with a suitable level of complexity and
adaptability required by the target application. Additionally, Using two languages, one dynamic for structure and an-
the contribution that is the main focus of this article allows other static language for behavior, the framework combines
the reuse of frameworks created for a regular object-oriented both worlds’ benefits. This approach promotes a style of pro-
structure, which compensate for the need for having several gramming with a strict separation of structure and behavior.
specific components. On the other hand, Oghma only allows To avoid a problem of type duality between the two
the reuse of components created for its own structure. languages, the solution includes an Integrated Development
Environment (IDE) and an Ink Virtual Machine (IVM). The
B. INK IDE imposes mapping rules between types and design-time
Ink [11] is an AOM framework that depends on a Domain- behavior. It validates whether the Java code is compatible
Specific Language (DSL) interpreter to define the entity with the model defined in Ink. The IDE also provides features
model. It follows its predecessor ModelTalk [44] in its that help in the application development, such as incremental
approach based on DSLs. At runtime, instances of DSL constructor and code completion.
classes are instantiated and used as meta-objects for their The IVM is responsible for connecting structure and be-
corresponding Java instances through a technique called havior at runtime. It provides an API to access the model
model-driven dependency injection. Developers can change structure and a meta-object protocol (MOP) to manipulate
the model by editing the Ink configuration in an Eclipse plu- the application model at runtime, for example, to define a
gin specially developed to handle the DSL structure. When new class.
changes to the template are saved, the plugin automatically Two characteristics of Ink that differentiate it from the
invokes the framework DSL parser, which performs cross- other AOM frameworks are the existence of a new language
validation on the system. to define the type structure and a support IDE tool. However,
The Ink’s metamodel comprises constructions to support the unique feature of Esfinge AOM Role Mapper comparing
types, operations, properties, and constraints. Fig. 11 presents it to Ink is the same mentioned for Oghma. While Ink
a class diagram showing the essential elements and rela- provides several ready-to-use components, it is not possible
tionships within the Ink metamodel. As can be seen in this to reuse components that were not explicitly made to ma-
model, almost every class inherits from the class InkObject, nipulate objects using its structure. The solution proposed in
which allows the definition of high-level relationships, such this article and implemented on Esfinge AOM Role Mapper
as "owner". On the right side of the model, starting with allows regular frameworks that use reflection and annotations
InkType, there were the classes for defining the types, and to be reused for AOM entities, which is not possible with Ink.
on the left side, starting with TypedObject, the classes to
represent the instances. X. CONCLUSION AND FUTURE WORK
In the Ink framework, two languages are used collabora- The AOM architectural style [1] is an approach that can
tively to implement the AOM system: Ink and Java. Ink is a be used to develop adaptive and flexible applications. The
language to describe the object-oriented structure. The role peculiar entity API and the creation of domain-specific solu-
of this language is to define the system structure in a way tions prevent the reuse of components, both from other AOM
that it can be dynamically defined and changed at runtime, applications and traditional object-oriented ones. Existing
supporting explicit metaclasses. Fig. 12, [11] presents an ex- AOM frameworks [10], [11] focus on providing domain-
ample of definition of the entity "Movie" with the properties independent models and their own reusable components,
"title" and "rating". The other language is Java, a statically however without offering compatibility with external frame-
object-oriented language to describe behavior. The role of works.
18 VOLUME X, 20XX

This work is licensed under a Creative Commons Attribution 4.0 License. For more information, see https://creativecommons.org/licenses/by/4.0/
This article has been accepted for publication in a future issue of this journal, but has not been fully edited. Content may change prior to final publication. Citation information: DOI
10.1109/ACCESS.2021.3087795, IEEE Access

Guerra et al.: A Model to Enable the Reuse of Metadata-based Frameworks in Adaptive Object Model Architectures

The present work proposed an AOM framework model that Conference on Information Reuse and Integration (IRI), 2017, pp. 315–
enables the reuse of reflective and metadata-based frame- 324.
[10] H. S. Ferreira, F. F. Correia, and A. Aguiar, “Design for an adaptive object-
works by creating adapters generated in runtime. The pro- model framework,” in Proceedings of the 4th Workshop on Models@ run.
posed model was implemented in Esfinge AOM RoleMapper, time, held at the ACM/IEEE 12th International Conference on Model
an AOM framework that can work with domain-specific Driven Engineering Languages and Systems (MoDELS’09), 2009.
[11] E. Acherkan, A. Hen-Tov, D. H. Lorenz, and L. Schachter, “The ink
AOMs. Works using previous versions of this framework language meta-metamodel for adaptive object-model frameworks,” in
were already published [8], [38]–[40], but none of them Proceedings of the ACM international conference companion on Object
focused on the generation of adapters containing code an- oriented programming systems languages and applications companion.
ACM, 2011, pp. 181–182.
notations in a way that enable their usage by metadata-based [12] S. Microsystems, “Javabeans(tm) specification 1.01 final release,” Aug.
frameworks. 1997. [Online]. Available: http://download.oracle.com/otn-pub/jcp/7224-
In summary, the main contributions of this work are: (a) javabeans-1.01-fr-spec-oth-JSpec/beans.101.pdf
[13] E. Guerra, F. Alves, U. Kulesza, and C. Fernandes, “A reference
proposal of an AOM framework model that enables the architecture for organizing the internal structure of metadata-based
reuse of existing metadata-based frameworks; (b) a reference frameworks,” J. Syst. Softw., vol. 86, no. 5, pp. 1239–1256, May 2013.
implementation of the proposed framework model in Esfinge [Online]. Available: http://dx.doi.org/10.1016/j.jss.2012.12.024
[14] P. Esfinge, “http://esfinge.sf.net/,” 2017.
AOM RoleMapper; (c) a feasibility study using the Hibernate [15] L. Welicki, J. W. Yoder, R. Wirfs-Brock, and R. E. Johnson, “Towards
framework; and, finally, (d) an experiment that compared the a pattern language for adaptive object models,” ser. OOPSLA ’07.
usage of the proposed approach with the creation of imper- New York, NY, USA: Association for Computing Machinery, 2007, p.
787–788. [Online]. Available: https://doi.org/10.1145/1297846.1297888
ative code, capturing development time and the impressions [16] R. Johnson and B. Woolf, Type Object. USA: Addison-Wesley Longman
of each participant. Publishing Co., Inc., 1997, p. 47–65.
Future works can explore the development of more fea- [17] J. W. Yoder, B. Foote, D. Riehle, and M. Tilman, “Metadata and active
object-models,” in Addendum to the 1998 Proceedings of the Conference
tures for Esfinge AOM RoleMapper and distinct evaluations. on Object-Oriented Programming, Systems, Languages, and Applications
As new functionalities for the framework, we intend to focus (Addendum), ser. OOPSLA ’98 Addendum. New York, NY, USA:
on the limitations identified in the Hibernate case study and Association for Computing Machinery, 1998, p. 0.22–A22. [Online].
Available: https://doi.org/10.1145/346852.346955
the development of tools that can help to manage annotation [18] L. Welicki, J. W. Yoder, and R. Wirfs-Brock, “Adaptive object-
mapping and entity type definition. As new evaluations, the model builder,” in Proceedings of the 16th Conference on Pattern
next studies will consist on experiments and case studies that Languages of Programs, ser. PLoP ’09. New York, NY, USA:
Association for Computing Machinery, 2009. [Online]. Available:
focus on creating an entire application. They will target more https://doi.org/10.1145/1943226.1943231
than one metadata-based framework and the impact of the [19] ——, “Rendering patterns for adaptive object-models,” ser. PLOP ’07.
proposed model in the application design. New York, NY, USA: Association for Computing Machinery, 2007.
[Online]. Available: https://doi.org/10.1145/1772070.1772085
[20] H. S. Ferreira, F. F. Correia, and L. Welicki, “Patterns for data and
REFERENCES metadata evolution in adaptive object-models,” ser. PLoP ’08. New
York, NY, USA: Association for Computing Machinery, 2008. [Online].
[1] J. W. Yoder and R. Johnson, “The adaptive object-model architectural Available: https://doi.org/10.1145/1753196.1753203
style,” in Software Architecture. Springer, 2002, pp. 3–27. [21] A. Hen-Tov, L. Nikolaev, L. Schachter, R. Wirfs-Brock, and J. W.
[2] R. Johnson and J. Oakes, “The user-defined product framework,” URL: Yoder, “Adaptive object-model evolution patterns,” ser. SugarLoafPLoP
http://stwww. cs. uiuc. edu/users/johnson/papers/udp, 1998. ’10. New York, NY, USA: Association for Computing Machinery, 2010.
[3] W. K. Mizutani and F. Kon, “Unlimited rulebook: a reference architecture [Online]. Available: https://doi.org/10.1145/2581507.2581512
for economy mechanics in digital games,” in 2020 IEEE International [22] R. E. Johnson and B. Foote, “Designing reusable classes,” Journal of
Conference on Software Architecture (ICSA), 2020, pp. 58–68. object-oriented programming, vol. 1, no. 2, pp. 22–35, 1988.
[4] R. McClatchey, “The deployment of an enhanced model-driven [23] B. FOOTE and J. YODER, “Evolution, architecture, and metamorphosis,”
architecture for business process management,” in Proceedings of in Pattern Languages of Program Design. Addison-Wesley, 1996, vol. 2,
the 22nd International Database Engineering amp; Applications pp. 295–314.
Symposium, ser. IDEAS 2018. New York, NY, USA: Association [24] C. Bauer and G. King, Hibernate in Action. Greenwich, CT: Manning,
for Computing Machinery, 2018, p. 217–225. [Online]. Available: 2005. [Online]. Available: http://www.amazon.com/Hibernate-Action-In-
https://doi.org/10.1145/3216122.3216155 Christian-Bauer/dp/193239415X
[5] M. Overeem and S. Jansen, “An exploration of the’it’in’it depends’: [25] E. Guerra, J. de Souza, and C. Fernandes, Pattern Language for the
Generative versus interpretive model-driven development.” in MODEL- Internal Structure of Metadata-Based Frameworks. Berlin, Heidelberg:
SWARD, 2017, pp. 100–111. Springer Berlin Heidelberg, 2013, pp. 55–110.
[6] K. J. Lippert, “Towards the evolution of information in digital ecosystems,” [26] E. Guerra and C. Fernandes, “A qualitative and quantitative analysis on
Ph.D. dissertation, University of South Alabama, 2018. metadata-based frameworks usage,” in Computational Science and Its
[7] S. Fioravanti, F. Patara, and E. Vicario, “Engineering the performance Applications – ICCSA 2013, B. Murgante, S. Misra, M. Carlini, C. M.
of a meta-modeling architecture,” in Proceedings of the 8th ACM/SPEC Torre, H.-Q. Nguyen, D. Taniar, B. O. Apduhan, and O. Gervasi, Eds.
on International Conference on Performance Engineering Companion, Berlin, Heidelberg: Springer Berlin Heidelberg, 2013, pp. 375–390.
ser. ICPE ’17 Companion. New York, NY, USA: Association [27] L. O’Brien, “Design patterns 15 years later: an interview with erich
for Computing Machinery, 2017, p. 203–208. [Online]. Available: gamma, richard helm and ralph johnson,” Indianápolis: Informit, Oct,
https://doi.org/10.1145/3053600.3053647 vol. 22, 2009.
[8] A. Dias, E. Guerra, and P. Lima, “An architecture for dynamic [28] JSR, “Jsr 175: A metadata facility for the Java programming language,”
web services that integrates adaptive object models with existing Aug. 2004. [Online]. Available: http://www.jcp.org/en/jsr/detail?id=175
frameworks,” in Proceedings of the XIII Brazilian Symposium on Software [29] ECMA, “Ecma - 334: C# language specification,” Dec. 2017. [Online].
Components, Architectures, and Reuse, SBCARS 2019, Salvador, Brazil, Available: https://www.ecma-international.org/publications/files/ECMA-
September 23-27, 2019. ACM, 2019, pp. 13–22. [Online]. Available: ST/Ecma-334.pdf
https://doi.org/10.1145/3357141.3357602 [30] H. Wada and J. Suzuki, “Modeling turnpike frontend system: A
[9] T. Gottardi and R. T. V. Braga, “Model-oriented web service implemen- model-driven development framework leveraging uml metamodeling
tations compared to traditional web services,” in 2017 IEEE International and attribute-oriented programming,” Model Driven Engineering

VOLUME X, 20XX 19

This work is licensed under a Creative Commons Attribution 4.0 License. For more information, see https://creativecommons.org/licenses/by/4.0/
This article has been accepted for publication in a future issue of this journal, but has not been fully edited. Content may change prior to final publication. Citation information: DOI
10.1109/ACCESS.2021.3087795, IEEE Access

Guerra et al.

Languages and Systems, pp. 584–600, 2005. [Online]. Available: ANTONIO DE OLIVEIRA DIAS has a Master
http://www.springerlink.com/index/l166363337837142.pdf degree (2019) in Applied Computing at the Na-
[31] D. Schwarz, “Peeking inside the box: Attribute-oriented tional Institute for Space Research (INPE), São
programming with Java 1.5, part,” 2004. [Online]. Available: José dos Campos, SP, Brazil. He works at Atech
http://archive.oreilly.com/pub/a/onjava/2004/06/30/insidebox1.html Embraer as a Systems Specialist and teaches De-
[32] JSR, “Jsr 220: Enterprise javabeans 3.0,” Aug. 2007. [Online]. Available: vOps and Software Engineering disciplines at Fac-
http://jcp.org/en/jsr/detail?id=220 uldade Impacta. He is an Adaptive Object Model
[33] ——, “Jsr 338: Javatm persistence 2.1,” May 2013. [Online]. Available:
enthusiast.
http://www.jcp.org/en/jsr/detail?id=338
[34] ——, “Jsr 365: Contexts and dependency injection for javatm 2.0,” Jan.
2017. [Online]. Available: http://www.jcp.org/en/jsr/detail?id=365
[35] H. Rocha and H. Valente, “How annotations are used in Java: An empirical
study,” in 23rd International Conference on Software Engineering and
Knowledge Engineering (SEKE), 2011, pp. 426–431.
[36] P. Lima, E. Guerra, P. Meirelles, L. Kanashiro, H. Silva, and F. Silveira,
“A metrics suite for code annotation assessment,” Journal of Systems
and Software, vol. 137, pp. 163 – 183, 2018. [Online]. Available:
http://www.sciencedirect.com/science/article/pii/S016412121730273X
[37] Z. Yu, C. Bai, L. Seinturier, and M. Monperrus, “Characterizing the usage,
evolution and impact of Java annotations in practice,” IEEE Transactions
on Software Engineering, 2019. LUIZ GUSTAVO D. O. VÉRAS has a Doctoral
[38] P. Matsumoto and E. Guerra, “An approach for mapping domain-specific degree (2019) and a Masters’s degree (2013) in
aom applications to a general model,” Journal of Universal Computer Applied Computing at the National Institute for
Science, vol. 20, no. 4, pp. 534–560, apr 2014. Space Research (INPE), São José dos Campos,
[39] E. Guerra and A. Aguiar, Support for Refactoring an Application towards SP, Brazil. He received a Technological degree in
an Adaptive Object Model. Cham: Springer International Publishing, Geoprocessing from the Federal Institute of Ed-
2014, pp. 73–89. ucation, Science and Technology of Piauí (IFPI),
[40] E. Guerra, J. Santos, A. Aguiar, and L. G. Veras, “Dynamic generated Teresina, PI, Brazil, in 2010. Since 2016, he has
adapters from adaptive object models to static apis,” in Proceedings of been a Professor with the Computing Department,
the 22nd Conference on Pattern Languages of Programs, ser. PLoP ’15. at the Federal Institute of Education, Science and
USA: The Hillside Group, 2015. Technology of São Paulo (IFSP). He has experience in system development
[41] C. Wohlin, P. Runeson, M. Höst, M. C. Ohlsson, B. Regnell, and A. Wess-
and geoprocessing. Currently, he is focused on applications of Unmanned
lén, Experimentation in software engineering. Springer Science &
Aerial Vehicles (UAV) in Smart Cities, working with the research group
Business Media, 2012.
[42] V. R. Basili and H. D. Rombach, “The tame project: Towards
"Smart and Sustainable Cities" of IFSP.
improvement-oriented software environments,” Software Engineering,
IEEE Transactions on, vol. 14, no. 6, pp. 758–773, 1988.
[43] V. B. Kampenes, T. Dybå, J. E. Hannay, and D. I. Sjøberg, “A systematic
review of quasi-experiments in software engineering,” Information and
Software Technology, vol. 51, no. 1, pp. 71–82, 2009.
[44] A. Hen-Tov, D. H. Lorenz, A. Pinhasi, and L. Schachter, “Modeltalk: when
everything is a domain-specific language,” IEEE Software, vol. 26, no. 4,
2009.

ADEMAR AGUIAR is Associate Professor at


Faculty of Engineering of University of Porto
(FEUP) and researcher at INESC TEC, Porto, Por-
tugal. His research interests include agile meth-
ods, software patterns, framework development,
and live software development. Ademar received
a Ph.D. in software engineering from FEUP.

EDUARDO GUERRA is currently a researcher


at the Free University of Bozen-Bolzano, worked
in Brazil as a researcher in the National Institute
for Space Research in Brazil and as a teacher at
Aeronautics Institute of Technology. His research
interests include agile methods, software patterns,
framework development, software analytics, and
dynamic architectures. Guerra received a Ph.D. in
computer engineering from the Aeronautics Insti-
tute of Technology and has practical experience in JOELMA CHOMA is a PhD student in Applied
architecture and framework design. Computing at the National Institute for Space
Research (INPE) working on Software Analyt-
ics. Master in Computer Science by the Federal
University of São Carlos (UFSCar). Her research
interest areas include agile practices, software an-
alytics, user-centered design, and empirical soft-
ware engineering.

20 VOLUME X, 20XX

This work is licensed under a Creative Commons Attribution 4.0 License. For more information, see https://creativecommons.org/licenses/by/4.0/
This article has been accepted for publication in a future issue of this journal, but has not been fully edited. Content may change prior to final publication. Citation information: DOI
10.1109/ACCESS.2021.3087795, IEEE Access

Guerra et al.: A Model to Enable the Reuse of Metadata-based Frameworks in Adaptive Object Model Architectures

TIAGO SILVA DA SILVA received his M.Sc. from


Pontifical Catholic University of Rio Grande do
Sul in 2008 as well as his Ph.D. in Computer
Science in 2012. He was a visiting researcher at
University of Calgary in 2010 and 2011. He is
currently an Assistant Professor at the Science
and Technology Institute of Federal University of
São Paulo (UNIFESP), doing research on agile
software development, user-centered design, inte-
gration of agile and user-centered design, devel-
oper experience, software fault and usability prediction, and evidence-based
software engineering.

VOLUME X, 20XX 21

This work is licensed under a Creative Commons Attribution 4.0 License. For more information, see https://creativecommons.org/licenses/by/4.0/

You might also like