<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>Reifier: Model-Driven Engineering of Component-Based and Service-Oriented JEE Applications</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>JØrme Rocheteau</string-name>
          <email>jerome.rocheteau@icam.fr</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>David Sferruzza</string-name>
          <email>david.sferruzza@univ-nantes.fr</email>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>ICAM / 35</institution>
          ,
          <addr-line>avenue du Champ de Manuvres, 44470 Carquefou</addr-line>
          ,
          <country country="FR">France</country>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>LINA - UMR CNRS 6241 / F-44322 Nantes Cedex 3</institution>
          ,
          <country country="FR">France</country>
        </aff>
      </contrib-group>
      <abstract>
        <p>This paper aims at presenting Reifier, a tool for prototyping modules of JEE applications by the means of a model-driven development. Web services are dened as parametric components which enables to express web service patterns, to verify them formally and to reuse them in other contexts. Although Reifier requires developers to implement components compliantly to a lightweight API, it provides modelers design exibility and verication support of their web service models. https://www.youtube.com/playlist?list=PLirnqO5cc9voQv_9NDQrRw9zaOsydYj0L</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>Introduction</title>
      <p>ICAM drives 50 applied research projects per year in various application elds
either as a supplier of companies within their inner short-term projects or as
partner in long-term collaborative projects. In the information technology eld,
projects mainly lead to develop prototypes based on web services, web
technologies and mobile technologies in order to highlight innovative features. Adopted
approach mostly consists in a 4-step methodology: (1) need and requirement
analysis that encompasses state-of-the art and reverse engineering of existing
solutions, (2) modelling, (3) prototype development and proof-of-concept, (4)
skills and knowledge transfer. In fact, models are central to this approach: on
the one hand, they correspond to the outputs of the two rst steps and, on the
other hand, they correspond to the input of the two last ones. It has been noticed
that the average time spent for developing the prototype (including bug xes) is
at least twice that of spent to modelling whereas prototyping merely consists of
transforming models into source codes. The opposite would be better: to spend
more time in modelling and to save time in verifying model implementations.</p>
      <p>Thus, since 2014 and for its own applied research activities, ICAM began to
develop a prototype, called Reifier, able to automatically generate the source
code of JEE applications from a specic model of web services. A domain-specic
language for web services has been designed in order to deal both with data and
process models within the same model. Data model corresponds to entities with
properties, inheritance and many-to-one relationships to other entities. Processes
corresponds to parametric components dened by their inputs and outputs. The
latter can be split, on the one hand, into atomic components, each of them linked
to a computational unit manually developed and provided throughout libraries
and, on the other hand, into compound components that stand for
computation ows. Web services can therefore be seen as component specializations over
specic entities. We argue that such a meta-model makes possible to dene web
service patterns which tends to reduce the number of atomic components
involved in developments, and therefore the number of bugs introduced during
developments, as formal verication is made possible thanks to the
componentbased formalization.</p>
      <p>Reifier’s novelty thus consists in applying theorem proving techniques to
web engineering and in demonstrating that it is relevant. This paper is organized
as follows: The section 1 details the meta-model of web services and its associated
verication operations (naming uniqueness, type system hierarchy, component
consistency). The section 2 presents the programming interface required for
developing atomic components that ease their verication. The section 3 explains
how JEE applications are generated from such models. Finally, the section 4
compares our approach to others found in the literature.
1</p>
    </sec>
    <sec id="sec-2">
      <title>Meta-Model</title>
      <p>The meta-model of web services is dened by the means of the syntactic
category model in the gure 1. It has been designed in order to match needs and
requirements about verication. It does not aim to become another standard
but rather to support mapping from and to web service meta-models like RAML
and Swagger for instance. This category model is specied as a product type of
4 attributes: a name, a list of entities that stands for the data model, a list of
components that stands for the process model and the web services that compose
both entities and processes.</p>
      <p>Firstly, entities are represented by the syntactic category entity which is
