SlideShare a Scribd company logo
1 of 24
Download to read offline
ECMFA 2016: Metamodeling vs Metaprogramming
Metamodeling vs Metaprogramming
A Case Study on Developing Client Libraries for REST APIs
Markus Scheidgen
scheidge@informatik.hu-berlin.de
@mscheidgen
Frederik Marticke
marticke@informatik.hu-berlin.de
Sven Efftinge
sven.efftinge@typefox.io
@svenefftinge
1
ECMFA 2016: Metamodeling vs Metaprogramming
RESTful Web Applications
Metamodeling vs Metaprogramming
Markus Scheidgen
scheidge@informatik.hu-berlin.de
@mscheidgen
Frederik Marticke
marticke@informatik.hu-berlin.de
Sven Efftinge
sven.efftinge@typefox.io
@sefftinge
2
ECMFA 2016: Metamodeling vs Metaprogramming
Agenda
■ Model-driven for Web Applications
■ Representational State Transfer (REST)
■ Metamodeling: external DSL
■ Metaprogramming: Active Annotations
■ Conclusions
3
ECMFA 2016: Metamodeling vs Metaprogramming
MDD and WEB REST Metamodeling Active Annotations Conclusions
Web Applications
4
Endpoints
GWT: Java
Javascript
Cloud Storage
e.g. from Google
Hypertext Transfer Protocol (HTTP)
Client
e.g. Web Browser
Server
e.g. App Engine
ECMFA 2016: Metamodeling vs Metaprogramming
MDD and WEB REST Metamodeling Active Annotations Conclusions
Web Applications – Horizontal “Platforms”
5
Endpoints
GWT: Java
Javascript
Graph Database
e.g. Neo4J
Servlet: JavaRuby JavascriptPython PHP
Document Database
e.g. MongoDB
Cloud Stoage
e.g. from Google
SQL Database
e.g. MySQL
Hypertext Transfer Protocol (HTTP)
JavascriptJava
e.g. on Android
Objective-C
e.g. on iOS
Dart
ECMFA 2016: Metamodeling vs Metaprogramming
MDD and WEB REST Metamodeling Active Annotations Conclusions
Web Applications – Horizontal “Platforms”
6
Endpoints
GWT: Java
Javascript
Graph Database
e.g. Neo4J
Servlet: JavaRuby JavascriptPython PHP
Document Database
e.g. MongoDB
Cloud Stoage
e.g. from Google
SQL Database
e.g. MySQL
Hypertext Transfer Protocol (HTTP)
JavascriptJava
e.g. on Android
Objective-C
e.g. on iOS
Dart
ECMFA 2016: Metamodeling vs Metaprogramming
MDD and WEB REST Metamodeling Active Annotations Conclusions
Web Applications – Horizontal “Platforms”
7
Endpoints
GWT: Java
Javascript
Graph Database
e.g. Neo4J
Servlet: JavaRuby JavascriptPython PHP
Document Database
e.g. MongoDB
Cloud Stoage
e.g. from Google
SQL Database
e.g. MySQL
Hypertext Transfer Protocol (HTTP)
JavascriptJava
e.g. on Android
Objective-C
e.g. on iOS
Dart
ECMFA 2016: Metamodeling vs Metaprogramming
MDD and WEB REST Metamodeling Active Annotations Conclusions
Web Applications – Vertical “Platforms”
8
Endpoints
GWT: Java
Javascript
Graph Database
e.g. Neo4J
Servlet: JavaRuby JavascriptPython PHP
Document Database
e.g. MongoDB
Cloud Stoage
e.g. from Google
SQL Database
e.g. MySQL
Hypertext Transfer Protocol (HTTP)
JavascriptJava
e.g. on Android
Objective-C
e.g. on iOS
Dart
object.name = “John”
json.put(“name”, “John”);
bean.setName(“John”);
entity.set(“name”,“John”);
{ name : “John” }
ECMFA 2016: Metamodeling vs Metaprogramming
Introduction REST Metamodeling Active Annotations Conclusions
Representational State Transfer (REST)
■ Set of principles for distributed architectures by
Roy Fielding
■ Most importantly: stateless server
■ Allows robust, scalable, easy to build and easy to
maintain server
■ In practice almost always synonymous with web-
services based on HTTP and JSON
■ Examples: Facebook, Twitter, Google+, Youtube, ...
9
CLIENT
10
GET
api.twitter.com/1.1/
statuses/user_timeline.json?
screen_name=”mscheidgen”
GET
api.twitter.com/1.1/
statuses/user_timeline.json?
screen_name=”mscheidgen”&
max_id=”37..3”
[
{
id : 123336
text : “Som
favorits : 2
user : {
screen_n
name : “M
follower :
}, ...
}, ...
{
id : 364625
text : “Che
}
]
SERVER
200 OK
[
{
id : 1233364542,
text : “Going to ECMFA; #STAF”,
favorits : 21, retweets = 3,
user : {
screen_name : “mscheidgen”,
name : “Markus Scheidgen”,
follower : 1021, ...
}, ...
}, ...
{
id : 374256453
text : “Check out the new ...”, ...
}
]
reprsentational
state transfer
ECMFA 2016: Metamodeling vs Metaprogramming
Introduction REST Metamodeling Active Annotations Conclusions
11
REST – How it works
■ Identify resources via URLs: host, path, and
parameters
■ CRUD methods, i.e. HTTP’s PUT, GET, POST,
DELETE
■ Resource contents is represented platform
independently as JSON (or XML)
■ HATEOAS: ideally hyperlinks in resources
connect all resources of one service
ECMFA 2016: Metamodeling vs Metaprogramming
Introduction REST Metamodeling Active Annotations Conclusions
REST – Metrics and Flaws
+ HTTP and JSON are platform independent, libraries
for most systems and programming languages exist
- HTTP and JSON represent the smallest common
denominator for most systems and programming
languages
- Loads of platform specific boilerplate code to
process HTTP and JSON
- No static types for URL and JSON data, no static
safety
12
ECMFA 2016: Metamodeling vs Metaprogramming
Introduction REST Metamodeling Active Annotations Conclusions
REST – Client Libraries
13
val request = HTTP.get("api.twitter.com/1.1/"statuses/user_timeline.json")
request.queryString("screen_name", "mscheidgen")
val str = request.asString()
val jsonNode = JSON.parse(str)
val jsonArray = jsonNode.asArray()
for (i:0..<jsonArray.length) {
val jsonItem = jsonArray.get(i);
println(jsonItem.get("text"))
}
val result = twitter.statuses.userTimeline.
userId("mscheidgen").xResult()
for (item:result) {
println(item.text)
}
exists?
right type?
is it an array?
exists/right type?
save
ECMFA 2016: Metamodeling vs Metaprogramming
Introduction REST Metamodeling Active Annotations Conclusions
REST – Client Libraries
■ language specific, uses language features, i.e. type safety
■ turns HTTP request/response RPCs into regular method
calls
■ comprises
■ a method for each API function
■ a wrapper type for each API resource type
■ Client libraries consist of very canonical, schematic
boilerplate code. They are dull, tedious, and error prone to
make.
14
ECMFA 2016: Metamodeling vs Metaprogramming
Introduction REST Metamodeling Active Annotations Conclusions
Code
the desired platform code, e.g.
a REST client library
Code
the desired platform code, e.g.
a REST client library
Code-Generator
a tool that processes a
metamodel instance to
generates code
Code-Generator
a tool that processes a
metamodel instance to
generates code
Platform/
Language
Platform/
Language
Metamodeling
15
Metamodel
defines language constructs,
e.g. constructs to define REST
request and resource types
Model
uses the given language
constructs, e.g. to describe a
REST API
Code-Generator
a tool that processes a
metamodel instance to
generates code
Code
the desired platform code, e.g.
a REST client library
Metametamodel
the metamodeling language
Code-Generator
Language
Platform/
Language
ECMFA 2016: Metamodeling vs Metaprogramming
Introduction REST Metamodeling Active Annotations Conclusions
A Metamodel for REST APIs
16
method:Methods
path:EString
Request
separator:EString
Parameter
PrimitiveDataType
ComplexDataType
Response
Field
GET
POST
PUT
DELETE
«enum»
Methods
type 1
response 1
{subsets features}
pathPattern:EString
PathParameter
baseURL:EString
REST-API
features 0..*
parameters 0..*
{subsets features}
Class
array:EBoolean
Feature DataType
name:EString
NamedElement
0..* parameters
{redefines features} 0..*
dataTypes
0..*
requests
QueryParameter BodyParameter
get request Timeline
for “statuses/user_timeline.json”
returns array of Status {
query max_id : String
query screen_name : String
}
datatype Status {
id : String
text : String
favorits : Integer
retweets : Integer
user : User
}
datatype User {
screen_name : String
name : String
...
}
ECMFA 2016: Metamodeling vs Metaprogramming
Introduction REST Metamodeling Active Annotations Conclusions
xTend
17
@request(path=“statuses/user_timeline.json”,
response=@Response(type=Status, isArray=true))
class Timeline {
String max_id
String screen_name
}
@JSON class Status {
String id
String text
int favorits
int retweets
User user
}
@JSON class User {
String screen_name
String name
...
}
get request Timeline
for “statuses/user_timeline.json”
returns array of Status {
query max_id : String
query screen_name : String
}
datatype Status {
id : String
text : String
favorits : Integer
retweets : Integer
user : User
}
datatype User {
screen_name : String
name : String
...
}
ECMFA 2016: Metamodeling vs Metaprogramming
Introduction REST Metamodeling Active Annotations Conclusions
Metaprogramming xTend – Active Annotations
18
@Request(path="statuses/user_timeline.json",
response=@Response(type=Status, isArray=true))
class Timeline {
String max_id
String screen_name
}
public class Timeline extends AbstractRequest<List<Status>> {
@Override
public List<Status> xResult() {
JSONArray jsonArray = xResponse().getJSONArray("");
List<Status> result = new ArrayList<Status>();
for (int i = 0; i < jsonArray.length(); i++) {
result.add(new Status(jsonArray.getJSONObject(i)));
}
return Collections.unmodifiableList(result);
}
...
xTend compiler + RequestClassProcessor implements
RegisterGlobalsParticipant
TransformationParticipant
CodeGenerationParticipant
ValidationParticipant
ECMFA 2016: Metamodeling vs Metaprogramming
Introduction REST Metamodeling Active Annotations Conclusions
Active Annotations – Simple Examples
19
@AddConstructor
class Customer {
private val String id
@Accessors(PUBLIC_GETTER, PROTECTED_SETTER)
private String name
}
public class Customer {
private final String id;
private String name;
public Customer(final String id) {
super();
this.id = id;
}
public String getName() {
return this.name;
}
protected void setName(final String name) {
this.name = name;
}
}
ECMFA 2016: Metamodeling vs Metaprogramming
Introduction REST Metamodeling Active Annotations Conclusions
Metamodeling vs Metaprogramming
20
xTend Language
xTend Code
e.g. uses annotations to describe
REST request and resource types
xTend Compiler
Code
the desired Java code, e.g. a
REST client library
Active Annotations Class Processors
Code
the desired platform code, e.g.
Code
the desired platform code, e.g.
Code-GeneratorCode-Generator
Metamodel
Model
Code-Generator
Code
the desired platform code, e.g. a
REST client library
ECMFA 2016: Metamodeling vs Metaprogramming
Introduction REST Metamodeling Active Annotations Conclusions
Beyond REST – Active Annotation and Web
21
Endpoints
GWT: Java
Javascript
Cloud Storage
e.g. from Google
HTTP
@GWTJavaScriptObject
@JSONObject
@JavaBean
@CloudStorageEntity
class User {
String screen_name
String name
...
}
object.name = “John”
json.put(“name”, “John”);
bean.setName(“John”);
entity.set(“name”,“John”);
{ name : “John” }
ECMFA 2016: Metamodeling vs Metaprogramming
Introduction REST Metamodeling Active Annotations Conclusions
Beyond REST – Active Annotation and Web
22
class Statuses {
@com.google.endpoints.ApiMethod(
name=“statuses/user_timeline.json”)
@RequestFromEndpoints
@ApiMethodMockup
List<StatusBean> getTimeline(
String screenName,
String maxId) {
...
}
}
@Request(path=“statuses/user_timeline.json”,
response=@Response(type=Status, isArray=true))
class Timeline {
String max_id
String screen_name
}
REST Client Library Request Code
Server CodeMockup Skeleton
a bare bone implementa-
tion for tests
HTTP
ECMFA 2016: Metamodeling vs Metaprogramming
Introduction REST Metamodeling Active Annotations Conclusions
Conclusions
■ Model-driven can be used for Web application
development, especially for REST APIs
■ Active annotations can be used like stereotype
to extend an existing programming language
■ Active annotation are an internal DSL alternative
to custom code-generation
23
ECMFA 2016: Metamodeling vs Metaprogramming
Introduction REST Metamodeling Active Annotations Conclusions
Questions
24
xTend Language
xTend Code
e.g. uses annotations to describe
REST request and resource types
xTend Compiler
Code
the desired Java code, e.g. a
REST client library
Active Annotations Class Processors
Code
the desired platform code, e.g.
Code
the desired platform code, e.g.
Code-GeneratorCode-Generator
Metamodel
Model
Code-Generator
Code
the desired platform code, e.g. a
REST client library

More Related Content

What's hot

20100309 03 - Vulnerability analysis (McCabe)
20100309 03 - Vulnerability analysis (McCabe)20100309 03 - Vulnerability analysis (McCabe)
20100309 03 - Vulnerability analysis (McCabe)LeClubQualiteLogicielle
 
An Empirical Study of Refactorings and Technical Debt in Machine Learning Sys...
An Empirical Study of Refactorings and Technical Debt in Machine Learning Sys...An Empirical Study of Refactorings and Technical Debt in Machine Learning Sys...
An Empirical Study of Refactorings and Technical Debt in Machine Learning Sys...Raffi Khatchadourian
 
Analyzing Changes in Software Systems From ChangeDistiller to FMDiff
Analyzing Changes in Software Systems From ChangeDistiller to FMDiffAnalyzing Changes in Software Systems From ChangeDistiller to FMDiff
Analyzing Changes in Software Systems From ChangeDistiller to FMDiffMartin Pinzger
 
Opal Hermes - towards representative benchmarks
Opal  Hermes - towards representative benchmarksOpal  Hermes - towards representative benchmarks
Opal Hermes - towards representative benchmarksMichaelEichberg1
 
Ontology-based data access: why it is so cool!
Ontology-based data access: why it is so cool!Ontology-based data access: why it is so cool!
Ontology-based data access: why it is so cool!Josef Hardi
 
Model-Based Co-Evolution of Production Systems and their Libraries with Auto...
Model-Based Co-Evolution of Production Systems and their Libraries with Auto...Model-Based Co-Evolution of Production Systems and their Libraries with Auto...
Model-Based Co-Evolution of Production Systems and their Libraries with Auto...Luca Berardinelli
 
Ontologies Ontop Databases
Ontologies Ontop DatabasesOntologies Ontop Databases
Ontologies Ontop DatabasesMartín Rezk
 
Applying the Scientific Method to Simulation Experiments
Applying the Scientific Method to Simulation ExperimentsApplying the Scientific Method to Simulation Experiments
Applying the Scientific Method to Simulation ExperimentsFrank Bergmann
 
DeepAM: Migrate APIs with Multi-modal Sequence to Sequence Learning
DeepAM: Migrate APIs with Multi-modal Sequence to Sequence LearningDeepAM: Migrate APIs with Multi-modal Sequence to Sequence Learning
DeepAM: Migrate APIs with Multi-modal Sequence to Sequence LearningSung Kim
 
Stanford'12 Intro to Ontology Based Data Access for RDBMS through query rewri...
Stanford'12 Intro to Ontology Based Data Access for RDBMS through query rewri...Stanford'12 Intro to Ontology Based Data Access for RDBMS through query rewri...
Stanford'12 Intro to Ontology Based Data Access for RDBMS through query rewri...Mariano Rodriguez-Muro
 
MGU SYLLABUS MANUAL-Advance diploma in computer applications
MGU SYLLABUS MANUAL-Advance diploma in computer applicationsMGU SYLLABUS MANUAL-Advance diploma in computer applications
MGU SYLLABUS MANUAL-Advance diploma in computer applicationsmahatmagandhiuniversity
 
8th TUC Meeting – George Fletcher (TU Eindhoven), gMark: Schema-driven data a...
8th TUC Meeting – George Fletcher (TU Eindhoven), gMark: Schema-driven data a...8th TUC Meeting – George Fletcher (TU Eindhoven), gMark: Schema-driven data a...
8th TUC Meeting – George Fletcher (TU Eindhoven), gMark: Schema-driven data a...LDBC council
 
BASIC CONCEPTS OF C++ CLASS 12
BASIC CONCEPTS OF C++ CLASS 12BASIC CONCEPTS OF C++ CLASS 12
BASIC CONCEPTS OF C++ CLASS 12Dev Chauhan
 
GenePattern: Ted Liefeld
GenePattern: Ted LiefeldGenePattern: Ted Liefeld
GenePattern: Ted Liefeldniranabey
 
Ontop: Answering SPARQL Queries over Relational Databases
Ontop: Answering SPARQL Queries over Relational DatabasesOntop: Answering SPARQL Queries over Relational Databases
Ontop: Answering SPARQL Queries over Relational DatabasesGuohui Xiao
 

What's hot (20)

ExSchema
ExSchemaExSchema
ExSchema
 
20100309 03 - Vulnerability analysis (McCabe)
20100309 03 - Vulnerability analysis (McCabe)20100309 03 - Vulnerability analysis (McCabe)
20100309 03 - Vulnerability analysis (McCabe)
 
An Empirical Study of Refactorings and Technical Debt in Machine Learning Sys...
An Empirical Study of Refactorings and Technical Debt in Machine Learning Sys...An Empirical Study of Refactorings and Technical Debt in Machine Learning Sys...
An Empirical Study of Refactorings and Technical Debt in Machine Learning Sys...
 
Icpc11c.ppt
Icpc11c.pptIcpc11c.ppt
Icpc11c.ppt
 
Analyzing Changes in Software Systems From ChangeDistiller to FMDiff
Analyzing Changes in Software Systems From ChangeDistiller to FMDiffAnalyzing Changes in Software Systems From ChangeDistiller to FMDiff
Analyzing Changes in Software Systems From ChangeDistiller to FMDiff
 
Icsme16.ppt
Icsme16.pptIcsme16.ppt
Icsme16.ppt
 
Opal Hermes - towards representative benchmarks
Opal  Hermes - towards representative benchmarksOpal  Hermes - towards representative benchmarks
Opal Hermes - towards representative benchmarks
 
Ontology-based data access: why it is so cool!
Ontology-based data access: why it is so cool!Ontology-based data access: why it is so cool!
Ontology-based data access: why it is so cool!
 
Model-Based Co-Evolution of Production Systems and their Libraries with Auto...
Model-Based Co-Evolution of Production Systems and their Libraries with Auto...Model-Based Co-Evolution of Production Systems and their Libraries with Auto...
Model-Based Co-Evolution of Production Systems and their Libraries with Auto...
 
Ontologies Ontop Databases
Ontologies Ontop DatabasesOntologies Ontop Databases
Ontologies Ontop Databases
 
Applying the Scientific Method to Simulation Experiments
Applying the Scientific Method to Simulation ExperimentsApplying the Scientific Method to Simulation Experiments
Applying the Scientific Method to Simulation Experiments
 
DeepAM: Migrate APIs with Multi-modal Sequence to Sequence Learning
DeepAM: Migrate APIs with Multi-modal Sequence to Sequence LearningDeepAM: Migrate APIs with Multi-modal Sequence to Sequence Learning
DeepAM: Migrate APIs with Multi-modal Sequence to Sequence Learning
 
Stanford'12 Intro to Ontology Based Data Access for RDBMS through query rewri...
Stanford'12 Intro to Ontology Based Data Access for RDBMS through query rewri...Stanford'12 Intro to Ontology Based Data Access for RDBMS through query rewri...
Stanford'12 Intro to Ontology Based Data Access for RDBMS through query rewri...
 
MGU SYLLABUS MANUAL-Advance diploma in computer applications
MGU SYLLABUS MANUAL-Advance diploma in computer applicationsMGU SYLLABUS MANUAL-Advance diploma in computer applications
MGU SYLLABUS MANUAL-Advance diploma in computer applications
 
Results of the FLOSSMetrics project
Results of the FLOSSMetrics projectResults of the FLOSSMetrics project
Results of the FLOSSMetrics project
 
8th TUC Meeting – George Fletcher (TU Eindhoven), gMark: Schema-driven data a...
8th TUC Meeting – George Fletcher (TU Eindhoven), gMark: Schema-driven data a...8th TUC Meeting – George Fletcher (TU Eindhoven), gMark: Schema-driven data a...
8th TUC Meeting – George Fletcher (TU Eindhoven), gMark: Schema-driven data a...
 
BASIC CONCEPTS OF C++ CLASS 12
BASIC CONCEPTS OF C++ CLASS 12BASIC CONCEPTS OF C++ CLASS 12
BASIC CONCEPTS OF C++ CLASS 12
 
GenePattern: Ted Liefeld
GenePattern: Ted LiefeldGenePattern: Ted Liefeld
GenePattern: Ted Liefeld
 
ontop: A tutorial
ontop: A tutorialontop: A tutorial
ontop: A tutorial
 
Ontop: Answering SPARQL Queries over Relational Databases
Ontop: Answering SPARQL Queries over Relational DatabasesOntop: Answering SPARQL Queries over Relational Databases
Ontop: Answering SPARQL Queries over Relational Databases
 

Similar to Metamodeling vs Metaprogramming, A Case Study on Developing Client Libraries for REST APIs

CTS Conference Web 2.0 Tutorial Part 2
CTS Conference Web 2.0 Tutorial Part 2CTS Conference Web 2.0 Tutorial Part 2
CTS Conference Web 2.0 Tutorial Part 2Geoffrey Fox
 
Node.js for enterprise - JS Conference
Node.js for enterprise - JS ConferenceNode.js for enterprise - JS Conference
Node.js for enterprise - JS ConferenceTimur Shemsedinov
 
David Gómez G. - Hypermedia APIs for headless platforms and Data Integration ...
David Gómez G. - Hypermedia APIs for headless platforms and Data Integration ...David Gómez G. - Hypermedia APIs for headless platforms and Data Integration ...
David Gómez G. - Hypermedia APIs for headless platforms and Data Integration ...Codemotion
 
Cdm mil-18 - hypermedia ap is for headless platforms and data integration
Cdm mil-18 - hypermedia ap is for headless platforms and data integrationCdm mil-18 - hypermedia ap is for headless platforms and data integration
Cdm mil-18 - hypermedia ap is for headless platforms and data integrationDavid Gómez García
 
myEquivalents, aka a new cross-reference service
myEquivalents, aka a new cross-reference servicemyEquivalents, aka a new cross-reference service
myEquivalents, aka a new cross-reference serviceRothamsted Research, UK
 
Server Side Swift - AppBuilders 2017
Server Side Swift - AppBuilders 2017Server Side Swift - AppBuilders 2017
Server Side Swift - AppBuilders 2017Jens Ravens
 
May 2010 - RestEasy
May 2010 - RestEasyMay 2010 - RestEasy
May 2010 - RestEasyJBug Italy
 
Web-based IoT standardization activity including OMA GotAPI and DWAPI
Web-based IoT standardization activity including OMA GotAPI and DWAPIWeb-based IoT standardization activity including OMA GotAPI and DWAPI
Web-based IoT standardization activity including OMA GotAPI and DWAPIDevice WebAPI Consortium
 
ASP.NET MVC - In the Wild
ASP.NET MVC - In the WildASP.NET MVC - In the Wild
ASP.NET MVC - In the WildBrian Boatright
 
Scala.js for large and complex frontend apps
Scala.js for large and complex frontend appsScala.js for large and complex frontend apps
Scala.js for large and complex frontend appsOtto Chrons
 
R, HTTP, and APIs, with a preview of TopicWatchr
R, HTTP, and APIs, with a preview of TopicWatchrR, HTTP, and APIs, with a preview of TopicWatchr
R, HTTP, and APIs, with a preview of TopicWatchrPortland R User Group
 
"R, HTTP, and APIs, with a preview of TopicWatchr" (15 November 2011)
"R, HTTP, and APIs, with a preview of TopicWatchr" (15 November 2011)"R, HTTP, and APIs, with a preview of TopicWatchr" (15 November 2011)
"R, HTTP, and APIs, with a preview of TopicWatchr" (15 November 2011)Portland R User Group
 
Hypermedia APIs and HATEOAS
Hypermedia APIs and HATEOASHypermedia APIs and HATEOAS
Hypermedia APIs and HATEOASVladimir Tsukur
 
Software Analysis for the Web: Achievements and Prospects
Software Analysis for the Web: Achievements and ProspectsSoftware Analysis for the Web: Achievements and Prospects
Software Analysis for the Web: Achievements and ProspectsAli Mesbah
 

Similar to Metamodeling vs Metaprogramming, A Case Study on Developing Client Libraries for REST APIs (20)

CTS Conference Web 2.0 Tutorial Part 2
CTS Conference Web 2.0 Tutorial Part 2CTS Conference Web 2.0 Tutorial Part 2
CTS Conference Web 2.0 Tutorial Part 2
 
Ajax
AjaxAjax
Ajax
 
Switch to Backend 2023
Switch to Backend 2023Switch to Backend 2023
Switch to Backend 2023
 
Node.js for enterprise - JS Conference
Node.js for enterprise - JS ConferenceNode.js for enterprise - JS Conference
Node.js for enterprise - JS Conference
 
RESTEasy
RESTEasyRESTEasy
RESTEasy
 
David Gómez G. - Hypermedia APIs for headless platforms and Data Integration ...
David Gómez G. - Hypermedia APIs for headless platforms and Data Integration ...David Gómez G. - Hypermedia APIs for headless platforms and Data Integration ...
David Gómez G. - Hypermedia APIs for headless platforms and Data Integration ...
 
Cdm mil-18 - hypermedia ap is for headless platforms and data integration
Cdm mil-18 - hypermedia ap is for headless platforms and data integrationCdm mil-18 - hypermedia ap is for headless platforms and data integration
Cdm mil-18 - hypermedia ap is for headless platforms and data integration
 
Ams adapters
Ams adaptersAms adapters
Ams adapters
 
myEquivalents, aka a new cross-reference service
myEquivalents, aka a new cross-reference servicemyEquivalents, aka a new cross-reference service
myEquivalents, aka a new cross-reference service
 
Ajax Lecture Notes
Ajax Lecture NotesAjax Lecture Notes
Ajax Lecture Notes
 
Server Side Swift - AppBuilders 2017
Server Side Swift - AppBuilders 2017Server Side Swift - AppBuilders 2017
Server Side Swift - AppBuilders 2017
 
May 2010 - RestEasy
May 2010 - RestEasyMay 2010 - RestEasy
May 2010 - RestEasy
 
Web-based IoT standardization activity including OMA GotAPI and DWAPI
Web-based IoT standardization activity including OMA GotAPI and DWAPIWeb-based IoT standardization activity including OMA GotAPI and DWAPI
Web-based IoT standardization activity including OMA GotAPI and DWAPI
 
ASP.NET MVC - In the Wild
ASP.NET MVC - In the WildASP.NET MVC - In the Wild
ASP.NET MVC - In the Wild
 
Scala.js for large and complex frontend apps
Scala.js for large and complex frontend appsScala.js for large and complex frontend apps
Scala.js for large and complex frontend apps
 
R, HTTP, and APIs, with a preview of TopicWatchr
R, HTTP, and APIs, with a preview of TopicWatchrR, HTTP, and APIs, with a preview of TopicWatchr
R, HTTP, and APIs, with a preview of TopicWatchr
 
"R, HTTP, and APIs, with a preview of TopicWatchr" (15 November 2011)
"R, HTTP, and APIs, with a preview of TopicWatchr" (15 November 2011)"R, HTTP, and APIs, with a preview of TopicWatchr" (15 November 2011)
"R, HTTP, and APIs, with a preview of TopicWatchr" (15 November 2011)
 
Hypermedia APIs and HATEOAS
Hypermedia APIs and HATEOASHypermedia APIs and HATEOAS
Hypermedia APIs and HATEOAS
 
Spring 4 Web App
Spring 4 Web AppSpring 4 Web App
Spring 4 Web App
 
Software Analysis for the Web: Achievements and Prospects
Software Analysis for the Web: Achievements and ProspectsSoftware Analysis for the Web: Achievements and Prospects
Software Analysis for the Web: Achievements and Prospects
 

Recently uploaded

From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 

Recently uploaded (20)

From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 

Metamodeling vs Metaprogramming, A Case Study on Developing Client Libraries for REST APIs

  • 1. ECMFA 2016: Metamodeling vs Metaprogramming Metamodeling vs Metaprogramming A Case Study on Developing Client Libraries for REST APIs Markus Scheidgen scheidge@informatik.hu-berlin.de @mscheidgen Frederik Marticke marticke@informatik.hu-berlin.de Sven Efftinge sven.efftinge@typefox.io @svenefftinge 1
  • 2. ECMFA 2016: Metamodeling vs Metaprogramming RESTful Web Applications Metamodeling vs Metaprogramming Markus Scheidgen scheidge@informatik.hu-berlin.de @mscheidgen Frederik Marticke marticke@informatik.hu-berlin.de Sven Efftinge sven.efftinge@typefox.io @sefftinge 2
  • 3. ECMFA 2016: Metamodeling vs Metaprogramming Agenda ■ Model-driven for Web Applications ■ Representational State Transfer (REST) ■ Metamodeling: external DSL ■ Metaprogramming: Active Annotations ■ Conclusions 3
  • 4. ECMFA 2016: Metamodeling vs Metaprogramming MDD and WEB REST Metamodeling Active Annotations Conclusions Web Applications 4 Endpoints GWT: Java Javascript Cloud Storage e.g. from Google Hypertext Transfer Protocol (HTTP) Client e.g. Web Browser Server e.g. App Engine
  • 5. ECMFA 2016: Metamodeling vs Metaprogramming MDD and WEB REST Metamodeling Active Annotations Conclusions Web Applications – Horizontal “Platforms” 5 Endpoints GWT: Java Javascript Graph Database e.g. Neo4J Servlet: JavaRuby JavascriptPython PHP Document Database e.g. MongoDB Cloud Stoage e.g. from Google SQL Database e.g. MySQL Hypertext Transfer Protocol (HTTP) JavascriptJava e.g. on Android Objective-C e.g. on iOS Dart
  • 6. ECMFA 2016: Metamodeling vs Metaprogramming MDD and WEB REST Metamodeling Active Annotations Conclusions Web Applications – Horizontal “Platforms” 6 Endpoints GWT: Java Javascript Graph Database e.g. Neo4J Servlet: JavaRuby JavascriptPython PHP Document Database e.g. MongoDB Cloud Stoage e.g. from Google SQL Database e.g. MySQL Hypertext Transfer Protocol (HTTP) JavascriptJava e.g. on Android Objective-C e.g. on iOS Dart
  • 7. ECMFA 2016: Metamodeling vs Metaprogramming MDD and WEB REST Metamodeling Active Annotations Conclusions Web Applications – Horizontal “Platforms” 7 Endpoints GWT: Java Javascript Graph Database e.g. Neo4J Servlet: JavaRuby JavascriptPython PHP Document Database e.g. MongoDB Cloud Stoage e.g. from Google SQL Database e.g. MySQL Hypertext Transfer Protocol (HTTP) JavascriptJava e.g. on Android Objective-C e.g. on iOS Dart
  • 8. ECMFA 2016: Metamodeling vs Metaprogramming MDD and WEB REST Metamodeling Active Annotations Conclusions Web Applications – Vertical “Platforms” 8 Endpoints GWT: Java Javascript Graph Database e.g. Neo4J Servlet: JavaRuby JavascriptPython PHP Document Database e.g. MongoDB Cloud Stoage e.g. from Google SQL Database e.g. MySQL Hypertext Transfer Protocol (HTTP) JavascriptJava e.g. on Android Objective-C e.g. on iOS Dart object.name = “John” json.put(“name”, “John”); bean.setName(“John”); entity.set(“name”,“John”); { name : “John” }
  • 9. ECMFA 2016: Metamodeling vs Metaprogramming Introduction REST Metamodeling Active Annotations Conclusions Representational State Transfer (REST) ■ Set of principles for distributed architectures by Roy Fielding ■ Most importantly: stateless server ■ Allows robust, scalable, easy to build and easy to maintain server ■ In practice almost always synonymous with web- services based on HTTP and JSON ■ Examples: Facebook, Twitter, Google+, Youtube, ... 9
  • 10. CLIENT 10 GET api.twitter.com/1.1/ statuses/user_timeline.json? screen_name=”mscheidgen” GET api.twitter.com/1.1/ statuses/user_timeline.json? screen_name=”mscheidgen”& max_id=”37..3” [ { id : 123336 text : “Som favorits : 2 user : { screen_n name : “M follower : }, ... }, ... { id : 364625 text : “Che } ] SERVER 200 OK [ { id : 1233364542, text : “Going to ECMFA; #STAF”, favorits : 21, retweets = 3, user : { screen_name : “mscheidgen”, name : “Markus Scheidgen”, follower : 1021, ... }, ... }, ... { id : 374256453 text : “Check out the new ...”, ... } ] reprsentational state transfer
  • 11. ECMFA 2016: Metamodeling vs Metaprogramming Introduction REST Metamodeling Active Annotations Conclusions 11 REST – How it works ■ Identify resources via URLs: host, path, and parameters ■ CRUD methods, i.e. HTTP’s PUT, GET, POST, DELETE ■ Resource contents is represented platform independently as JSON (or XML) ■ HATEOAS: ideally hyperlinks in resources connect all resources of one service
  • 12. ECMFA 2016: Metamodeling vs Metaprogramming Introduction REST Metamodeling Active Annotations Conclusions REST – Metrics and Flaws + HTTP and JSON are platform independent, libraries for most systems and programming languages exist - HTTP and JSON represent the smallest common denominator for most systems and programming languages - Loads of platform specific boilerplate code to process HTTP and JSON - No static types for URL and JSON data, no static safety 12
  • 13. ECMFA 2016: Metamodeling vs Metaprogramming Introduction REST Metamodeling Active Annotations Conclusions REST – Client Libraries 13 val request = HTTP.get("api.twitter.com/1.1/"statuses/user_timeline.json") request.queryString("screen_name", "mscheidgen") val str = request.asString() val jsonNode = JSON.parse(str) val jsonArray = jsonNode.asArray() for (i:0..<jsonArray.length) { val jsonItem = jsonArray.get(i); println(jsonItem.get("text")) } val result = twitter.statuses.userTimeline. userId("mscheidgen").xResult() for (item:result) { println(item.text) } exists? right type? is it an array? exists/right type? save
  • 14. ECMFA 2016: Metamodeling vs Metaprogramming Introduction REST Metamodeling Active Annotations Conclusions REST – Client Libraries ■ language specific, uses language features, i.e. type safety ■ turns HTTP request/response RPCs into regular method calls ■ comprises ■ a method for each API function ■ a wrapper type for each API resource type ■ Client libraries consist of very canonical, schematic boilerplate code. They are dull, tedious, and error prone to make. 14
  • 15. ECMFA 2016: Metamodeling vs Metaprogramming Introduction REST Metamodeling Active Annotations Conclusions Code the desired platform code, e.g. a REST client library Code the desired platform code, e.g. a REST client library Code-Generator a tool that processes a metamodel instance to generates code Code-Generator a tool that processes a metamodel instance to generates code Platform/ Language Platform/ Language Metamodeling 15 Metamodel defines language constructs, e.g. constructs to define REST request and resource types Model uses the given language constructs, e.g. to describe a REST API Code-Generator a tool that processes a metamodel instance to generates code Code the desired platform code, e.g. a REST client library Metametamodel the metamodeling language Code-Generator Language Platform/ Language
  • 16. ECMFA 2016: Metamodeling vs Metaprogramming Introduction REST Metamodeling Active Annotations Conclusions A Metamodel for REST APIs 16 method:Methods path:EString Request separator:EString Parameter PrimitiveDataType ComplexDataType Response Field GET POST PUT DELETE «enum» Methods type 1 response 1 {subsets features} pathPattern:EString PathParameter baseURL:EString REST-API features 0..* parameters 0..* {subsets features} Class array:EBoolean Feature DataType name:EString NamedElement 0..* parameters {redefines features} 0..* dataTypes 0..* requests QueryParameter BodyParameter get request Timeline for “statuses/user_timeline.json” returns array of Status { query max_id : String query screen_name : String } datatype Status { id : String text : String favorits : Integer retweets : Integer user : User } datatype User { screen_name : String name : String ... }
  • 17. ECMFA 2016: Metamodeling vs Metaprogramming Introduction REST Metamodeling Active Annotations Conclusions xTend 17 @request(path=“statuses/user_timeline.json”, response=@Response(type=Status, isArray=true)) class Timeline { String max_id String screen_name } @JSON class Status { String id String text int favorits int retweets User user } @JSON class User { String screen_name String name ... } get request Timeline for “statuses/user_timeline.json” returns array of Status { query max_id : String query screen_name : String } datatype Status { id : String text : String favorits : Integer retweets : Integer user : User } datatype User { screen_name : String name : String ... }
  • 18. ECMFA 2016: Metamodeling vs Metaprogramming Introduction REST Metamodeling Active Annotations Conclusions Metaprogramming xTend – Active Annotations 18 @Request(path="statuses/user_timeline.json", response=@Response(type=Status, isArray=true)) class Timeline { String max_id String screen_name } public class Timeline extends AbstractRequest<List<Status>> { @Override public List<Status> xResult() { JSONArray jsonArray = xResponse().getJSONArray(""); List<Status> result = new ArrayList<Status>(); for (int i = 0; i < jsonArray.length(); i++) { result.add(new Status(jsonArray.getJSONObject(i))); } return Collections.unmodifiableList(result); } ... xTend compiler + RequestClassProcessor implements RegisterGlobalsParticipant TransformationParticipant CodeGenerationParticipant ValidationParticipant
  • 19. ECMFA 2016: Metamodeling vs Metaprogramming Introduction REST Metamodeling Active Annotations Conclusions Active Annotations – Simple Examples 19 @AddConstructor class Customer { private val String id @Accessors(PUBLIC_GETTER, PROTECTED_SETTER) private String name } public class Customer { private final String id; private String name; public Customer(final String id) { super(); this.id = id; } public String getName() { return this.name; } protected void setName(final String name) { this.name = name; } }
  • 20. ECMFA 2016: Metamodeling vs Metaprogramming Introduction REST Metamodeling Active Annotations Conclusions Metamodeling vs Metaprogramming 20 xTend Language xTend Code e.g. uses annotations to describe REST request and resource types xTend Compiler Code the desired Java code, e.g. a REST client library Active Annotations Class Processors Code the desired platform code, e.g. Code the desired platform code, e.g. Code-GeneratorCode-Generator Metamodel Model Code-Generator Code the desired platform code, e.g. a REST client library
  • 21. ECMFA 2016: Metamodeling vs Metaprogramming Introduction REST Metamodeling Active Annotations Conclusions Beyond REST – Active Annotation and Web 21 Endpoints GWT: Java Javascript Cloud Storage e.g. from Google HTTP @GWTJavaScriptObject @JSONObject @JavaBean @CloudStorageEntity class User { String screen_name String name ... } object.name = “John” json.put(“name”, “John”); bean.setName(“John”); entity.set(“name”,“John”); { name : “John” }
  • 22. ECMFA 2016: Metamodeling vs Metaprogramming Introduction REST Metamodeling Active Annotations Conclusions Beyond REST – Active Annotation and Web 22 class Statuses { @com.google.endpoints.ApiMethod( name=“statuses/user_timeline.json”) @RequestFromEndpoints @ApiMethodMockup List<StatusBean> getTimeline( String screenName, String maxId) { ... } } @Request(path=“statuses/user_timeline.json”, response=@Response(type=Status, isArray=true)) class Timeline { String max_id String screen_name } REST Client Library Request Code Server CodeMockup Skeleton a bare bone implementa- tion for tests HTTP
  • 23. ECMFA 2016: Metamodeling vs Metaprogramming Introduction REST Metamodeling Active Annotations Conclusions Conclusions ■ Model-driven can be used for Web application development, especially for REST APIs ■ Active annotations can be used like stereotype to extend an existing programming language ■ Active annotation are an internal DSL alternative to custom code-generation 23
  • 24. ECMFA 2016: Metamodeling vs Metaprogramming Introduction REST Metamodeling Active Annotations Conclusions Questions 24 xTend Language xTend Code e.g. uses annotations to describe REST request and resource types xTend Compiler Code the desired Java code, e.g. a REST client library Active Annotations Class Processors Code the desired platform code, e.g. Code the desired platform code, e.g. Code-GeneratorCode-Generator Metamodel Model Code-Generator Code the desired platform code, e.g. a REST client library