16
Hamza Ed-douibi, Javier Luis Cánovas Izquierdo, 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

Embed Size (px)

Citation preview

Page 1: EMF-REST: Generation of RESTful APIs from Models

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

Page 2: EMF-REST: Generation of RESTful APIs from Models

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)

Page 3: EMF-REST: Generation of RESTful APIs from Models

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:

Page 4: EMF-REST: Generation of RESTful APIs from Models

Java

Environment

XMI

EMF-REST proposal

4

JAVASCRIPT

+

Web

Environment

JAVASCRIPT

+

REST API

EMF-REST

Page 5: EMF-REST: Generation of RESTful APIs from Models

EMF-REST benefits

5

Collaboration Scalability

Portability

Page 6: EMF-REST: Generation of RESTful APIs from Models

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

Page 7: EMF-REST: Generation of RESTful APIs from Models

EMF-REST features

7

REST API JSON Serialization XML Serialization

Validation Security

Page 8: EMF-REST: Generation of RESTful APIs from Models

Running Example

8

IFML (Interaction Flow Modeling Language) model: A form from a movie manager

Page 9: EMF-REST: Generation of RESTful APIs from Models

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

Page 10: EMF-REST: Generation of RESTful APIs from Models

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"

}

}

}

}

Page 11: EMF-REST: Generation of RESTful APIs from Models

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

Page 12: EMF-REST: Generation of RESTful APIs from Models

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

Page 13: EMF-REST: Generation of RESTful APIs from Models

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

Page 14: EMF-REST: Generation of RESTful APIs from Models

EMF-REST generation process

14

Page 15: EMF-REST: Generation of RESTful APIs from Models

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

Page 16: EMF-REST: Generation of RESTful APIs from Models

Thank you!

16

• Visit us at:

http://som-

research.uoc.edu/tools/emf-rest/

• Hamza Ed-douibi:

[email protected]

•Javier Cánovas:

[email protected]

•Jordi Cabot:

[email protected]