Apache Sling A REST-based Web Application Framework Carsten Ziegeler cziegeler@apache.org ApacheCon NA 2014



Similar documents
Creating a REST API for Cloud services using Apache Felix and Sling Carsten Ziegeler and David Bosschaert

Server-side OSGi with Apache Sling. Felix Meschberger Day Management AG 124

Effective Web Application Development with Apache Sling. Robert Munteanu ), Adobe Systems Romania

NextRow - AEM Training Program Course Catalog

APACHE SLING & FRIENDS TECH MEETUP BERLIN, SEPTEMBER APACHE SLING & SCALA Jochen Fliedner

RESTful web applications with Apache Sling

Developer s Guide. How to Develop a Communiqué Digital Asset Management Solution

Continuous Delivery of Apache Sling Applications

CQCON 2013: five Sling features you should know

Apache Karaf in real life ApacheCon NA 2014

FUSE-ESB4 An open-source OSGi based platform for EAI and SOA

GlassFish v3. Building an ex tensible modular Java EE application server. Jerome Dochez and Ludovic Champenois Sun Microsystems, Inc.

IBM WebSphere Server Administration

Apache Sentry. Prasad Mujumdar

Configuring CQ Security

Introducing Apache Pivot. Greg Brown, Todd Volkert 6/10/2010

WebSphere Server Administration Course

Building a Modular Server Platform with OSGi. Dileepa Jayakody Software Engineer SSWSO2 Inc.

Communiqué 4. Standardized Global Content Management. Designed for World s Leading Enterprises. Industry Leading Products & Platform

Nuxeo, an open source platform for content-centric business applications. Stéfane Fermigier, Nuxeo Laurent Doguin, Nuxeo

MicroStrategy Course Catalog

Collaborative Open Market to Place Objects at your Service

Portal Factory CMIS Connector Module documentation

Learning GlassFish for Tomcat Users

Introducing the Adobe Digital Enterprise Platform

Architecture Guide Jahia EE v6.1

Digital Asset Management Beyond CMIS

NetBeans IDE Field Guide

The end. Carl Nettelblad

Building native mobile apps for Digital Factory

Content Management Systems: Drupal Vs Jahia

San Jose State University

Course Description. Course Audience. Course Outline. Course Page - Page 1 of 5

Data Modeling for Big Data

Flattening Enterprise Knowledge

IKAN ALM Architecture. Closing the Gap Enterprise-wide Application Lifecycle Management

HP Systinet. Software Version: Windows and Linux Operating Systems. Concepts Guide

Software Architecture Document

D5.4.4 Integrated SemaGrow Stack API components

Apache Jakarta Tomcat

Operations and Monitoring with Spring

Web Application Development

enterprise^ IBM WebSphere Application Server v7.0 Security "publishing Secure your WebSphere applications with Java EE and JAAS security standards

Spring Security 3. rpafktl Pen source. intruders with this easy to follow practical guide. Secure your web applications against malicious

Decoding the Big Data Deluge a Virtual Approach. Dan Luongo, Global Lead, Field Solution Engineering Data Virtualization Business Unit, Cisco

Cross-domain Identity Management System for Cloud Environment

Enterprise Service Bus

Alfresco. Wiley Publishing, Inc. PROFESSIONAL. PRACTICAL SOLUTIONS FOR ENTERPRISE. John Newton CONTENT MANAGEMENT. Michael Farman Michael G.

Business Process Management

Java EE Web Development Course Program

Structured Content: the Key to Agile. Web Experience Management. Introduction

MongoDB Developer and Administrator Certification Course Agenda

Open For Business in a Nutshell

JBoss Data Services. Enabling Data as a Service with. Gnanaguru Sattanathan Twitter:@gnanagurus Website: bushorn.com

Building Java Servlets with Oracle JDeveloper

Eclipse Open Healthcare Framework

Converting Java EE Applications into OSGi Applications

Core Java+ J2EE+Struts+Hibernate+Spring

Combining SAWSDL, OWL DL and UDDI for Semantically Enhanced Web Service Discovery

Customer Bank Account Management System Technical Specification Document

JBoss Portlet Container. User Guide. Release 2.0

Windows Azure Data Services (basics) 55093A; 3 Days

Cloud Powered Mobile Apps with Azure

