28
APACHE SLING & FRIENDS TECH MEETUP BERLIN, 23-25 SEPTEMBER 2013 “RESTful transactions” with Apache Sling Şenol Taş

Developing “RESTful transactions” with Apache Sling

Embed Size (px)

Citation preview

Page 1: Developing “RESTful transactions” with Apache Sling

APACHE SLING & FRIENDS TECH MEETUP BERLIN, 23-25 SEPTEMBER 2013

“RESTful transactions” with Apache Sling Şenol Taş

Page 2: Developing “RESTful transactions” with Apache Sling

About

adaptTo() 2013 2

§  My Name is Şenol Taş §  Senior Computer Scientist §  Adobe in Basel, Switzerland

@thelabertasch

Page 3: Developing “RESTful transactions” with Apache Sling

adaptTo() 2013 3

Why such a boring Topic?

Page 4: Developing “RESTful transactions” with Apache Sling

Because websites are…

adaptTo() 2013 4

§  No longer simple advertisement platforms

§  Not only “online Business cards” §  Not a “nice to have” medium §  Not a “Playground” §  …..

Page 5: Developing “RESTful transactions” with Apache Sling

Because websites are…

adaptTo() 2013 5

§  Serious business §  Make $$$ §  Complex §  MUST have §  “Real” Applications

Page 6: Developing “RESTful transactions” with Apache Sling

adaptTo() 2013 6

Your Website IS THE Application

Page 7: Developing “RESTful transactions” with Apache Sling

Let’s….

adaptTo() 2013 7

§  Find out “what is a transaction?” §  Quick reminder about REST §  How do this two concepts work

together?

Page 8: Developing “RESTful transactions” with Apache Sling

adaptTo() 2013 8

What are Transactions?

Page 9: Developing “RESTful transactions” with Apache Sling

What are Transactions?

adaptTo() 2013 9

Page 10: Developing “RESTful transactions” with Apache Sling

adaptTo() 2012 10

“An input message to a computer system that must be dealt with as a single unit of work”

Page 11: Developing “RESTful transactions” with Apache Sling

What are Transactions?

adaptTo() 2013 11

§  begin transaction §  debit checking account §  credit savings account §  update history log §  commit transaction

Page 12: Developing “RESTful transactions” with Apache Sling

What are Transactions?

adaptTo() 2013 12

§  Late 70s: Jim Gray defined the semantic of reliable transactions

§  Early 80s: Andreas Reuter and Theo Härder defined the acronym “ACID” in their paper “Principles of Transaction-Oriented Database Recovery”

Page 13: Developing “RESTful transactions” with Apache Sling

ACID

adaptTo() 2013 13

§  Atomicity §  Consistency §  Isolation §  Durability

Page 14: Developing “RESTful transactions” with Apache Sling

How do tools like hybernate help?

adaptTo() 2013 14

Page 15: Developing “RESTful transactions” with Apache Sling

adaptTo() 2013 15

What is REST?

Page 16: Developing “RESTful transactions” with Apache Sling

What is REST?

adaptTo() 2013 16

§  Representational State Transfer §  Stateless §  Client-server §  Cachable §  Scalable §  …..

Page 17: Developing “RESTful transactions” with Apache Sling

What is REST?

adaptTo() 2013 17

§  So? How does this work together with transactions?

Page 18: Developing “RESTful transactions” with Apache Sling

adaptTo() 2013 18

REST and transaction is a oxymoron

Page 19: Developing “RESTful transactions” with Apache Sling

REST and transactions

adaptTo() 2013 19

§  Atomicity §  Consistency §  Isolation §  Durability

Page 20: Developing “RESTful transactions” with Apache Sling

What are the challenges?

adaptTo() 2013 20

§  HTTP REQUEST – RESPONSE PATTERN

§  STATELESS §  …..?

Page 21: Developing “RESTful transactions” with Apache Sling

Change your mindset…

adaptTo() 2013 21

§  Not everything has to be done in one request

§  If you are using POST.jsp or similar in Sling, most likely something is wrong

§  Events and Observations are your friends

§  Use the full power of the Sling Default Post and GET Servlet

Page 22: Developing “RESTful transactions” with Apache Sling

Remember the cheat sheet from Lars?

adaptTo() 2013 22

Page 23: Developing “RESTful transactions” with Apache Sling

Example

adaptTo() 2013 23

§  Resource: /home/senol/profile

§  Begin transaction §  change interests §  Commit transaction

Page 24: Developing “RESTful transactions” with Apache Sling

Begin Transaction

adaptTo() 2013 24

§  Copy the node /home/senol/profile to /home/senol/transactions/profile/*

Page 25: Developing “RESTful transactions” with Apache Sling

Change interests

adaptTo() 2013 25

§  Update with regular post request

Page 26: Developing “RESTful transactions” with Apache Sling

Commit transaction

adaptTo() 2012 26

§  With observation or events

§  Directly

Page 27: Developing “RESTful transactions” with Apache Sling

Things of interest

adaptTo() 2012 27

§  Communicating with services layer §  Distributed transactions §  Nested transactions §  Locking…

§  Using Adobe CQ? §  Have a look at the Workflow Launcher!

Page 28: Developing “RESTful transactions” with Apache Sling

adaptTo() 2013 28

Thank you and have a RESTful Day!