dened by its name and a list of properties. An entity can optionally inherit from
another entity as specied by its attribute entity:entity? . A property merely
consists of its name and its type; a type being either a primitive type (string,
boolean, integer, etc) or an entity. Primitive-type properties corresponds to the
strict denition of entity properties whereas entity-type properties corresponds
to many-to-one relationships between the entity that they belong to and the
entity that they reference. This data meta-model consist in the minimal and
common one among UML object-oriented data models (class diagrams),
relational data models and conceptual ones (entity/association diagrams).</p>
      <p>Secondly, components dened by the component as the sum type of abstract
components or compound components. Both types of components are dened by
their name, their lists of inputs and outputs and a list of parameters. Moreover,
compound components own a list of concrete components. The latter correspond
to abstract or compound components specialized with some valuated
paramemodel = (name:name,entities:entity*,components:component*,services:service*)
service = (name:name,path:name,methods:method*)
method component[protocol:protocol,request:message,response:message]
message = (content-type:string,content-encoding :string,headers:string*,type:type)
protocol ::= get | post | put | delete | head | options | trace | connect
component ::= abstract | compound
abstract = (name:name,inputs:variable*,outputs:variable*,parameters:variable*)
concrete = (component:component,parameters:parameter*)
compound abstract[components:concrete*]
parameter variable[term:term]</p>
      <p>term ::= variable | constant
variable = (name:name,type:type)
constant = (type:type,value:object)
name ::= abstract-name(name:string)
| concrete-name(name:string)
| compound-name(names:name*)
entity = (name:name,stored:boolean,entity:entity?,properties:property*)
property = (name:name,type:type,required:boolean,indexed:boolean)
type ::= void | string | boolean | integer | oat | date | entity
ters. The name of abstract component stands for the Java qualied name of its
implementation.</p>
      <p>Finally, a web service formalized by the syntactic category service is
dened by its name, its path and a list of methods. The syntactic category method
extends that of concrete components i.e. it specializes a given abstract or
compound component by valuated parameters. Such methods then consist of
wrappers around concrete components with a given method protocol the signature of
its required requests and that of its provided responses.</p>
      <p>Verication Model verication focuses on names, entities and components.
Verifying names consists in detecting naming collisions i.e. dierent elements in a
given model have the same name. It is also veried that only inputs and outputs
of abstract or compound components can be parametric names; neither entity,
component, service nor parameter names can partially be dened by a
parameter. Moreover, some naming conventions are veried: for instance, each entity
(resp. component, service) name has the model name concatenated with
"entities" (resp. "components", "services") as a namespace. This naming convention
verication ensures that no conict will happen during source code generation
i.e. a single le will be generated twice for two dierent model elements. If an
entity (resp. a component) does not verify such a condition, it is assumed that
it points to an existing third-party entity (resp. component) and a verication
is therefore performed in order to ensure that this entity (resp. this
component) is provided by a library. Verifying entities consists in checking that the
type system is well-founded i.e. that no cycle exists over entity inheritance
relationships. Verifying components as well as methods of services consists, rstly,
in checking that abstract component implementations meet their specications
(see section 2) secondly, in checking compliance between input and output types
of inner components of compound components and, thirdly, in checking that
every parameters of a concrete component must be declared by its inner
component. It is also veried that inner component output exists within a compound
component that overrides the output of one of its previous inner components.
Moreover, every services must embed only components without any free variables
or non-valuated parameters.
2</p>
    </sec>
    <sec id="sec-3">
      <title>Programming Interface</title>
      <p>An application programming interface (API) for developing implementations of
abstract components is provided by the means of a Java library that contains:
2 Java interfaces: Component and Resource,
5 Java annotations: Parameter, Input, Output, Request and Response.
This API involves that of the Java servlets. The Resource interface merely
consists in two methods setUp and tearDown able to initialize and nalize
objects. The rst method setUp is applied to a servlet context as parameter. This
API therefore enables resource implementations to provide some real resources
throughout servlet context sessions. Such resources can be shared between
several components while initializing them.</p>
      <p>In fact, the Component interface species three methods setUp, tearDown