Portals, Portlets & Liferay Platform

Developing modular Java applications

Accessing Data with ADOBE FLEX 4.6

Querying MongoDB without programming using FUNQL

Client-Server Architecture & J2EE Platform Technologies Overview Ahmed K. Ezzat

How to Build an E-Commerce Application using J2EE. Carol McDonald Code Camp Engineer

Java Application Developer Certificate Program Competencies

WebSphere Training Outline

Onegini Token server / Web API Platform

<Insert Picture Here> GlassFish v3 - A Taste of a Next Generation Application Server

Template Development Guide Jahia EE v6.1

Adobe Training Services Course Catalog

DataDirect XQuery Technical Overview

PowerTier Web Development Tools 4

EMC Documentum Connector for Microsoft SharePoint

S3 Monitor Design and Implementation Plans

MathCloud: From Software Toolkit to Cloud Platform for Building Computing Services

JEE Web Applications Jeff Zhuk

Glassbox: Open Source and Automated Application Troubleshooting. Ron Bodkin Glassbox Project Leader

BMC Remedy Action Request System 7.0 Configuring

Developing a Web Server Platform with SAPI Support for AJAX RPC using JSON

Terms and Definitions for CMS Administrators, Architects, and Developers

Java Servlet 3.0. Rajiv Mordani Spec Lead

Adobe ColdFusion 11 Enterprise Edition

MarkLogic Server. Java Application Developer s Guide. MarkLogic 8 February, Copyright 2015 MarkLogic Corporation. All rights reserved.

Agile Best Practices and Patterns for Success on an Agile Software development project.

Jackalope JCR & PHP. OpenExpo Herbst 2009, Winterthur, 23. September Tobias Ebnöther & Christian Stocker

GlassFish. Developing an Application Server in Open Source

Servlet 3.0. Alexis Moussine-Pouchkine. mercredi 13 avril 2011

Cloud3DView: Gamifying Data Center Management

An Approach to Implement Map Reduce with NoSQL Databases

Copyright Pivotal Software Inc, of 10

Eclipse 4 RCP application Development COURSE OUTLINE

Transcription:

Apache Sling A REST-based Web Application Framework Carsten Ziegeler cziegeler@apache.org ApacheCon NA 2014

About cziegeler@apache.org @cziegeler RnD Team at Adobe Research Switzerland Member of the Apache Software Foundation Apache Felix and Apache Sling (PMC and committer) And other Apache projects OSGi Core Platform and Enterprise Expert Groups Member of the OSGi Board Book / article author, technical reviewer, conference speaker 2

Web Challenges Publish and process huge amount of information Highly dynamic Different types Different output formats Collaboration and integration Fast changing requirements Rapid prototyping and development Dynamic, extensible but maintainable 3

Web Challenges Entering Apache Sling Publish and process huge amount of information Highly dynamic Different types Different output formats Collaboration and integration Fast changing requirements Rapid prototyping and development Dynamic, extensible but maintainable JCR REST / ROA Scripting OSGI 4

Apache Sling The Fun is Back Web framework Java Content Repository (JCR) ROA / REST Scripting Inside OSGi Apache Open Source top level project http://sling.apache.org Driving force behind several OSGi related projects at Apache 5

Key General Takeaways Leveraging REST Embracing OSG Hidden gems in Apache projects 6

Apache Jackrabbit - A Java Content Repository 7

Motivation for JCR Tried and trusted NoSQL solution Standard Java API First spec released in May 2005 Various implementations, products, and solutions Open Source implementation since 2006 (Apache Jackrabbit) Think about your data use cases / problems JCR might help! 8

Consider JCR Data structure Supporting the web ACID Security Additional features 9

The Structure of Data A data storage should be flexible and Allow to model app data in the right way Optimal way of dealing with the data in the app 10

The Structure of Data A data storage should be flexible and Allow to model data in the right way What is the right way? Tables? Key-Value-Pairs? Schema based? Semi structured or even unstructured? Flat, hierarchical or graph? 11

The Structure of Data The right way depends on the application: Tables Key-Value-Pairs Schema based Semi structured and unstructured Flat, hierarchical, and graph An app might have more than one right way But: A lot of data can be modeled in a hierarchy 12

