The document discusses generating REST gateways for mobile applications. It introduces arconsis IT-Solutions GmbH, who develops agile and lean software using JBoss middleware and focuses on mobile solutions. The presentation aims to show how a domain-specific language approach can simplify creating RESTful mobile apps that integrate with enterprise systems in a simple, fast, and multi-platform way. It demonstrates using a DSL to generate a REST gateway on JBoss AS along with mobile app code and proxies to connect an example mobile app to a backend system.
1. Generated REST Gateways for
Mobile Applications
Wolfgang Frank
arconsis IT-Solutions GmbH
May, 3rd 2010
2. Who we are?
arconsis IT-Solutions GmbH from Karlsruhe,
Germany
agile- & lean software development
software architecture
solutions based on JBoss middleware
mobile solutions leveraging MDSD
RedHat/JBoss Advanced SI Partner
2 arconsis IT-Solutions GmbH
3. We want to …
Create data-driven mobile apps
Integrate with enterprise
This should be …
simple
fast
multi-platform (apps + integration)
3 arconsis IT-Solutions GmbH
4. How we do it …
„ The talk will show how the usage of a Domain
Specific Language (DSL) approach could help
to simplify the RESTful integration of mobile
applications (like on the iPhone or Android)
with JBoss Middleware. The talk will sketch
out the main concepts and provide a live demo
for a solution based on a fully open source
stack, composed of JBoss- as well as Eclipse
technology.“
4 arconsis IT-Solutions GmbH
5. How we do it …
„ The talk will show how the usage of a Domain
Specific Language (DSL) approach could help
to simplify the RESTful integration of mobile
applications (like on the iPhone or Android)
with JBoss Middleware. The talk will sketch
out the main concepts and provide a live demo
for a solution based on a fully open source
stack, composed of JBoss- as well as Eclipse
technology.“
5 arconsis IT-Solutions GmbH
6. Take a look
What do I mean with simple and fast?
A quick demo …
6 arconsis IT-Solutions GmbH
7. A Mobile Gateway architecture example
JBoss AS
iPhone Other Applications
(e.g. CRM, ERP, …)
Mobile JBoss ESB
Android REST Gateway Open Services
on JBoss AS (e.g. Google, Yahoo,
Amazon,…)
Blackberry
JBoss DS Internal Services
HornetQ (e.g. SOA,
Database)
Should be
easy to scale
out!
7 arconsis IT-Solutions GmbH
8. Where we’re heading …
Basics about MDSD +
Domain Specific Languages
RESTful services + JBoss RestEasy
The iPhonical project
Data-driven Apps
A Mobile Gateway architecture
Putting it all together (demo)
8 arconsis IT-Solutions GmbH
9. Basics about MDSD + Domain Specific Languages
9 arconsis IT-Solutions GmbH
10. MDSD benefits
Separation of technical • Automation with generation
aspects and business aspects • Reduced costs, raised productivity
Manage technological change • Improved software-quality
Concepts more stable than • Reduced maintenance costs
technology ==> safer invest • Better reusability
• Reduced development costs
No silver bullet! • Manage high complexity
• Reduced development costs,
Higher effort for spec independence from 3rd
Effort to write generator • Better communication IT & Biz
100% generation not always
feasible
10 arconsis IT-Solutions GmbH
11. Domain Specific Language
A DSL is a formal, processable language targeting at
a specific viewpoint or aspect of a software system
It’s semantics, flexibility and notation is designed in
order to support working with that viewpoint as good
as possible
""Open Source Eclipse Frameworks (EMP):
Xtext: Define grammar + create parser + editor
Xpand, Xtend: Template language for model transformation
11 arconsis IT-Solutions GmbH
12. REST over HTTP …
… is an architectural style that uses HTTP as protocol and URIs
as identification mechanism
… leverages proven web-technologies
.. helps loose coupling (uniform interface)
… achieves interoperability (HTTP, URIs, XML/JSON, HTML, …)
… has only one interface (dataformat needs to be known)
… is performant and scalable (nearly unlimited)
no session + caching highly distributable
12 arconsis IT-Solutions GmbH
REST = Representational State Transfer: Roy Fielding 2000
13. Basic principles of REST
All resources have a unique identifier
Usage of links and hypermedia
Standardized methods
Support different representations
Stateless communication
Wikipedia: „Unlike SOAP-based web services, there is no "official" standard
for RESTful web service. This is because REST is an architecture, unlike SOAP,
which is a protocol. Even though REST is not a standard, a RESTful implementation
such as the Web can use standards like HTTP, URL, XML, PNG, etc.“
13 arconsis IT-Solutions GmbH
14. Unique identifier for resources
Use URIs for all resources worth it (values + sets)
Examples:
http://example.com/customers/1234
http://example.com/orders/2008/10/776654
http://example.com/products
http://example.com/processes/salary-increase-234"
Careful: “It does not mean that every database key
" " " and entity should be exposed as a resource!”
14 arconsis IT-Solutions GmbH
15. Links and hypermedia
“Hypermedia as the engine of application state”
Example:
<order href=‘http://example.org/orders/4711’>
" "<amount>69</amount>
" "<product ref=‘http://example.org/products/0815’ />
" "<customer ref=‘http://example.org/customers/4711’ />
" "<product ref=‘http://example.org/products/0815’ />
" "<link rel= ‘cancel’ ref=‘./cancellations’ />
</order>
Links can span different systems
Control allowed workflow (e.g. cancellation currently allowed)
15 arconsis IT-Solutions GmbH
16. Standardized methods
Every resource supports the same interface
HTTP verbs
GET, PUT, POST, DELETE, HEAD and OPTIONS"
“Guaranteed” behaviour, defined in HTTP specification
Idempotent; safe; cacheable + repeatable
GET/PUT/DELETE (get, modify/create, remove)
Unsafe; can create a resource or can do anything
POST"
16 arconsis IT-Solutions GmbH
Idempotent = Free of side effects. “You can safely repeat the request anytime”
17. WebService + RPC vs. REST
Data types • Different approaches can
be mapped to each other!
Service Design
Operations Instances
"Every app understanding HTTP-protocol can use your application
" allows for generic clients (e.g. curl, wget, proxy-server,
" Google- or Yahoo services, MSN, ...)
17 arconsis IT-Solutions GmbH
18. Resources and representations
Content negotiation in HTTP:
""GET /customers/123 HTTP/1.1
"HOST: example.org
"Accept: application/vnd.mycompany.customer+xml"
Result could be company internal XML format
""GET /customers/123 HTTP/1.1
"HOST: example.org
"Accept: text/x-vcard"
Result could be customer address in vCard format
So many data formats and standards available to use
instead to re-invent!
18 arconsis IT-Solutions GmbH
19. Stateless communication "
“Stateless” does not mean no server-side state but:
“State” is kept in client or transformed in resource-state
on server-side
No transient, client-specific state for longer than one
request on server-side
E.g. “shopping cart” as resource save bookmark,
forward per email
Why?
Scalability
Coupling to clients (subsequent requests can be serverd by
different server nodes)
19 arconsis IT-Solutions GmbH
20. JSR-311 JAX-RS with JBoss RESTEasy
RESTful WebServices implementation for Java to be
included within Java EE 6
Fully certified JAX-RS implementation
Comes with jboss-eap-5.0 download!
20 arconsis IT-Solutions GmbH
21. JBoss RESTEasy
Portable to any app-server/Tomcat that JAXB marshalling into XML, JSON, Jackson,
runs on JDK 5 or higher Fastinfoset, and Atom as well as wrappers
for maps, arrays, lists, and sets of JAXB
Embeddedable server implementation for Objects.
junit testing
GZIP content-encoding. Automatic GZIP
Client framework that leverages JAX-RS compression/decompression suppport in
annotations so that you can write HTTP client and server frameworks
clients easily (JAX-RS only defines server
bindings) Asynchronous HTTP (Comet) abstractions
for JBoss Web, Tomcat 6, and Servlet 3.0
Client "Browser" cache. Supports HTTP 1.1
caching semantics including cache Asynchronous Job Service.
revalidation
Rich interceptor model.
Server in-memory cache. Local response
cache. Automatically handles ETag EJB, Seam, Guice, Spring, and Spring MVC
generation and cache revalidation integration
Rich set of providers for: XML, JSON,
YAML, Fastinfoset, Multipart, XOP, Atom,
etc.
21 arconsis IT-Solutions GmbH
23. iPhonical project
Model Driven Software Development for mobile devices
Extensible modular DSL
Tooling support / editor (Workbench)
Extensible + flexible generator
Open Source (incubation phase):
http://code.google.com/p/iphonical
Idea was to build a framework based on powerful + flexible Eclipse ecosystem
Leverage multi-platfrom support of Titanium Mobile Framework (Apache)
23 arconsis IT-Solutions GmbH
25. Data-driven mobile applications
Skype Typical usage scenario
Contacts
Present list of data
Twitter
Drill-down details
Facebook
LinkedIn Edit details
IPod Perform some action ...
....
25 arconsis IT-Solutions GmbH
26. A Mobile Gateway architecture example
iPhone JBoss AS
Other Applications
(e.g. CRM, ERP, …)
JRMI"
REST/JSON"
Hessian" FTP, RMI"
Android Mobile JBoss ESB
REST Gateway Open Services
on JBoss AS (e.g. Google, Yahoo,
REST/XML"
Amazon,…)
SOAP"
Blackberry REST/XML"
JBoss DS Internal Services
HornetQ (e.g. SOA,
JDBC, SOAP" Database)
REST Client REST Server
26 arconsis IT-Solutions GmbH
27. Putting it all together …
LIVE DEMO !
27 arconsis IT-Solutions GmbH
28. So what did we see?
We defined the domain model of the App
Hit Generate
Hit Simulate we got an ...
„out of the box“ CRUD App
Lead Company Contact
1 1 1 *
28 arconsis IT-Solutions GmbH
29. So what did we see?
We added the REST service definitions
Hit Generate
Hit Simulate we got an ...
„out of the box“ CRUD App
REST client proxies for the mobile device
“Out of the box” REST Gateway running on
JBoss5 AS using RESTEasy
29 arconsis IT-Solutions GmbH
30. So what did we see?
We changed the the controller.js to use the
generate REST client proxy
Hit Simulate we got an ...
„out of the box“ CRUD App
REST client proxies for the mobile device
“Out of the box” REST Gateway running on
JBoss5 AS using RESTEasy
Integrated data-driven remote mobile App
30 arconsis IT-Solutions GmbH
31. What next?
Could use it “as is” for rapid prototyping and scaffolding
Change or extend the generator and the grammar:
"
It’s open source!
Planned changes for this summer:
Concept to re-generate code for client (JS prototypes)
View aspects with UI controls for CUSTOM Apps
Integration with JBossESB DSL (see my last talk)
Cosmetic changes (e.g. Images support)
31 arconsis IT-Solutions GmbH
32. Q&A + contact …
Let us know what you think …
? c/o: Wolfgang Frank
wolfgang.frank@arconsis.com
32 arconsis IT-Solutions GmbH
33. More things to see …
http://rest-http.info"
http://developer.appcelerator.com/"
http://www.json.org"
http://www.jboss.org/resteasy"
http://www.jboss.org/jbossesb"
http://www.jboss.org/jbossas"
http://code.google.com/p/iphonical/"
http://www.arconsis.com ;-)"
33 arconsis IT-Solutions GmbH
34. BACKUP SLIDES
ups!
… Something went wrong so I will need these …
34 arconsis IT-Solutions GmbH