Post on 16-Apr-2017
Hamza Ed-douibi, Javier Luis CánovasIzquierdo, Abel Gómez, Massimo Tisi, Jordi
Cabot
EMF-REST: Generation of RESTful APIs from Models
1
ACM SAC 2016 - Pisa, Italy.
07/04/2016
EMF-REST: Generation of RESTful APIs from Models
2
The Model-driven engineering paradigm emphasizes the use of models to raise the level of abstraction and to (semi)automate the development of software.
Abstraction
Automation
MDE
Standar-dization
The Eclipse Modeling Framework (EMF) is the foundation for modeling and data integration at Eclipse. (Models are described using the Ecore language)
EMF-REST: Generation of RESTful APIs from Models
3
Addressable resources (URI)
Representation-oriented (JSON,XML)
Statelessness
Uniform and Constrained Interface
Representational State Transfer (REST) is an architectural style that specifies constraints such as:
Java
Environment
XMI
EMF-REST proposal
4
JAVASCRIPT
+
Web
Environment
JAVASCRIPT
+
REST API
EMF-REST
EMF-REST benefits
5
Collaboration Scalability
Portability
EMF-REST approach
EMF-REST generates RESTful Web APIs out of EMF models.
The generated API provides a direct mapping to access data models following the REST principles :– Addressable resources (URI)– Representation-oriented (JSON,XML)– Statelessness– Uniform and Constrained Interface (HTTP verbs :
GET, POST,…) The generated application supports validation and
security. The generated RESTful Web API relies on well-known
libraries and standards.
6
EMF-REST features
7
REST API JSON Serialization XML Serialization
Validation Security
Running Example
8
IFML (Interaction Flow Modeling Language) model: A form from a movie manager
Mapping EMF with REST
EMF
EMF-REST
9
Addressable resources
1. platform:/resource/project/AddMovie.xmi
2. platform:/resource/project/AddMovie.xmi#title
3. platform:/resource/project/AddMovie.xmi#//.../@viewComponentsParts.0
1. https://example.com/rest/IFMLModel/AddMovie
2. https://example.com/rest/IFMLModel/.../viewComponentsParts/title
3. https://example.com/rest/IFMLModel/.../viewComponentsParts?index=0
Mapping EMF with REST
XML JSON
10
Representation-Oriented
<form>
<name>AddMovieForm</name>
<viewComponentParts>
<simpleField>
<uri>https://example.com/.../
viewComponentsParts/picture</uri>
</simpleField>
<simpleField>
<uri>https://example.com/.../
viewComponentsParts/title</uri>
</simpleField>
...
</viewComponentParts>
<viewElementEvents>
<onSubmitEvent>
<uri>https://example.com/.../
viewElementEvents/add</uri>
</onSubmitEvent>
</viewElementEvents>
</form>
{
"form":{
"name":"addMovieForm",
"viewComponentParts":{
"simpleField":[
{
"uri":"https://.../
viewComponentsParts/picture"
},
{
"uri":"https://.../
viewComponentsParts/title"
}
,…]
},
"viewElementEvents":{
"onsubmitevent":{
"uri":"https://.../
viewelementevents/add"
}
}
}
}
Mapping EMF with REST: Uniform and Constrained Interface & Statelessness
EMF
EMF-REST
11
PUT https :// example .com/rest/IFMLModel/AddMovie/
interactionFlowElements/AddMovieWindow/
viewElements /AddMovieForm
{"form":{
name :"toto"
}
}
addMovieFormObj . setName (" toto ");
//addMovieFormObj is of type Form
Extra features
Validation
– Use of OCL annotations to enable validation each time the API is called
Security
– Encryption: All the communications with the server are using HTTPS
– Authentication: Only authenticated users are allowed to access the API
– Authorization: Use of a Role-based mechanism to assign permissions for each operation.
– Use of model annotations to support authentication and authorization
12
Architecture of EMF-REST generated application
13
EMF
JAX-RS
EJB/CDI
JAXB OCL JPA
JavaScript API
Browser
REST Client
Validation SecurityContent management
Web ClientWeb Application
EMF-REST generation process
14
Conclusion & future work
EMF-REST generates truly RESTful APIs for EMF models by mapping data models with REST principles.
EMF-REST complements the existing (Java-based) API generation facilities EMF already provides and extends them to the Web.
Future work:
– Storage configuration
– Configuration of the generated API
– Definition of how model elements should be serialized.
15
Thank you!
16
• Visit us at:
http://som-
research.uoc.edu/tools/emf-rest/
• Hamza Ed-douibi:
hed-douibi@uoc.edu
•Javier Cánovas:
jcanovasi@uoc.edu
•Jordi Cabot:
jordi.cabot@icrea.cat