Sample: Product Catalog Books DVDs English English Fiction IT SF Douglas Adams Databases 2001 2010 A Hitch.. Apache Jackrabbit 13

Java Content Repository Hierarchical content Nodes with properties (Table is a special tree) Structured Nodetypes with typed properties And/or semi structured and unstructured Fine and coarse-grained Single repository for all content! 14

Sample: Product Catalog Databases Apache Jackrabbit title authors ISBN cover 15

Sample: Product Catalog Databases Apache Jackrabbit title authors ISBN Defined by node type cover 16

Sample: Product Catalog Databases Apache Jackrabbit title authors ISBN cover User Images Defined by node type img1 img2 17

Authentication and Access Control Apache Jackrabbit supports JAAS Custom login modules possible Deny / Allow of privileges on a node Like read, write, add, delete Inheritance from parent Tree allows structuring based on access rights Access control is done in the data tier! 18

Sample Content Structure with ACLs johndoe janedoe public private public private Basel Photo Amsterdam Photo Wedding 1997 Read for everyone, write for owner Write for owner Photo Photo 19

JSR 170 / JSR 283: Content Repository for JavaTM technology API (Java) Standard Version 1.0 and 2.0 Supported by many vendors Used by many products and projects Several open source solutions Data model and features Query and observation 20

Apache Jackrabbit 21 JSR 170/283 reference implementation Apache TLP since 2006 Vital community New implementation: OAK (!) http://jackrabbit.apache.org/ 21

ROA and REST 22

Data and the Web? A website is hierarchical by nature Web applications provide data in different ways HTML JSON Provide your data in a RESTful way http:// /products/books/english/it/databases/apachejackrabbit.(html json) Avoid mapping/conversion http:// /products.jsp?id=5643564 23

Resource Oriented Architecture I Every piece of information is a resource News entry, book, book title, book cover image Descriptive URI Stateless web architecture (REST) Request contains all relevant information Targets the resource Leverage HTTP GET for rendering, POST/PUT/DELETE for operations 24

Resource Oriented Architecture II JCR and Apache Jackrabbit are a perfect match for the web Hierarchical From a single piece of information to binaries Elegant way to bring data to the web Apache Sling is (the one) web framework 25

Sample Application: Slingshot Digital Asset Management Hierarchical storage of pictures Upload Tagging Searching Automatic thumbnail generation Sample application from Apache Sling Poor man's flickr... 26

Slingshot Content Structure Travel Family Europe Wedding Amsterdam Basel 1997 2007 City Photo Photo Photo Photo 27

Facts About Slingshot Java web application Uses Apache Sling as web framework Content repository managed by Apache Jackrabbit Interaction through Sling s Resource API 28

REST with Apache Sling Default behavior for GET Creating/Updating content through POST Default behavior Additional operations/methods Resource-first request processing! 29

Resource Tree / Travel misc Europe images workflows http://localhost/travel/europe Resource: /Travel/Europe 30

Resource Apache Sling s abstraction of the thing addressed by the request URI Usually mapped to a JCR node File system, bundle, Cassandra, MongoDB, database.. Attributes of resources Path in the resource tree Resource type Metadata, e.g. last modification date 31

Resource-first Request Processing URI Decomposition Resource and representation /Travel/Europe/Basel.print.a4.html Resource Path Selectors Extension Content retrieved from resource tree Rendering based on resource type, selectors and extension 32

Basic Request Processing Steps Resolve the resource (using URI) Decomposition Resolve rendering script Source: resource type, selectors and extension Scripts wrapped by generic servlet Create rendering chain Configurable (servlet) filters Rendering servlet Invoke rendering chain 33

Resource Resolver I Tasks: Finding resources Getting resources Querying resources Not Thread Safe! Includes all objects fetched via resolver 34

Resource Resolver II Central gateway for resource handling Abstracts path resolution Abstracts access to the persistence layer(s) Configurable Mappings (Multi site mgmt, beautify paths) 35

Resource Tree / Travel misc Europe images workflows 36

Mounting Resource Providers / Travel misc Europe images workflows Resource Provider [DB] Resource Provider [JCR] Resource Provider [File] Resource Provider [Mongo] 37

Scripting 38

Scripting Inside It s your choice JSP, servlet, ESP, Scala javax.script own script handlers Scripts stored in OSGi bundles or the resource tree Scripts are searched at configured locations Default servlets JSON, XML Error Handling 39