and doProcess. Whereas the rst method setUp consists of initializing objects of
classes that implements this interface, the second one corresponds to its dual i.e.
it consists in destroying these objects. The rst method is applied to a servlet
context and a servlet conguration which makes possible to retrieve some
resources previously inserted into the servlet context attributes. Hence resources
can be shared between several components. As for the third method doProcess, it
denes the computation of such components. Abstract component
implementations can then process HTTP requests and responses such that it makes possible
to wrap them into HTTP servlets in order to build computation ows.</p>
      <p>The ve annotations provided by the Reifier API bridge the gap between
component specication and their implementations. In fact, they are used to
verify that component implementations meet their specication. These annotations
all concern either elds or local variables within component implementations.
They are all dened by a name and a type that must comply the Reifier type
system. This means that types are either primitive types or entities that are
dened by qualied names of Java classes or interfaces. Types can also be
references to parameters of these component implementations which type is a Java
class. The latter corresponds exactly to parameter terms that are variables in
the Reifier meta-model. That is why these annotations could ease verication
of abstract components as Reifier type system is embedded into component
implementation annotations. However, this correspond to a shallow verication
as the compliance between annotations and the elds or local variables that they
concern is not veried.</p>
      <p>This API encourages developers to provide ne-grained and focused
components throughout their libraries as compound component and service
implementations are automatically generated from a given model as well as web service
descriptions. However, it does not tackle side-eects, asynchronous method calls,
rst-order pre/post conditions within component implementations, as this API
has been designed to be the more lightweight possible for developers.
3</p>
    </sec>
    <sec id="sec-4">
      <title>Model to Text Transformation</title>
      <p>Code generation is performed thanks to a Maven plugin and generated JEE
applications rely on the Reifier API library, Hibernate core library and on
Hibernate Search library when plain text search is enabled for some indexed
properties of entities (i.e. when the indexed attribute of an entity property is set
to true). These libraries remains the required dependencies involved by the source
code generation. It reads a XML le that describes a model compliant with the
meta-model presented in the section 1. Models are then built and veried before
being serialized by the means of a template engine as follows:</p>
      <p>Firstly, entities are created as Java classes. The name of these classes is
provided by the name of the entity. Private elds are declared within such classes
from the entity properties, the name of elds is provided by that of properties and
its Java type is dened either by Java primitive type wrappers that associated
to Reifier primitive types or by Java classes that are generated from entities.
A specic eld called id of type long per stored entity (i.e. those which attribute
stored is set to true in a given model) is inserted that stands for the identier
or primary key of these entity occurrences. These Java elds are annotated by
annotations that are provided by the Java persistence API, the Hibernate API
and the Hibernate Search API accordingly. Public setters and getters for such
Java elds are inserted within these Java classes. The latter do no hold
neither constructor nor other specic methods. These classes correspond to data
structures only. Moreover, a XML le is also created that species a Hibernate
object-to-relational mapping between these Java classes and SQL tables from
stored entities.</p>
      <p>Secondly, compound components are created as Java classes that implements
the Component interface provided by the Reifier API. Private elds and
associated setters and getters are inserted within these classes from the parameters
of their components. The setUp method constructs every inner components and
calls their respective setUp methods. In the same way, the doProcess method
(resp. tearDown method) merely calls inner component doProcess methods (resp.
tearDown methods). Moreover, every methods of services are created the same
manner as Java classes that implements the Component interface; their Java class
name is provided by their service name with their protocol name as sux.</p>
      <p>Thirdly, services are created as Java classes that extend the HttpServlet class.
A private eld is declared per method, the protocol name provides this eld
name. The Java type of such elds is dened by the generated class of these
methods. Finally, the XML le web.xml that species, on the one hand, the
previous servlet context listener and, on the other hand, both the available paths
and their associated HTTP servlets is generated. This achieved the model-to-text
transformation that reies the JEE application.</p>
      <p>In addition, a Java class that stands for a HTTP client is created per service
