SlideShare a Scribd company logo
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

ExSchema
ExSchemaExSchema
ExSchema
jccastrejon
 
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
 
Icpc11c.ppt
Icpc11c.pptIcpc11c.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
Martin Pinzger
 
Icsme16.ppt
Icsme16.pptIcsme16.ppt
Opal Hermes - towards representative benchmarks
Opal  Hermes - towards representative benchmarksOpal  Hermes - towards representative benchmarks
Opal Hermes - towards representative benchmarks
MichaelEichberg1
 
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 Databases
Martí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 Experiments
Frank 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 Learning
Sung 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 applications
mahatmagandhiuniversity
 
Results of the FLOSSMetrics project
Results of the FLOSSMetrics projectResults of the FLOSSMetrics project
Results of the FLOSSMetrics project
Jesus M. Gonzalez-Barahona
 
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 12
Dev Chauhan
 
GenePattern: Ted Liefeld
GenePattern: Ted LiefeldGenePattern: Ted Liefeld
GenePattern: Ted Liefeld
niranabey
 
ontop: A tutorial
ontop: A tutorialontop: A tutorial
ontop: A tutorial
Mariano Rodriguez-Muro
 
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
Guohui 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 2
Geoffrey Fox
 
Ajax
AjaxAjax
Switch to Backend 2023
Switch to Backend 2023Switch 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
Timur Shemsedinov
 
RESTEasy
RESTEasyRESTEasy
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
David Gómez García
 
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
 
Ams adapters
Ams adaptersAms adapters
Ams adapters
Bruno Alló Bacarini
 
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
Rothamsted Research, UK
 
Ajax Lecture Notes
Ajax Lecture NotesAjax Lecture Notes
Ajax Lecture Notes
Santhiya Grace
 
Server Side Swift - AppBuilders 2017
Server Side Swift - AppBuilders 2017Server Side Swift - AppBuilders 2017
Server Side Swift - AppBuilders 2017
Jens Ravens
 
May 2010 - RestEasy
May 2010 - RestEasyMay 2010 - RestEasy
May 2010 - RestEasy
JBug 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 DWAPI
Device WebAPI Consortium
 
ASP.NET MVC - In the Wild
ASP.NET MVC - In the WildASP.NET MVC - In the Wild
ASP.NET MVC - In the Wild
Brian 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 apps
Otto Chrons
 
"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
 
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
Portland R User Group
 
Hypermedia APIs and HATEOAS
Hypermedia APIs and HATEOASHypermedia APIs and HATEOAS
Hypermedia APIs and HATEOAS
Vladimir Tsukur
 
Spring 4 Web App
Spring 4 Web AppSpring 4 Web App
Spring 4 Web App
Rossen Stoyanchev
 
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
Ali 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
 
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
 
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 ...
 
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" (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)
 
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
 
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

dbms calicut university B. sc Cs 4th sem.pdf
dbms  calicut university B. sc Cs 4th sem.pdfdbms  calicut university B. sc Cs 4th sem.pdf
dbms calicut university B. sc Cs 4th sem.pdf
Shinana2
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
Zilliz
 
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdfMonitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Tosin Akinosho
 
SAP S/4 HANA sourcing and procurement to Public cloud
SAP S/4 HANA sourcing and procurement to Public cloudSAP S/4 HANA sourcing and procurement to Public cloud
SAP S/4 HANA sourcing and procurement to Public cloud
maazsz111
 
JavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green MasterplanJavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green Masterplan
Miro Wengner
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
Jason Packer
 
Trusted Execution Environment for Decentralized Process Mining
Trusted Execution Environment for Decentralized Process MiningTrusted Execution Environment for Decentralized Process Mining
Trusted Execution Environment for Decentralized Process Mining
LucaBarbaro3
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc
 
leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...
leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...
leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...
alexjohnson7307
 
Generating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and MilvusGenerating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and Milvus
Zilliz
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
panagenda
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
panagenda
 
Fueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte WebinarFueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte Webinar
Zilliz
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
Tomaz Bratanic
 
Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |
AstuteBusiness
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
Ivanti
 
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Jeffrey Haguewood
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
Chart Kalyan
 
Digital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying AheadDigital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying Ahead
Wask
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
akankshawande
 

Recently uploaded (20)

dbms calicut university B. sc Cs 4th sem.pdf
dbms  calicut university B. sc Cs 4th sem.pdfdbms  calicut university B. sc Cs 4th sem.pdf
dbms calicut university B. sc Cs 4th sem.pdf
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
 
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdfMonitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdf
 
SAP S/4 HANA sourcing and procurement to Public cloud
SAP S/4 HANA sourcing and procurement to Public cloudSAP S/4 HANA sourcing and procurement to Public cloud
SAP S/4 HANA sourcing and procurement to Public cloud
 
JavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green MasterplanJavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green Masterplan
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
 
Trusted Execution Environment for Decentralized Process Mining
Trusted Execution Environment for Decentralized Process MiningTrusted Execution Environment for Decentralized Process Mining
Trusted Execution Environment for Decentralized Process Mining
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
 
leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...
leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...
leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...
 
Generating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and MilvusGenerating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and Milvus
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
 
Fueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte WebinarFueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte Webinar
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
 
Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
 
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
 
Digital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying AheadDigital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying Ahead
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
 

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