Script Resolving I Path to script is build from Configured search paths ( /apps, /libs ) Resource type converted to path (slingshot/album) Selector string (print/a4) Request method & extension GET à Extension (html) Else -> Method ( POST, PUT, DELETE ) 40

Script Resolving Example URI: /Travel/Europe/Basel.print.a4.html Resource: /Travel/Europe/Basel Resource Type: slingshot:album Script for GET: /apps/slingshot/album/print/a4/html.* Script for POST: /libs/slingshot/album/print/a4/post.* 41

Script Resolving II Scripts are searched by best matching /apps/slingshot/album/print/a4/html.* /libs/slingshot/album/print/a4/html.* /apps/slingshot/album/html.* /libs/slingshot/album/html.* Resource has a type and a super type Script inheritance Default script (JSON...) 42

Sample JSP Script <%@page import="org.apache.sling.api.resource.resource, org.apache.sling.api.resource.valuemap" %><% %><%@taglib prefix="sling" uri="http://sling.apache.org/taglibs/sling/1.0" %><% %><sling:defineobjects/><% final ValueMap attributes = resource.getvaluemap(); final String albumname = attributes.get( title,resource.getname()); %><html> <head> <title>album <%= albumname %></title> </head> <body> <h2>contained Albums</h2> <% for ( final Resource current : resource.getchildren() ) { if ( current.isresourcetype(constants.resourcetype_album) ) { %><sling:include resource="<%= current %> /><% } } %> 43

Resource-first Request Processing ROA URI decomposition Resource resolving Script resolving Recursion Flexible script search algorithm 44

OSGi 45

Runtime Requirements Modularization Modularity is key Manage growing complexity Support (dynamic) extensibility Lifecycle management Configuration management Modules, services Different distributions/feature sets Dynamic system changes 46

OSGi in 5..ehm..1 Minute Specification of a framework Module concept (bundles) with lifecycle Simple but powerful component model Lifecycle management Publish/Find/Bind service registration Dynamic! Uses the concept of bundles 47

An OSGi Bundle Leverages the Java packaging mechanism: JAR files Contains Java classes and resources Additional meta-data Implicit dependencies to other bundles Package imports/exports Semantic versioning of API 48

Services OSGi offers an API to register services Service is registered by its interface name(s) Implementation is bundle private Several components for same service possible (from different bundles) Bundles can find and use services By interface names With additional filters 49

The OSGi Core Minimal but sufficient API for services Minimal overhead: Good for simple bundles No support for component management No support for configuration management Requires sometimes a lot of Java coding Additional (optional) OSGi extensions Declarative Service Specification Configuration Admin Service Specification 50

OSGi Declarative Service Specification Component model Component lifecycle management Publishing services Consuming services Default configuration Support for Config Admin 51

Config Admin and Metatype OSGi Config Admin Configuration Manager Persistence storage API to retrieve/update/remove configs Works with Declarative Services OSGi Metatype Service Description of bundle metadata Description of service configurations 52

Apache Felix Top-level project (March 2007) Healthy and diverse community OSGi R5 implementation Framework (frequent releases) Various interesting subprojects Tools Maven Plugins, Web Console 53

Contributions to Apache Felix Declarative service implementation Config admin implementation Metatype implementation Preferences implementation Web console (!) Maven SCR Plugin (!) and SCR tooling 54

Apache Sling Runtime Uses Apache Felix Runtime: Apache Sling Launchpad Two flavors Standalone Java Application Web application But Sling can be deployed in any OSGi framework! 55

Standalone Java Application One single executable JAR file Small Launcher Starts OSGi Framework (Apache Felix) Uses Jetty in an OSGi Bundle 56

Web Application Extends Standalone Application Replaces Main with a Servlet Uses a bridge to connect Sling to the Servlet Container 57

Facts About Apache Sling Sling API Uses resource abstraction Use JCR, MongoDB, Cassandra Highly modular and runtime configurable Everything is a OSGi bundle Deploy what you need! Commons Bundles (Threads, Scheduling ) OSGi Provisioning Cloud discovery Distributed eventing 58

Apache Sling The Fun is Back Web Framework Java Content Repository REST Scripting inside OSGi Apache Open Source project Check it out today! 59