server-side osgi with apache sling (jazoon 2010)

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

Upload: felix-meschberger

Post on 29-Jan-2018

4.603 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Server-side OSGi with Apache Sling (Jazoon 2010)

Server-side OSGi with Apache Sling

Felix Meschberger

Day Management AG

124

Page 2: Server-side OSGi with Apache Sling (Jazoon 2010)

2

About Felix Meschberger

> Senior Developer, Day Management AG

> [email protected]

> http://blog.meschberger.ch

> VP Apache Sling

> Apache Felix

> Apache Jackrabbit

Page 3: Server-side OSGi with Apache Sling (Jazoon 2010)

3

Agenda

> Apache Sling

> Why OSGi ?

> What parts of OSGi ?

> Advantages and Problems

> Demo

Page 4: Server-side OSGi with Apache Sling (Jazoon 2010)

4

Apache Sling

> REST based web framework

> Content-driven (JCR, JSR-170/283)

> Powered by OSGi

> Scripting inside (Java Scripting, JSR-223)

> Apache Open Source Projekt (http://sling.apache.org)

Page 5: Server-side OSGi with Apache Sling (Jazoon 2010)

5

Sling Architecture

OSGi Framework

FelixWeb Console

WebDAVServer

browserfilesystemdebuggerHTTP

JSR-170/283 API

JCRrepository

resourceresolution

servletresolution

standardservlets

customservlets

JSR223Scripting

JSP

javascript

etc.

Page 6: Server-side OSGi with Apache Sling (Jazoon 2010)

6

Sling URL Decomposition

/content/cars/audi/s4.details.html

Page 7: Server-side OSGi with Apache Sling (Jazoon 2010)

7

Sling is RESTful

> URLs map to Resources

– Items in the JCR Repository

– Files in the Filesystem

– Content of Bundles

> HTTP Methods map to Script Names

– e.g. cars/POST.jsp

– GET for reading only

– Dilution: POST allowed for any changes (Create, Update, Delete)

> Content Negotiation

– Request URL extension

– Accept request header currently ignored

Page 8: Server-side OSGi with Apache Sling (Jazoon 2010)

8

Sling is Object Oriented Web

> Resources are the Object

> Resources maintained in Resource Tree

> Resources accessed by path in the Resource Tree

> Request Method, Extension and Selectors define „Method“ to call

> Resources are typed:

– Resource Type

– Resource Super Type

– „Root Type“: sling/servlet/default

Page 9: Server-side OSGi with Apache Sling (Jazoon 2010)

9

Functionality Out-Of-the-Box

> Default Implementations for GET

– Plain Text

– JSON

– XML

> Default Implementation for POST

– Create, Update, Modify content

– Extensible

Page 10: Server-side OSGi with Apache Sling (Jazoon 2010)

10

Sling in Action

> Day Communiqué 5 (http://www.day.com/cq5)

> Sakai 3 (http://www.sakaiproject.org)

> Tuberculosis Project

> Idium Web (http://www.idium.no/no/idium_web)

http://cwiki.apache.org/SLING/who-is-using-sling-.html

Page 11: Server-side OSGi with Apache Sling (Jazoon 2010)

11

Agenda

> Apache Sling

> Why OSGi ?

> What parts of OSGi ?

> Advantages and Problems

> Demo

Page 12: Server-side OSGi with Apache Sling (Jazoon 2010)

12

Requirements for Sling

> Modular and Extensible System

> Declared Dependencies

> Intermodule Communication

> Lightweight Framework

Page 13: Server-side OSGi with Apache Sling (Jazoon 2010)

13

Variants

> Do It Yourself

– Well, don't we have other problems to solve ? ;-)

> Spring (before Spring DM)

– First Favourite due to declarative nature

– Systems not really dynamic

– Static application descriptor

> OSGi

– Perfect match to all requirements

Page 14: Server-side OSGi with Apache Sling (Jazoon 2010)

14

Agenda

> Apache Sling

> Why OSGi ?

> What parts of OSGi ?

> Advantages and Problems

> Demo

Page 15: Server-side OSGi with Apache Sling (Jazoon 2010)

15

OSGi Elements Used

> Framework

> Configuration Admin Service

> Meta Type Service

> Declarative Services

> Event Admin Service

> Log Service

> HTTP Service

Page 16: Server-side OSGi with Apache Sling (Jazoon 2010)

16

Launching Sling

> Standalone or Web Application

> Small Footprint Launcher (~30K)

> Framework in its own ClassLoader

> Restart of Framework

> Update of Framework

> Application is Container Agnostic

– Interaction only within the OSGi Framework

– Http Service implementation is the key

Page 17: Server-side OSGi with Apache Sling (Jazoon 2010)

17

Configuration Admin Service

> Provides an API to manage Configurations

> Provides functionality to pass configuration to consumers

> Hides persistance problems

> Uses in Sling

– Web Console configuraition editor

– JCR Install updates through repository

Page 18: Server-side OSGi with Apache Sling (Jazoon 2010)

18

Metatype Service

> Descriptor to generate GUI for Configuration Management

> Use in Sling

– Descriptor generated by Maven SCR Plugin

– Configuration Admin GUI in Web Console supports Metatype Service descriptors

Page 19: Server-side OSGi with Apache Sling (Jazoon 2010)

19

Declarative Services

> Replace boiler-plate code by descriptors

– Service Registration

– Configuration support

– Service Access

> Dependency Injection

> One of many OSGi Core Extensions:

– Apache Felix Dependency Manager (Predecessor)

– Apache Felix iPOJO (Successor)

– Blueprint (OSGi Compendium Specification R 4.2)

– Peaberry

Page 20: Server-side OSGi with Apache Sling (Jazoon 2010)

20

Event Admin Service

> Whiteboard Pattern oriented eventing

> Support for synchronous and asynchronous events

> Uses in Sling

– Base Mechnism to implement Job Scheduling

– Extended to allow for event distribution in Cluster

Page 21: Server-side OSGi with Apache Sling (Jazoon 2010)

21

Log Service

> Sling's own implementation

> Based on SLF4J API

> Provides

– OSGi LogService

– SLF4J Logging

– Commons Logging

– Log4F Logging

> Dynamically Configurable (by Configuration Admin Service)

> Log Levels and Log Format per Logger

> Multiple Log Files with size and time rotation

Page 22: Server-side OSGi with Apache Sling (Jazoon 2010)

22

Http Service

> Registering Servlets (and Resources) dynamically

> Real Implementation

– Includes Servlet Container

> Bridged Implementation

– Used for Web Application Launcher

– Bridges Servlet Container to OSGi

> Implementation transparent to registered Servlets

Page 23: Server-side OSGi with Apache Sling (Jazoon 2010)

23

Extensions

> Apache Felix Web Console

– Extensible Web Based Management

– Jquery UI Based (as of Version 3.0)

> Maven SCR Plugin

– Generates Declarative Services Descriptors Metatype Service Descriptors

– Supports JavaDoc Tags (@scr.component, etc.) Java 5 Annotations (@Component, etc.)

> JCR Install

– Deploy Bundles via JCR Repository

– Deploy Configuration Admin configurations via JCR Repository

Page 24: Server-side OSGi with Apache Sling (Jazoon 2010)

24

Agenda

> Apache Sling

> Why OSGi ?

> What parts of OSGi ?

> Advantages and Problems

> Demo

Page 25: Server-side OSGi with Apache Sling (Jazoon 2010)

25

Advantages

> Declared Dependencies

> Better Isolution through explicit exports and private classes

> Classloader Isolation

> Extensibility built-in, not built-atop

> Dynamism

Page 26: Server-side OSGi with Apache Sling (Jazoon 2010)

26

Problems

> Steep Learning Curve

– OSGi Specifications Themselves

– Modularization vs. Monolithic

> Uptime vs. Startup Time

> Legacy Specs und ClassLoader

– JDBC, XML, etc.

> Scripting und ClassLoader

– BundleClassLoaderProxy approach

> Application Packaging

– CRX Content Packages (Day proprietary)

– Karaf features (Sling provides feature.xml)

Page 27: Server-side OSGi with Apache Sling (Jazoon 2010)

27

Agenda

> Apache Sling

> Why OSGi ?

> What parts of OSGi ?

> Advantages and Problems

> Demo

Page 28: Server-side OSGi with Apache Sling (Jazoon 2010)

29

Links

> Apache Sling – The JCR (Web) Application Framework

http://sling.apache.org

> Apache Felix – OSGi Framework and Compendium Service implementations

http://felix.apache.org

> Apache Jackrabbit – The JCR (JSR-170/283) Reference Implementation

http://jackrabbit.apache.org

> Day Developer's Home

http://dev.day.com

Page 29: Server-side OSGi with Apache Sling (Jazoon 2010)

30

Questions

Page 30: Server-side OSGi with Apache Sling (Jazoon 2010)

31

Thank you very much !

Page 31: Server-side OSGi with Apache Sling (Jazoon 2010)

Felix Meschberger http://www.day.com

Day Management AG [email protected]