thanks to the Apache HTTP client library. Every HTTP clients have a string
eld that corresponds to the server name of the generated JEE application. They
all have two methods setUp and tearDown with no parameter for initializing and
nalizing them. They also have a Java method per Reifier method; its return
type is dened by that of the Reifier method response and, potentially, such
Java methods have an argument dened by the Reifier method request.
4</p>
    </sec>
    <sec id="sec-5">
      <title>Related Work</title>
      <p>
        This work follows the recommendation from [
        <xref ref-type="bibr" rid="ref6 ref6">6, 6</xref>
        ] that meta-model approaches
are suitable for server-side code generation instead of a meta-programming one.
Moreover, the meta-model presented in the gure 1 share the same concepts
with that of [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ]. In fact, web services are dened as pairs composed of a process
and a behavior. Processes correspond either to an action (single-step process)
or a composite one (multiple-steps process). In addition, single-step process are
specied by their behavior that consist in inputs and outputs but also in
preconditions and eects. Although our web service denition takes into account
inputs and outputs, it lacks of higher order specications as preconditions and
eects.
      </p>
      <p>
        A interesting way to embed preconditions or eects into our approach can
be drawn out from [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ]. In fact, a innovative web engineering methodology is
designed that starts by extracting requirements from mockups i.e. quick designs
of application use cases and end-user screens. Then, some renements can be
introduced into extracted models with the concept of tags. Tags help to specify
application features such as some operations over data structures, navigation,
search queries, specic actions, etc. This tag system seems lightweight for
developers or modelers and this could be applied to our work through out Java
annotations for atomic component implementations.
      </p>
      <p>
        This work is highly related to that of [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ] with the Declare tool and those
from [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ] to [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ] with the M3D tool, the latter extending the previous one. In
fact, M3D generates web application code source from a 4-layer meta-model:
information layer by the means of UML class diagram, service layer by the means
of BPMN, presentation layer by the means of ad hoc meta-model and a process
layer by means of Declare an event constraint language based on the temporal
logic LTL. Code generation is achieved using a model-to-text approach with the
Xpand language. These tools aim at providing developers the higher exibility
possible as well as the better support possible the less to develop and verify but
the easiest to customize. This exactly is Reifier development main guideline.
Our work specially focuses on the design-time support (see [1, 3.1]) even if
still requires to explicitly express services and it does not yet support formal
verication. These tools have a lot in common with respect to these guidelines.
However, they dier one to another at some extent. The main dierence consists
in the fact that M3D generates web applications i.e. both server-side and
clientside applications whereas Reifier only generates web services i.e. server-side
applications although it used to generate both sides on its earlier versions.
      </p>
    </sec>
    <sec id="sec-6">
      <title>Conclusion</title>
      <p>Reifier has been successfully applied to the development of several JEE
applications. It has been noticed that the set of abstract component implementations
reaches both quantity and quality stability over the time. It then reduces the
lines of code manually written and, therefore, the number of bugs. It tends to
reduce development time for server-side JEE applications and to dispatch eort
dierently: less for developers, more for designers.</p>
      <p>Three main prospects are here sketched: The rst prospect corresponds to an
