a model-driven approach for rest compliant...
TRANSCRIPT
![Page 1: A model-driven approach for REST compliant servicesdesign.inf.usi.ch/sites/default/files/seminar-2014... · 2014-08-29 · University of Stuttgart Universitätsstr. 38 70569 Stuttgart](https://reader033.vdocuments.us/reader033/viewer/2022042916/5f544ba4cec7d3513135438b/html5/thumbnails/1.jpg)
University of Stuttgart Universitätsstr. 38 70569 Stuttgart Germany
Phone +49-711-685 88205 Fax +49-711-685 88472
Florian Haupt Institute of Architecture of Application Systems
USI Informatics Seminar, Lugano, 2014-08-25
A model-driven approach for REST compliant services
![Page 2: A model-driven approach for REST compliant servicesdesign.inf.usi.ch/sites/default/files/seminar-2014... · 2014-08-29 · University of Stuttgart Universitätsstr. 38 70569 Stuttgart](https://reader033.vdocuments.us/reader033/viewer/2022042916/5f544ba4cec7d3513135438b/html5/thumbnails/2.jpg)
© Florian Haupt 2
Rese
arch
A model-driven approach for REST compliant services – USI Informatics Seminar, Lugano, 2014-08-25
Agenda
� REST Introduction
� REST and the WWW
� Layered Meta-Model
� Prototype
� Formalization
� Conclusion
![Page 3: A model-driven approach for REST compliant servicesdesign.inf.usi.ch/sites/default/files/seminar-2014... · 2014-08-29 · University of Stuttgart Universitätsstr. 38 70569 Stuttgart](https://reader033.vdocuments.us/reader033/viewer/2022042916/5f544ba4cec7d3513135438b/html5/thumbnails/3.jpg)
© Florian Haupt 3
Rese
arch
A model-driven approach for REST compliant services – USI Informatics Seminar, Lugano, 2014-08-25
Definition
� REST is an “architectural style for distributed hypermedia systems” [2] � The WWW is a distributed hypermedia system
� REST is defined as a set of architectural constraints
![Page 4: A model-driven approach for REST compliant servicesdesign.inf.usi.ch/sites/default/files/seminar-2014... · 2014-08-29 · University of Stuttgart Universitätsstr. 38 70569 Stuttgart](https://reader033.vdocuments.us/reader033/viewer/2022042916/5f544ba4cec7d3513135438b/html5/thumbnails/4.jpg)
© Florian Haupt 4
Rese
arch
A model-driven approach for REST compliant services – USI Informatics Seminar, Lugano, 2014-08-25
REST = LCODC$SS + U
L Layered System
CS Client Server
CSS Client Stateless Server
$ Caching
COD Code On Demand
U Uniform Interface
REST Representational State Transfer
![Page 5: A model-driven approach for REST compliant servicesdesign.inf.usi.ch/sites/default/files/seminar-2014... · 2014-08-29 · University of Stuttgart Universitätsstr. 38 70569 Stuttgart](https://reader033.vdocuments.us/reader033/viewer/2022042916/5f544ba4cec7d3513135438b/html5/thumbnails/5.jpg)
© Florian Haupt 5
Rese
arch
A model-driven approach for REST compliant services – USI Informatics Seminar, Lugano, 2014-08-25
REST style derivation tree
RR
$
CS
C$SS
CSS
LS
LC$SS
LCS
VM
LCODC$SS
COD
U
REST
![Page 6: A model-driven approach for REST compliant servicesdesign.inf.usi.ch/sites/default/files/seminar-2014... · 2014-08-29 · University of Stuttgart Universitätsstr. 38 70569 Stuttgart](https://reader033.vdocuments.us/reader033/viewer/2022042916/5f544ba4cec7d3513135438b/html5/thumbnails/6.jpg)
© Florian Haupt 6
Rese
arch
A model-driven approach for REST compliant services – USI Informatics Seminar, Lugano, 2014-08-25
Uniform Interface
� Identification of resources � Manipulation of resources through representation � Self-descriptive messages � Hypermedia as the engine of application state
� aka HATEOAS
![Page 7: A model-driven approach for REST compliant servicesdesign.inf.usi.ch/sites/default/files/seminar-2014... · 2014-08-29 · University of Stuttgart Universitätsstr. 38 70569 Stuttgart](https://reader033.vdocuments.us/reader033/viewer/2022042916/5f544ba4cec7d3513135438b/html5/thumbnails/7.jpg)
© Florian Haupt 7
Rese
arch
A model-driven approach for REST compliant services – USI Informatics Seminar, Lugano, 2014-08-25
Classification of architectural styles
![Page 8: A model-driven approach for REST compliant servicesdesign.inf.usi.ch/sites/default/files/seminar-2014... · 2014-08-29 · University of Stuttgart Universitätsstr. 38 70569 Stuttgart](https://reader033.vdocuments.us/reader033/viewer/2022042916/5f544ba4cec7d3513135438b/html5/thumbnails/8.jpg)
© Florian Haupt 8
Rese
arch
A model-driven approach for REST compliant services – USI Informatics Seminar, Lugano, 2014-08-25
The History of REST
� 1991 � HTTP 0.9 � First version by Tim Berners-Lee
� 1994 � „Universal Resource Identifiers in WWW“
� RFC 1630 � „Uniform Resource Locators (URL)“
� RFC 1738 � 1996
� HTTP 1.0 � RFC 1945
� 1999 � HTTP 1.1
� RFC 2616 � 2000
� “Architectural styles and the design of network-based software architectures”
� Dissertation by Roy Fielding � First notion of the term “REST”
![Page 9: A model-driven approach for REST compliant servicesdesign.inf.usi.ch/sites/default/files/seminar-2014... · 2014-08-29 · University of Stuttgart Universitätsstr. 38 70569 Stuttgart](https://reader033.vdocuments.us/reader033/viewer/2022042916/5f544ba4cec7d3513135438b/html5/thumbnails/9.jpg)
© Florian Haupt 9
Rese
arch
A model-driven approach for REST compliant services – USI Informatics Seminar, Lugano, 2014-08-25
Motivation
� “Since 1994, the REST architectural style has been used to guide the design and development of the architecture for the modern Web.” [2]
� “… the motivation for developing REST was to create an architectural model for how the Web should work, such that it could serve as the guiding framework for the Web protocol standards. REST has been applied to describe the desired Web architecture, help identify existing problems, compare alternative solutions, and ensure that protocol extensions would not violate the core constraints that make the Web successful. This work was done as part of the Internet Engineering Taskforce (IETF) and World Wide Web Consortium (W3C) efforts to define the architectural standards for the Web: HTTP, URI, and HTML.” [2]
![Page 10: A model-driven approach for REST compliant servicesdesign.inf.usi.ch/sites/default/files/seminar-2014... · 2014-08-29 · University of Stuttgart Universitätsstr. 38 70569 Stuttgart](https://reader033.vdocuments.us/reader033/viewer/2022042916/5f544ba4cec7d3513135438b/html5/thumbnails/10.jpg)
© Florian Haupt 10
Rese
arch
A model-driven approach for REST compliant services – USI Informatics Seminar, Lugano, 2014-08-25
Success
The basics have been designed here (100.000 Webservers)
It worked here (46.000.000+ Webservers) And still works today
(02/2012 Apache had a market share of 64,92% with 397.867.089 servers)
„it works“ means
„it scales“
Numbers are taken from: - http://www.w3.org/2005/01/timelines/description - http://news.netcraft.com/archives/category/web-server-survey/
![Page 11: A model-driven approach for REST compliant servicesdesign.inf.usi.ch/sites/default/files/seminar-2014... · 2014-08-29 · University of Stuttgart Universitätsstr. 38 70569 Stuttgart](https://reader033.vdocuments.us/reader033/viewer/2022042916/5f544ba4cec7d3513135438b/html5/thumbnails/11.jpg)
© Florian Haupt 11
Rese
arch
A model-driven approach for REST compliant services – USI Informatics Seminar, Lugano, 2014-08-25
One reason for success
� “REST is software design on the scale of decades: every detail is intended to promote software longevity and independent evolution.” [2]
![Page 12: A model-driven approach for REST compliant servicesdesign.inf.usi.ch/sites/default/files/seminar-2014... · 2014-08-29 · University of Stuttgart Universitätsstr. 38 70569 Stuttgart](https://reader033.vdocuments.us/reader033/viewer/2022042916/5f544ba4cec7d3513135438b/html5/thumbnails/12.jpg)
© Florian Haupt 12
Rese
arch
A model-driven approach for REST compliant services – USI Informatics Seminar, Lugano, 2014-08-25
It looks easy, but it is hard to achieve
� “However, I think most people just make the mistake that it should be simple to design simple things. In reality, the effort required to design something is inversely proportional to the simplicity of the result. As architectural styles go, REST is very simple.” [1]
![Page 13: A model-driven approach for REST compliant servicesdesign.inf.usi.ch/sites/default/files/seminar-2014... · 2014-08-29 · University of Stuttgart Universitätsstr. 38 70569 Stuttgart](https://reader033.vdocuments.us/reader033/viewer/2022042916/5f544ba4cec7d3513135438b/html5/thumbnails/13.jpg)
13
REST and the WWW
![Page 14: A model-driven approach for REST compliant servicesdesign.inf.usi.ch/sites/default/files/seminar-2014... · 2014-08-29 · University of Stuttgart Universitätsstr. 38 70569 Stuttgart](https://reader033.vdocuments.us/reader033/viewer/2022042916/5f544ba4cec7d3513135438b/html5/thumbnails/14.jpg)
© Florian Haupt 14
Rese
arch
A model-driven approach for REST compliant services – USI Informatics Seminar, Lugano, 2014-08-25
REST and the WWW – Introduction
� Representational State Transfer (REST) � An architectural style for distributed hypermedia systems
� Defined as a set of constraints each REST architecture has to comply with
� World Wide Web (WWW) � The best known and biggest system following the REST
architectural style
� The WWW is based on several standards � HTTP, URI, MIME, HTML
� How are the REST constraints fulfilled in the WWW?
![Page 15: A model-driven approach for REST compliant servicesdesign.inf.usi.ch/sites/default/files/seminar-2014... · 2014-08-29 · University of Stuttgart Universitätsstr. 38 70569 Stuttgart](https://reader033.vdocuments.us/reader033/viewer/2022042916/5f544ba4cec7d3513135438b/html5/thumbnails/15.jpg)
© Florian Haupt 15
Rese
arch
A model-driven approach for REST compliant services – USI Informatics Seminar, Lugano, 2014-08-25
REST and the WWW – Fulfilling the constraints
REST constraint Fulfilled by
Layered Client Server HTTP / default
Cache HTTP
Stateless Server Developer
Uniform Interface HTTP + Developer
Identification HTTP / URI
Manipulation through Representations HTTP
Self Descriptive Messages HTTP
HATEOAS Developer (User?)
![Page 16: A model-driven approach for REST compliant servicesdesign.inf.usi.ch/sites/default/files/seminar-2014... · 2014-08-29 · University of Stuttgart Universitätsstr. 38 70569 Stuttgart](https://reader033.vdocuments.us/reader033/viewer/2022042916/5f544ba4cec7d3513135438b/html5/thumbnails/16.jpg)
© Florian Haupt 16
Rese
arch
A model-driven approach for REST compliant services – USI Informatics Seminar, Lugano, 2014-08-25
How to retrieve an object from an S3 bucket (1)
![Page 17: A model-driven approach for REST compliant servicesdesign.inf.usi.ch/sites/default/files/seminar-2014... · 2014-08-29 · University of Stuttgart Universitätsstr. 38 70569 Stuttgart](https://reader033.vdocuments.us/reader033/viewer/2022042916/5f544ba4cec7d3513135438b/html5/thumbnails/17.jpg)
© Florian Haupt 17
Rese
arch
A model-driven approach for REST compliant services – USI Informatics Seminar, Lugano, 2014-08-25
How to retrieve an object from an S3 bucket (2) <ListAllMyBucketsResult> <Buckets> <Bucket> <Name>hauptfn-images</Name> </Bucket> <Bucket> <Name>hauptfn-scripts</Name> </Bucket> </Buckets> </ListAllMyBucketsResult>
<ListBucketResult> <Name>Images</Name> <Contents> <Key>poster.jpg</Key> </Contents> <Contents> <Key>logo.jpg</Key> </Contents> </ListBucketResult>
/9j/4AAQSkZJRgABAQEASABIAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjL/wAARCAEsANUDASIAAhEBAxEB/8QAHAABAAICAwEAAAAAAAAAAAAAAAEHBQYDBAgC/8QATxAAAQMDAQUCCQYHDwMFAAAAAQACAwQFEQYHEhMhMUFRFBUiMmFxgZGhFkJSscHRI1Vic3STsggXJDM1NjdTcpKUosLh8ENUgmNkhLPi/8QAGwEBAAIDAQEAAAAAA…
GET s3.amazonaws.com
GET hauptfn-images.s3.amazonaws.com
GET hauptfn-images.s3.amazonaws.com/poster.jpg
GET {BucketName}.s3.amazonaws.com/{ObjectKey}
![Page 18: A model-driven approach for REST compliant servicesdesign.inf.usi.ch/sites/default/files/seminar-2014... · 2014-08-29 · University of Stuttgart Universitätsstr. 38 70569 Stuttgart](https://reader033.vdocuments.us/reader033/viewer/2022042916/5f544ba4cec7d3513135438b/html5/thumbnails/18.jpg)
© Florian Haupt 18
Rese
arch
A model-driven approach for REST compliant services – USI Informatics Seminar, Lugano, 2014-08-25
<ListAllMyBucketsResult> <Buckets> <Bucket> <Name>hauptfn-images</Name> <href>hauptfn-images.s3.amazonaws.com</href> </Bucket> <Bucket> <Name>hauptfn-scripts</Name> <href>hauptfn-scripts.s3.amazonaws.com</href> </Bucket> </Buckets> </ListAllMyBucketsResult>
How to retrieve an object from an S3 bucket (3)
GET s3.amazonaws.com
GET hauptfn-images.s3.amazonaws.com
GET hauptfn-images.s3.amazonaws.com/poster.jpg
<ListBucketResult> <Name>Images</Name> <Contents> <Key>poster.jpg</Key> <href>hauptfn-images.s3.amazonaws.com /poster.jpg</href> </Contents> <Contents> <Key>logo.jpg</Key> <href>hauptfn-images.s3.amazonaws.com /logo.jpg</href> </Contents> </ListBucketResult>
/9j/4AAQSkZJRgABAQEASABIAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjL/wAARCAEsANUDASIAAhEBAxEB/8QAHAABAAICAwEAAAAAAAAAAAAAAAEHBQYDBAgC/8QATxAAAQMDAQUCCQYHDwMFAAAAAQACAwQFEQYHEhMhMUFRFBUiMmFxgZGhFkJSscHRI1Vic3STsggXJDM1NjdTcpKUosLh8ENUgmNkhLPi/8QAGwEBAAIDAQEAAAAAA…
![Page 19: A model-driven approach for REST compliant servicesdesign.inf.usi.ch/sites/default/files/seminar-2014... · 2014-08-29 · University of Stuttgart Universitätsstr. 38 70569 Stuttgart](https://reader033.vdocuments.us/reader033/viewer/2022042916/5f544ba4cec7d3513135438b/html5/thumbnails/19.jpg)
© Florian Haupt 19
Rese
arch
A model-driven approach for REST compliant services – USI Informatics Seminar, Lugano, 2014-08-25
REST and the WWW – Conclusion
� Some constraints are already fulfilled by the building blocks of the WWW � HTTP, URI, MIME
� Some constraints have to be fulfilled by service providers (and consumers) � Uniform interface & HATEOAS
� Existing work shows, that constraints that are the responsibility of the service provider are often not fulfilled properly
![Page 20: A model-driven approach for REST compliant servicesdesign.inf.usi.ch/sites/default/files/seminar-2014... · 2014-08-29 · University of Stuttgart Universitätsstr. 38 70569 Stuttgart](https://reader033.vdocuments.us/reader033/viewer/2022042916/5f544ba4cec7d3513135438b/html5/thumbnails/20.jpg)
20
Layered Meta-Model [3]
![Page 21: A model-driven approach for REST compliant servicesdesign.inf.usi.ch/sites/default/files/seminar-2014... · 2014-08-29 · University of Stuttgart Universitätsstr. 38 70569 Stuttgart](https://reader033.vdocuments.us/reader033/viewer/2022042916/5f544ba4cec7d3513135438b/html5/thumbnails/21.jpg)
© Florian Haupt 21
Rese
arch
A model-driven approach for REST compliant services – USI Informatics Seminar, Lugano, 2014-08-25
Meta-model – Overview
Domain Model
Composite Resource Model
Atomic Resource Model
URL Model
Java Code
JAX-RS Application Model
HTML Service Description
PIM
PSM
Domain Model
Composite Resource Model
Atomic Resource Model
URL Model
Java Code
Java Code
Java Code
JAX-RS Application Model
JAX-RS Application Model
JAX-RS Application Model
WADL Service Description
WADL Service Description
WADL Service Description
![Page 22: A model-driven approach for REST compliant servicesdesign.inf.usi.ch/sites/default/files/seminar-2014... · 2014-08-29 · University of Stuttgart Universitätsstr. 38 70569 Stuttgart](https://reader033.vdocuments.us/reader033/viewer/2022042916/5f544ba4cec7d3513135438b/html5/thumbnails/22.jpg)
© Florian Haupt 22
Rese
arch
A model-driven approach for REST compliant services – USI Informatics Seminar, Lugano, 2014-08-25
Meta-model – Domain Model
� Independent of the concept of resources
� Tailored to application domain
Domain Model
Composite Resource Model
Atomic Resource Model
URL Model
Java Code
Java Code
Java Code
JAX-RS Application Model
JAX-RS Application Model
JAX-RS Application Model
WADL Service Description
WADL Service Description
HTML Service Description
OPAL version owner runMCJob(…)
Server cores active reset(…)
0..n uses
![Page 23: A model-driven approach for REST compliant servicesdesign.inf.usi.ch/sites/default/files/seminar-2014... · 2014-08-29 · University of Stuttgart Universitätsstr. 38 70569 Stuttgart](https://reader033.vdocuments.us/reader033/viewer/2022042916/5f544ba4cec7d3513135438b/html5/thumbnails/23.jpg)
© Florian Haupt 23
Rese
arch
A model-driven approach for REST compliant services – USI Informatics Seminar, Lugano, 2014-08-25
Meta-model – Resource Models
� Describes the resources provided by a REST service
� Composite Resource Model provides an additional abstraction layer for easier modeling
Domain Model
Composite Resource Model
Atomic Resource Model
URL Model
Java Code
Java Code
Java Code
JAX-RS Application Model
JAX-RS Application Model
JAX-RS Application Model
WADL Service Description
WADL Service Description
HTML Service Description
OPAL
GET – OPAL PUT - OPAL
ServerList
GET – ServerList POST – Server
Server
GET – Server PUT – Server POST - restartReq DELETE
MCJobManager
GET – JobList POST - JobDef
MCJob
GET – Job POST – JobAct DELETE
MCJobResult
GET – JobResult DELETE
[LRC] MCJob
![Page 24: A model-driven approach for REST compliant servicesdesign.inf.usi.ch/sites/default/files/seminar-2014... · 2014-08-29 · University of Stuttgart Universitätsstr. 38 70569 Stuttgart](https://reader033.vdocuments.us/reader033/viewer/2022042916/5f544ba4cec7d3513135438b/html5/thumbnails/24.jpg)
© Florian Haupt 24
Rese
arch
A model-driven approach for REST compliant services – USI Informatics Seminar, Lugano, 2014-08-25
Meta-model – Service Description
� View on the resource model � Interface description for
service clients � Independent of URL structure,
following HATEOAS
Domain Model
Composite Resource Model
Atomic Resource Model
URL Model
Java Code
Java Code
Java Code
JAX-RS Application Model
JAX-RS Application Model
JAX-RS Application Model
WADL Service Description
WADL Service Description
HTML Service Description
![Page 25: A model-driven approach for REST compliant servicesdesign.inf.usi.ch/sites/default/files/seminar-2014... · 2014-08-29 · University of Stuttgart Universitätsstr. 38 70569 Stuttgart](https://reader033.vdocuments.us/reader033/viewer/2022042916/5f544ba4cec7d3513135438b/html5/thumbnails/25.jpg)
© Florian Haupt 25
Rese
arch
A model-driven approach for REST compliant services – USI Informatics Seminar, Lugano, 2014-08-25
Meta-model – URL Model
� Assigns URLs to resources � HATEOAS implies that the
URL structure is irrelevant for clients
� Nevertheless, the URL structure is needed for the service implementation
Domain Model
Composite Resource Model
Atomic Resource Model
URL Model
Java Code
Java Code
Java Code
JAX-RS Application Model
JAX-RS Application Model
JAX-RS Application Model
WADL Service Description
WADL Service Description
HTML Service Description
OPAL
GET – OPAL PUT - OPAL
ServerList
GET – ServerList POST – Server
Server
GET – Server PUT – Server POST - restartReq DELETE
/servers /{SID}
![Page 26: A model-driven approach for REST compliant servicesdesign.inf.usi.ch/sites/default/files/seminar-2014... · 2014-08-29 · University of Stuttgart Universitätsstr. 38 70569 Stuttgart](https://reader033.vdocuments.us/reader033/viewer/2022042916/5f544ba4cec7d3513135438b/html5/thumbnails/26.jpg)
© Florian Haupt 26
Rese
arch
A model-driven approach for REST compliant services – USI Informatics Seminar, Lugano, 2014-08-25
Meta-model – Application Model and Code
� Application model combines resource model and URL model
� Application model is bound to specific platform
� Generated code has to be extended with domain logic
Domain Model
Composite Resource Model
Atomic Resource Model
URL Model
Java Code
Java Code
Java Code
JAX-RS Application Model
JAX-RS Application Model
JAX-RS Application Model
WADL Service Description
WADL Service Description
HTML Service Description
![Page 27: A model-driven approach for REST compliant servicesdesign.inf.usi.ch/sites/default/files/seminar-2014... · 2014-08-29 · University of Stuttgart Universitätsstr. 38 70569 Stuttgart](https://reader033.vdocuments.us/reader033/viewer/2022042916/5f544ba4cec7d3513135438b/html5/thumbnails/27.jpg)
27
Prototype
![Page 28: A model-driven approach for REST compliant servicesdesign.inf.usi.ch/sites/default/files/seminar-2014... · 2014-08-29 · University of Stuttgart Universitätsstr. 38 70569 Stuttgart](https://reader033.vdocuments.us/reader033/viewer/2022042916/5f544ba4cec7d3513135438b/html5/thumbnails/28.jpg)
© Florian Haupt 28
Rese
arch
A model-driven approach for REST compliant services – USI Informatics Seminar, Lugano, 2014-08-25
Prototype – Overview
� Graphical tool supporting model creation, validation and transformation
� Integrated in Eclipse platform based on Eclipse Epsilon (EMF, GMF)
� Supports generation of HTML based documentation � Supports generation of JAX-RS based implementation
![Page 29: A model-driven approach for REST compliant servicesdesign.inf.usi.ch/sites/default/files/seminar-2014... · 2014-08-29 · University of Stuttgart Universitätsstr. 38 70569 Stuttgart](https://reader033.vdocuments.us/reader033/viewer/2022042916/5f544ba4cec7d3513135438b/html5/thumbnails/29.jpg)
© Florian Haupt 29
Rese
arch
A model-driven approach for REST compliant services – USI Informatics Seminar, Lugano, 2014-08-25
Prototype – Screenshots
![Page 30: A model-driven approach for REST compliant servicesdesign.inf.usi.ch/sites/default/files/seminar-2014... · 2014-08-29 · University of Stuttgart Universitätsstr. 38 70569 Stuttgart](https://reader033.vdocuments.us/reader033/viewer/2022042916/5f544ba4cec7d3513135438b/html5/thumbnails/30.jpg)
© Florian Haupt 32
Rese
arch
A model-driven approach for REST compliant services – USI Informatics Seminar, Lugano, 2014-08-25
Prototype – URL Model & Eclipse Integration
![Page 31: A model-driven approach for REST compliant servicesdesign.inf.usi.ch/sites/default/files/seminar-2014... · 2014-08-29 · University of Stuttgart Universitätsstr. 38 70569 Stuttgart](https://reader033.vdocuments.us/reader033/viewer/2022042916/5f544ba4cec7d3513135438b/html5/thumbnails/31.jpg)
33
Formalization
![Page 32: A model-driven approach for REST compliant servicesdesign.inf.usi.ch/sites/default/files/seminar-2014... · 2014-08-29 · University of Stuttgart Universitätsstr. 38 70569 Stuttgart](https://reader033.vdocuments.us/reader033/viewer/2022042916/5f544ba4cec7d3513135438b/html5/thumbnails/32.jpg)
© Florian Haupt 37
Rese
arch
A model-driven approach for REST compliant services – USI Informatics Seminar, Lugano, 2014-08-25
Resource Graph
� A REST API is a set resources connected with links � A graph!
� GRES = (VRES, ERES) � VRES = set of resources (set of MR(t) functions) � ERES � (VRES x VRES) = set of relations between
resources
![Page 33: A model-driven approach for REST compliant servicesdesign.inf.usi.ch/sites/default/files/seminar-2014... · 2014-08-29 · University of Stuttgart Universitätsstr. 38 70569 Stuttgart](https://reader033.vdocuments.us/reader033/viewer/2022042916/5f544ba4cec7d3513135438b/html5/thumbnails/33.jpg)
© Florian Haupt 38
Rese
arch
A model-driven approach for REST compliant services – USI Informatics Seminar, Lugano, 2014-08-25
Resource Graph – Example
G1 = (V1, E1) V1 = {Library, BookList, Book, JournalList, Journal} E1 = {(Library, BookList), (BookList, Book), (Library, JournalList), (JournalList, Journal)}
Library
JournalList
BookList
Journal
Book
![Page 34: A model-driven approach for REST compliant servicesdesign.inf.usi.ch/sites/default/files/seminar-2014... · 2014-08-29 · University of Stuttgart Universitätsstr. 38 70569 Stuttgart](https://reader033.vdocuments.us/reader033/viewer/2022042916/5f544ba4cec7d3513135438b/html5/thumbnails/34.jpg)
© Florian Haupt 39
Rese
arch
A model-driven approach for REST compliant services – USI Informatics Seminar, Lugano, 2014-08-25
Relations – Details
� Card: ERES Æ {“1”, “*”} � Assigns a cardinality to each relation � Complete mapping, i.e. well defined for each relation
� Type: ERES Æ P{“navigation”, “creation”}\{} � Assigns one or more types to a relation
� Set of types is user defined / extensible
� Complete mapping, i.e. well defined for each relation � And mapping to the empty set is not allowed
![Page 35: A model-driven approach for REST compliant servicesdesign.inf.usi.ch/sites/default/files/seminar-2014... · 2014-08-29 · University of Stuttgart Universitätsstr. 38 70569 Stuttgart](https://reader033.vdocuments.us/reader033/viewer/2022042916/5f544ba4cec7d3513135438b/html5/thumbnails/35.jpg)
© Florian Haupt 40
Rese
arch
A model-driven approach for REST compliant services – USI Informatics Seminar, Lugano, 2014-08-25
Relations – Example
G1 = (V1, E1) V1 = {Library, BookList, Book, JournalList, Journal} E1 = {(Library, BookList), (BookList, Book), (Library, JournalList), (JournalList, Journal)} Card = Type =
Library
JournalList
BookList
Journal
Book
(Library, BookList) Æ “1” (BookList, Book) Æ “*” (Library, JournalList) Æ “1” (JournalList, Journal) Æ “*”
*
*
1
1
(Library, BookList) Æ {navigation} (BookList, Book) Æ {navigation, creation} (Library, JournalList) Æ {navigation} (JournalList, Journal) Æ {navigation, creation}
![Page 36: A model-driven approach for REST compliant servicesdesign.inf.usi.ch/sites/default/files/seminar-2014... · 2014-08-29 · University of Stuttgart Universitätsstr. 38 70569 Stuttgart](https://reader033.vdocuments.us/reader033/viewer/2022042916/5f544ba4cec7d3513135438b/html5/thumbnails/36.jpg)
© Florian Haupt 41
Rese
arch
A model-driven approach for REST compliant services – USI Informatics Seminar, Lugano, 2014-08-25
URI Graph (1)
� GURI = (VRES, EURI) � Same nodes like resource graph but different edges
� EURI � ERES � All relations between resources that are annotated with an
URI fragment
![Page 37: A model-driven approach for REST compliant servicesdesign.inf.usi.ch/sites/default/files/seminar-2014... · 2014-08-29 · University of Stuttgart Universitätsstr. 38 70569 Stuttgart](https://reader033.vdocuments.us/reader033/viewer/2022042916/5f544ba4cec7d3513135438b/html5/thumbnails/37.jpg)
© Florian Haupt 42
Rese
arch
A model-driven approach for REST compliant services – USI Informatics Seminar, Lugano, 2014-08-25
URI Graph – Example
Library
AuthorList
BookList
Author
Book http://example.org/lib
Catalog /catalog
/books
/{book.isbn}
/authors /{author.id}
Library
AuthorList
BookList
Author
Book
Catalog
![Page 38: A model-driven approach for REST compliant servicesdesign.inf.usi.ch/sites/default/files/seminar-2014... · 2014-08-29 · University of Stuttgart Universitätsstr. 38 70569 Stuttgart](https://reader033.vdocuments.us/reader033/viewer/2022042916/5f544ba4cec7d3513135438b/html5/thumbnails/38.jpg)
© Florian Haupt 43
Rese
arch
A model-driven approach for REST compliant services – USI Informatics Seminar, Lugano, 2014-08-25
URI Graph (2)
� RootEXPL = VRES Æ {true, false} � User defined
� RootIMPL = VRES Æ { true � V � VRES | � (S,T) � EURI : T z V, false else} � Resources without any incoming relation with URI
annotations
� VRES-ROOT = {V � VRES | RootEXPL � RootIMPL} � Root resources
![Page 39: A model-driven approach for REST compliant servicesdesign.inf.usi.ch/sites/default/files/seminar-2014... · 2014-08-29 · University of Stuttgart Universitätsstr. 38 70569 Stuttgart](https://reader033.vdocuments.us/reader033/viewer/2022042916/5f544ba4cec7d3513135438b/html5/thumbnails/39.jpg)
© Florian Haupt 44
Rese
arch
A model-driven approach for REST compliant services – USI Informatics Seminar, Lugano, 2014-08-25
URI Graph (3)
� URIAnnotation: ERES Æ (URIFragmentStatic � URIFragmentDynamic) � URI fragment annotations attached to the relations of the
resource graph � Incomplete, i.e. maybe undefined for a relation � URIFragmentDynamic = contains variable parts, denoted
by {} � URIFragmentStatic = contains no variable parts
� EURI = {E � ERES | URIAnnotation(E) is defined}
![Page 40: A model-driven approach for REST compliant servicesdesign.inf.usi.ch/sites/default/files/seminar-2014... · 2014-08-29 · University of Stuttgart Universitätsstr. 38 70569 Stuttgart](https://reader033.vdocuments.us/reader033/viewer/2022042916/5f544ba4cec7d3513135438b/html5/thumbnails/40.jpg)
45
Use Cases
![Page 41: A model-driven approach for REST compliant servicesdesign.inf.usi.ch/sites/default/files/seminar-2014... · 2014-08-29 · University of Stuttgart Universitätsstr. 38 70569 Stuttgart](https://reader033.vdocuments.us/reader033/viewer/2022042916/5f544ba4cec7d3513135438b/html5/thumbnails/41.jpg)
© Florian Haupt 46
Rese
arch
A model-driven approach for REST compliant services – USI Informatics Seminar, Lugano, 2014-08-25
Detect ambiguity in URL structures
� “Avoid runtime exceptions in JAX-RS”
Library
JournalList
BookList
Journal
Book /{book.isbn}
/{journal.issn}
/books
/journals
Library
Journal
Book /{book.isbn}
/{journal.issn}
![Page 42: A model-driven approach for REST compliant servicesdesign.inf.usi.ch/sites/default/files/seminar-2014... · 2014-08-29 · University of Stuttgart Universitätsstr. 38 70569 Stuttgart](https://reader033.vdocuments.us/reader033/viewer/2022042916/5f544ba4cec7d3513135438b/html5/thumbnails/42.jpg)
© Florian Haupt 47
Rese
arch
A model-driven approach for REST compliant services – USI Informatics Seminar, Lugano, 2014-08-25
Check URI mapping for completeness
� “Avoid runtime exceptions in JAX-RS”
Library
AuthorList
BookList
Author
Book /{book.isbn}
/{author.id}
/books
/authors
Publisher
The Publisher resource is not accessible, it has no URI assigned.
Library
AuthorList
BookList
Author
Book Publisher
The URI graph contains orphan nodes.
![Page 43: A model-driven approach for REST compliant servicesdesign.inf.usi.ch/sites/default/files/seminar-2014... · 2014-08-29 · University of Stuttgart Universitätsstr. 38 70569 Stuttgart](https://reader033.vdocuments.us/reader033/viewer/2022042916/5f544ba4cec7d3513135438b/html5/thumbnails/43.jpg)
© Florian Haupt 48
Rese
arch
A model-driven approach for REST compliant services – USI Informatics Seminar, Lugano, 2014-08-25
Detect infinite URIs
� “Avoid runtime exceptions in JAX-RS”
Library
AuthorList
BookList
Author
Book /{book.isbn}
/{author.id}
/books
/authors
Bibliography
/author
/bibliography
/{book.isbn}
Library
AuthorList
BookList
Author
Book Bibliography
http://example.org/library/books/12/author/bibliography/12/author/bibliography/12/author/…
![Page 44: A model-driven approach for REST compliant servicesdesign.inf.usi.ch/sites/default/files/seminar-2014... · 2014-08-29 · University of Stuttgart Universitätsstr. 38 70569 Stuttgart](https://reader033.vdocuments.us/reader033/viewer/2022042916/5f544ba4cec7d3513135438b/html5/thumbnails/44.jpg)
49
Conclusion
![Page 45: A model-driven approach for REST compliant servicesdesign.inf.usi.ch/sites/default/files/seminar-2014... · 2014-08-29 · University of Stuttgart Universitätsstr. 38 70569 Stuttgart](https://reader033.vdocuments.us/reader033/viewer/2022042916/5f544ba4cec7d3513135438b/html5/thumbnails/45.jpg)
© Florian Haupt 50
Rese
arch
A model-driven approach for REST compliant services – USI Informatics Seminar, Lugano, 2014-08-25
Contact [email protected] www.iaas.uni-stuttgart.de
Conclusion
� Designing REST compliant services is challenging � We propose to use MDSD techniques to tackle this � For that we provide
� A set of meta-models � A set of model-to-model transformations � A prototype
� Formalization as alternative modeling approach � Foundation for model analysis
![Page 46: A model-driven approach for REST compliant servicesdesign.inf.usi.ch/sites/default/files/seminar-2014... · 2014-08-29 · University of Stuttgart Universitätsstr. 38 70569 Stuttgart](https://reader033.vdocuments.us/reader033/viewer/2022042916/5f544ba4cec7d3513135438b/html5/thumbnails/46.jpg)
© Florian Haupt 51
Rese
arch
A model-driven approach for REST compliant services – USI Informatics Seminar, Lugano, 2014-08-25
References
[1] Fielding, R.: REST APIs must be hypertext-driven. http://roy.gbiv.com/untangled/2008/rest-apis-must-be-hypertext-driven.
[2] Fielding, R. T.: Architectural styles and the design of network-based software architectures. Dissertation, University of California, Irvine, 2000.
[3] Haupt, F.; Karastoyanova, D.; Leymann, F.; Schroth, B.: A model driven approach for REST compliant services. In: Proceedings of the IEEE International Conference on Web Services, ICWS 2014.
![Page 47: A model-driven approach for REST compliant servicesdesign.inf.usi.ch/sites/default/files/seminar-2014... · 2014-08-29 · University of Stuttgart Universitätsstr. 38 70569 Stuttgart](https://reader033.vdocuments.us/reader033/viewer/2022042916/5f544ba4cec7d3513135438b/html5/thumbnails/47.jpg)
53