Agile RESTful Web Development Michael Marth Michael Drig v e l - - PowerPoint PPT Presentation

agile restful web development
SMART_READER_LITE
LIVE PREVIEW

Agile RESTful Web Development Michael Marth Michael Drig v e l - - PowerPoint PPT Presentation

Agile RESTful Web Development Michael Marth Michael Drig v e l o p e r n i o r D e S e T e c h n o l o g y E v a n g e l i s t m i c h a e c o m l . m a r t h @ i g @ d a y . d a y .


slide-1
SLIDE 1

Michael Dürig

S e n i

  • r

D e v e l

  • p

e r m i c h a e l . d u e r i g @ d a y . c

  • m

Agile RESTful Web Development

Michael Marth

T e c h n

  • l
  • g

y E v a n g e l i s t m i c h a e l . m a r t h @ d a y . c

  • m
slide-2
SLIDE 2

Jugs - Agenda

REST in 15 minutes Meet Apache Sling demo & code

slide-3
SLIDE 3

What is REST? A API D Architectural Style C SOAP’s arch enemy B Technology

slide-4
SLIDE 4

REST: An Architectural Style

One of many Architectural Styles Architectural principles of the web, defined a posteriori Defined through architectural constraints

R

  • y

T . F i e l d i n g

Chief Scientist at Day Software

slide-5
SLIDE 5

Styles and implementation examples

peer to peer style

Napster The Web

REST style

the web is the only relevant implementation of REST

slide-6
SLIDE 6

REST ingredients

Resources Representations of resources Uniform interface Hypertext and links Stateless communication

roughly the constraints from Roy’ s thesis

slide-7
SLIDE 7

Resources

give all relevant things an ID

http:/ / example.com/cars/models/320

don’ t have to be pretty

Representations

http:/ / example.com/cars/models/320.html http:/ / example.com/cars/models/320.json http:/ / example.com/cars/models/320.xml http:/ / example.com/cars/models/320.jsp

slide-8
SLIDE 8

Uniform interface

GET retrieve information, possibly cached PUT Update or create with known ID POST Create or append sub-resource DELETE Logically remove

allows intermediaries to understand (caches, proxies)

slide-9
SLIDE 9

allows intermediaries to understand (caches, proxies)

GET retrieve information, possibly cached PUT Update or create with known ID POST Create or append sub-resource DELETE Logically remove

Uniform interface

check out the URL http:/ /www.youtube.com/watch? v=oHg5SJYRHA0

with method “WATCH”

slide-10
SLIDE 10

Hypertext

Link the “things” / the resources

<link rel="some-concept" ref="/some-uri">

How?

h a r d c

  • d

e d i n c l i e n t N O T h a r d c

  • d

e d i n c l i e n t

Why?

slide-11
SLIDE 11

A special browser for each web site? e.g. a Wikipedia browser that hardcodes http:/ / en.wikipedia.org/wiki/{concept}

wikipedia browser amazon browser jugs.ch browser blogs browser nzz browser admin.ch browser search.ch browser infoq browser facebook browser gmail browser

slide-12
SLIDE 12

A REST API must not define fixed resource names or hierarchies (an obvious coupling of client and server). Servers must have the freedom to control their

  • wn namespace.
slide-13
SLIDE 13

If you need this it’s (probably) not REST

slide-14
SLIDE 14

requests are self-contained

Stateless communication

state is kept on the client, no server-side application state

client server

GET / customer/1234/orders update software reboot POST /orders/123456789 <link rel=” ...” ref=” /orders/123456789”></link>

intermediaries scalability

slide-15
SLIDE 15

RPC-style modelling vs. REST-style modelling

+ getOrders() + submitOrder() + getOrderDetails() + getOrdersForCustomers() + updateOrder() + addOrderItem() + cancelOrder() OrderManagementService + getCustomers() + addCustomer() + getCustomerDetails() + updateCustomer() + deleteCustomer() CustomerManagementService GET PUT POST DELETE <<interface>> Resource GET - list all orders PUT - unused POST - add new order DELETE - unused /orders GET - get order details PUT - update order POST - add item DELETE - cancel order /orders/{id} GET - list all customers PUT - unused POST - add new customer DELETE - unused /customers GET - get customer details PUT - update customer POST - unused DELETE - delete customer /customers/{id} GET - get all orders for customer PUT - unused POST - add order DELETE - cancel all customer orders /customers/{id}/orders GET - unused PUT - unused POST - submit order DELETE - unused /orders/{id}/submit

m a n y

  • p

e r a t i

  • n

s f e w i n s t a n c e s few operations many instances

slide-16
SLIDE 16

Why again?

proven scalability proven to evolve proven cross-platform

The Web

Relevant for me?

slide-17
SLIDE 17

REST for the Enterprise?

slide-18
SLIDE 18

The Internet vs. The Enterprise