ongoing work at ICAM and consists in building other model-driven approaches
on the top of Reifier thanks to model-to-model transformations. This is
investigated for service-oriented management systems of sensor and actuator networks.
The second and third prospects are investigated during David Sferruzza’s PhD
thesis. It rstly consists in turning models into parametric models in order to
dene explicit design patterns. It secondly consists in strengthen verication by
the means of formal methods; an axiomatic semantics for components that could
reach this goal has been designed.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          1.
          <string-name>
            <surname>van der Aalst</surname>
          </string-name>
          , W.,
          <string-name>
            <surname>Pesic</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Schonenberg</surname>
          </string-name>
          , H.:
          <article-title>Declarative workows: Balancing between exibility and support</article-title>
          .
          <source>Computer Science - R&amp;D</source>
          <volume>23</volume>
          (
          <issue>2</issue>
          ),
          <volume>99113</volume>
          (
          <year>2009</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          2.
          <string-name>
            <surname>Bernardi</surname>
            ,
            <given-names>M.L.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Cimitile</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <given-names>Di</given-names>
            <surname>Lucca</surname>
          </string-name>
          ,
          <string-name>
            <surname>G.</surname>
          </string-name>
          ,
          <string-name>
            <given-names>Maria</given-names>
            <surname>Maggi</surname>
          </string-name>
          ,
          <string-name>
            <surname>F.</surname>
          </string-name>
          :
          <article-title>M3D: a tool for the Model Driven Development of Web Applications</article-title>
          . In: Fletcher,
          <string-name>
            <given-names>G.H.L.</given-names>
            ,
            <surname>Mitra</surname>
          </string-name>
          , P. (eds.)
          <source>Proceedings of the Twelfth International Workshop on Web Information and Data Management</source>
          ,
          <string-name>
            <surname>WIDM</surname>
          </string-name>
          <year>2012</year>
          ,
          <article-title>Maui</article-title>
          ,
          <string-name>
            <surname>HI</surname>
          </string-name>
          , USA, November
          <volume>02</volume>
          ,
          <year>2012</year>
          . pp.
          <fpage>7380</fpage>
          .
          <string-name>
            <surname>ACM</surname>
          </string-name>
          (
          <year>2012</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          3.
          <string-name>
            <surname>Bernardi</surname>
            ,
            <given-names>M.L.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Cimitile</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Maggi</surname>
            ,
            <given-names>F.M.:</given-names>
          </string-name>
          <article-title>Automated development of constraintdriven web applications</article-title>
          .
          <source>In: Proceedings of the 31st Annual ACM Symposium on Applied Computing</source>
          . pp.
          <fpage>11961203</fpage>
          .
          <string-name>
            <surname>ACM</surname>
          </string-name>
          (
          <year>2016</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          4.
          <string-name>
            <surname>Lautenbacher</surname>
            ,
            <given-names>F.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Bauer</surname>
            ,
            <given-names>B.</given-names>
          </string-name>
          :
          <article-title>Creating a meta-model for semantic web service standards</article-title>
          . pp.
          <fpage>376381</fpage>
          . INSTICC Press (
          <year>2007</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          5.
          <string-name>
            <surname>Rivero</surname>
            ,
            <given-names>J.M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Grigera</surname>
            ,
            <given-names>J.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Rossi</surname>
            ,
            <given-names>G.</given-names>
          </string-name>
          ,
          <string-name>
            <given-names>Robles</given-names>
            <surname>Luna</surname>
          </string-name>
          ,
          <string-name>
            <given-names>E.</given-names>
            ,
            <surname>Montero Simarro</surname>
          </string-name>
          ,
          <string-name>
            <given-names>F.</given-names>
            ,
            <surname>Gaedke</surname>
          </string-name>
          ,
          <string-name>
            <surname>M.</surname>
          </string-name>
          :
          <article-title>Mockup-driven development: Providing agile support for model-driven web engineering</article-title>
          .
          <source>Information &amp; Software Technology</source>
          <volume>56</volume>
          (
          <issue>6</issue>
          ),
          <volume>670687</volume>
          (
          <year>2014</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          6.
          <string-name>
            <surname>Scheidgen</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Etinge</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Marticke</surname>
            ,
            <given-names>F.</given-names>
          </string-name>
          :
          <article-title>Metamodeling vs Metaprogramming: A Case Study on Developing Client Libraries for REST APIs</article-title>
          .
          <source>Lecture Notes in Computer Science</source>
          , vol.
          <volume>9764</volume>
          , pp.
          <fpage>205216</fpage>
          . Springer (
          <year>2016</year>
          )
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>