Apache Sling

14
Apache Sling Andreas Hartmann CTO, BeCompany GmbH

Transcript of Apache Sling

Page 1: Apache Sling

Apache SlingAndreas Hartmann

CTO, BeCompany GmbH

Page 2: Apache Sling

REST

REpresentational State Transfer

Roy T. Fielding‘s dissertation

Not a technology/standard/software

Set of architectural constraints

Optimized for common use-cases of the WWW (based on experience)

Page 3: Apache Sling

REST in the WWW

HTML docs (representations) = states

Hyperlinks + forms = transitions

/products

/products/lenya

GET /products/lenya

/products/cocoon

POST /products/cocoontitle=Apache%20Cocoon

Page 4: Apache Sling

Concerns

Simplicity

Visibility

Reusability

Scalability

Reliability

Extensibility

Cacheability

Efficiency

Page 5: Apache Sling

REST Constraints

Client-Server

Layered transport (firewalls, proxies, …)

Caching

Stateless server

Uniform interface

Code on demand

Page 6: Apache Sling

REST Data Elements

Resource (anything that can be addressed, independent of a particular point in time)

URIs to identify resources

Resource metadata: source link, alternates, …

Representation = data (byte sequence)

Repr. metadata: media type, last modified, …

Page 7: Apache Sling

Uniform Interface

Representation of resources in one of an emerging set of standard formats

Uniform resource identification mechanism

Messages are self-descriptive:representation/resource/control metadata

Intermediaries can transform the messages,e.g. compressing for optimized transport

Page 8: Apache Sling

Common Violations

Indirect application state:Addressing and caching issues

Cookies (server-side state)Frames

Incremental processing issuesEmbedding metadata in HTML head<img> without @width, @heightdynamically sized table columns

Page 9: Apache Sling

Apache Sling

Web application framework

JCR for content storage

Process HTTP requests in a RESTful way

Scripts (JSR-233) or Servlets for processing

OSGi for deploying modules at runtime

Page 10: Apache Sling

Application Scenarios

Everything (well, „everything is content“)

WCM, DAM, Wiki, Blog, ERP, …

Especially for content-oriented applications

Page 11: Apache Sling

Sling encourages REST

Thinking in resources (mapped to JCR nodes)

Representation selection (HTML, Atom, PDF, …) via part of URI

Uniform interface for content handling:GET + POST + PUT + DELETE

Page 12: Apache Sling

UnRESTful Addressing

/product ?id=13423.jsp

URI doesn't addressthe resource

Not part of URI:not cacheable

Page 13: Apache Sling

Request Processing in Sling

/news/today .atom

Resource

sling:resourceType

Servlet / Script

feed

/apps/feed/atom.esp

/news/today ?title=Today

Resource

sling:resourceType

Servlet / Script

feed

/apps/feed/PUT.esp

GET PUT

Page 14: Apache Sling

Sling Demo

Start application

Connect via WebDAV

Connect via Eclipse Plug-In

Dojo Tree Example