The other is a worldwide, publicly accessible series of interconnected computer networks that transmit data by packet switching using the standard Internet Protocol (IP). One is a gigantic, uncontrollable anarchy of heterogeneous systems with varying quality that evolve independently and constantly get connected in new and unexpected ways.

Stefan Tilkov - Pragmatic Introduction to REST

slide-19
SLIDE 19

Jugs - Agenda

REST in 15 minutes Meet Apache Sling demo & code

slide-20
SLIDE 20

What’s Sling?

“ Apache Sling is a RESTful web framework that uses a Java Content Repository to store and manage content.”

in Apache incubator

just graduated

slide-21
SLIDE 21

What’s JCR?

“The API should be a standard, implementation independent, way to access content bi-directionally on a granular level within a

content repository.”

?

slide-22
SLIDE 22

Best of both worlds.

d a t a base file sys tem

con tent r e p

  • sit
  • ry

read write

h i e r

  • a

r c h i e s

streams

locking

a c c e s s c

  • n

t r

  • l

i n t e g r i t y s t r u c t u r e

t x

query

un-structured

“ full-text” sort

  • rder

versioning

  • bser
  • vation

multi- value

slide-23
SLIDE 23

“Data First!”

JCR supports “structure first” as well.

(but that’ s missing the point)

aka “ schemaless”

slide-24
SLIDE 24

Known compliant Repositories

Apache Jackrabbit Oracle XML DB Exo ECMS Platform Microsoft Sharepoint OpenText Livelink Day CRX IBM FileNet P8 Xythos Repository Alfresco ECM Vignette V7 Interwoven Repository IBM CM EMC Documentum

How many RDBMS vendors do you need?

+hundreds of TCKs registered

* * * *

* using third party connector

*

slide-25
SLIDE 25

Sourcemix Sourcemix Percussion Rhythmix Lutece Portal QuickWCM WCMS Jahia Framework Hippo CMS InfoQ Online Community Nuxeo ECM Sakai E-learning TYPO3 v5.0 WCM GX WebManager Exo ECMS Platform Liferay Enterprise Portal Artifactory Maven Proxy IBM FileNet WebSiteManager Apache James medic-2-medic mapofmedicine Day Communiqué WCMS Apache Tapestry Day Communique Collab QSLabs Compliance Apache Cocoon Alfresco ECMS Apache Sling Mindquarry Collaboration Day Communique DAM magnolia WCMS JBoss Portal

Some known JCR Applications

Sun OpenPortal Interface 21 Spring Framework Fast Enterprise Search Oracle Portal BEA Portal

slide-26
SLIDE 26

Sourcemix Sourcemix Percussion Rhythmix Lutece Portal QuickWCM WCMS Jahia Framework Hippo CMS InfoQ Online Community Nuxeo ECM Sakai E-learning TYPO3 v5.0 WCM GX WebManager Exo ECMS Platform Liferay Enterprise Portal Artifactory Maven Proxy IBM FileNet WebSiteManager Apache James medic-2-medic mapofmedicine Day Communiqué WCMS Apache Tapestry Day Communique Collab QSLabs Compliance Apache Cocoon Alfresco ECMS Apache Sling Mindquarry Collaboration Day Communique DAM magnolia WCMS JBoss Portal

Some known JCR Applications

Sun OpenPortal Interface 21 Spring Framework Fast Enterprise Search Oracle Portal BEA Portal

slide-27
SLIDE 27

JCR - Weatherforecast

2009 2010

2011 -12°

slide-28
SLIDE 28

JCR 2.0

http://www.day.com/jsr283

slide-29
SLIDE 29

Repository

A node is a resource

GET /cars/audi/s4.txt

User

  • agent
slide-30
SLIDE 30

POST /cars/audi/s48

Repository

A node is a resource

User

  • agent

Y

  • ur content

is your web server

write

slide-31
SLIDE 31

Repository

Web apps and Sling scripting

/cars/audi/s4.details.html

User

  • agent
slide-32
SLIDE 32

Repository

Web apps and Sling scripting

/cars/audi/s4.details.html

User

  • agent

1 file needed Convention over configuration

slide-33
SLIDE 33

Repository

Web apps and Sling scripting

/cars/audi/s4.details.html

User

  • agent

.esp

.erb .scala

slide-34
SLIDE 34

/product.jsp?id=/audi/s4

Web apps and Sling scripting

/cars/audi/s4.details.html

URLs do matter!

vs.

Addressing the “ script” Passing in “ this” (the resource)

slide-35
SLIDE 35

Bonus

slide-36
SLIDE 36

Sling

Apache Felix OSGi container

Sling is OSGi-based

Sling Sling my bundles my scripts extensible JCR my bundles

( n

  • t

j u s t “ e n a b l e d ” )

slide-37
SLIDE 37

Apache Felix OSGi container

Sling is OSGi-based

Sling Sling my bundles my scripts modular extensible JCR my bundles hot deploy Sling

( n

  • t

j u s t “ e n a b l e d ” )

slide-38
SLIDE 38

SEE

slide-39
SLIDE 39

DEMO