managing installations and provisioning of osgi...

46
Managing Installations and Provisioning of OSGi Applications Carsten Ziegeler [email protected]

Upload: others

Post on 12-Oct-2020

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Managing Installations and Provisioning of OSGi Applicationsarchive.apachecon.com/eu2012/presentations/08-Thursday/...• Many different tools for managing bundles and configurations

Managing Installations and Provisioning of

OSGi Applications

Carsten Ziegeler [email protected]

Page 2: Managing Installations and Provisioning of OSGi Applicationsarchive.apachecon.com/eu2012/presentations/08-Thursday/...• Many different tools for managing bundles and configurations

About

•  Member of the ASF •  Current PMC Chair of Apache Sling •  Apache Sling, Felix, ACE, Portals •  (Incubator, Cocoon, Excalibur, Commons)

•  RnD Team at Adobe Research Switzerland •  Article/Book Author, Conference Speaker •  Technical Reviewer •  JSR 286 Spec Group (Portlet API 2.0)

2

Page 3: Managing Installations and Provisioning of OSGi Applicationsarchive.apachecon.com/eu2012/presentations/08-Thursday/...• Many different tools for managing bundles and configurations

Agenda

§  1 Motivation §  2 Apache Sling Launchpad §  3 Apache Sling OSGi Installer §  4 Apache Sling Maven Launchpad Plugin §  5 Needful Things §  6 Summary §  7 The End…

3

Page 4: Managing Installations and Provisioning of OSGi Applicationsarchive.apachecon.com/eu2012/presentations/08-Thursday/...• Many different tools for managing bundles and configurations

Example Application �

����

Page 5: Managing Installations and Provisioning of OSGi Applicationsarchive.apachecon.com/eu2012/presentations/08-Thursday/...• Many different tools for managing bundles and configurations

Motivation I

§  Modularity is key §  Manage growing complexity §  Support dynamic extensibility

§  Embrace change – Embrace OSGi §  Only a few concepts – easy to get started §  Minor “overhead” §  High coherence

§  Loose Coupling §  Modules and Services

5

Page 6: Managing Installations and Provisioning of OSGi Applicationsarchive.apachecon.com/eu2012/presentations/08-Thursday/...• Many different tools for managing bundles and configurations

Motivation II

§  OSGi is everywhere! §  State of the Art solution for modularity in Java §  Ongoing and evolving development

§  Cloud, Enterprise etc. §  Modules are fine, but what about?

§  Assembling an application §  Deployment §  Provisioning §  (Development)

6

Page 7: Managing Installations and Provisioning of OSGi Applicationsarchive.apachecon.com/eu2012/presentations/08-Thursday/...• Many different tools for managing bundles and configurations

Apache Sling – Secret Facts

§  Apache Sling provides ecosystem §  Launchpad §  Launchpad Maven Plugin §  Partial Bundle Lists §  OSGi Installer §  Installer Providers §  Installer Factories §  And more…

7

Page 8: Managing Installations and Provisioning of OSGi Applicationsarchive.apachecon.com/eu2012/presentations/08-Thursday/...• Many different tools for managing bundles and configurations

Example Application �

����

8

Page 9: Managing Installations and Provisioning of OSGi Applicationsarchive.apachecon.com/eu2012/presentations/08-Thursday/...• Many different tools for managing bundles and configurations

Old Fashioned: I Have a Bunch of JARs

9

WE

I

R

N

IR

JO

S-

H

BA

B

G

S

EL

@AD OBE

Page 10: Managing Installations and Provisioning of OSGi Applicationsarchive.apachecon.com/eu2012/presentations/08-Thursday/...• Many different tools for managing bundles and configurations

Standalone App or Webapp

10

WE

I

R

N

IR

JO

S-

H

BA

B

G

S

EL

@AD OBE

WE

I

R

N

IR

JO

S-

H

BA

B

G

S

EL

@AD OBE

-  Main class -  Classpath:

-  Web application archive -  web-inf/lib:

Page 11: Managing Installations and Provisioning of OSGi Applicationsarchive.apachecon.com/eu2012/presentations/08-Thursday/...• Many different tools for managing bundles and configurations

I Have OSGi Bundles – and now?

11

WE

I

R

N

IR

JO

S-

H

BA

B

G

S

EL

@AD OBE

Page 12: Managing Installations and Provisioning of OSGi Applicationsarchive.apachecon.com/eu2012/presentations/08-Thursday/...• Many different tools for managing bundles and configurations

OSGi Standalone App or OSGi Webapp

12

WE

I

R

N

IR

JO

S-

H

BA

B

G

S

EL

@AD OBE

-  Main class starts OSGi framework and deploys bundles

-  Classpath: -  OSGi framework -  Bootstrap code

-  Web application archive -  Servlet starts OSGi framework

and deploys bundles -  web-inf/lib contains

-  OSGi framework -  Bootstrap code

Bundles:

Page 13: Managing Installations and Provisioning of OSGi Applicationsarchive.apachecon.com/eu2012/presentations/08-Thursday/...• Many different tools for managing bundles and configurations

Apache Sling Launchpad

•  Bootstrap code •  Launch an OSGi framework

•  Standalone jar with http service •  As a web application with http bridge

•  Includes Apache Felix •  Handles framework updates

•  Deploy packaged bundles •  Configurable

•  sling.properties •  (system properties / servlet parameters)

13

Page 14: Managing Installations and Provisioning of OSGi Applicationsarchive.apachecon.com/eu2012/presentations/08-Thursday/...• Many different tools for managing bundles and configurations

OSGi Standalone App or OSGi Webapp with Launchpad

14

JAR File Launchpad Main Bootstrap Code

OSGi Framewok OSGi HTTP Service

sling.properties Deployable Artifacts

WE

I

R

N

IR

JO

S-

H

BA

B

G

S

EL

@AD OBE

WAR File Launchpad Servlet

Bootstrap Code

OSGi Framewok HTTP Bridge

sling.properties Deployable Artifacts

WE

I

R

N

IR

JO

S-

H

BA

B

G

S

EL

@AD OBE

Page 15: Managing Installations and Provisioning of OSGi Applicationsarchive.apachecon.com/eu2012/presentations/08-Thursday/...• Many different tools for managing bundles and configurations

Apache Sling Properties

•  Central configuration file •  OSGi framework configuration

•  System packages •  Framework Start level

•  Bootstrap logging •  Configurations which should be there before the

configuration admin is available

15

Page 16: Managing Installations and Provisioning of OSGi Applicationsarchive.apachecon.com/eu2012/presentations/08-Thursday/...• Many different tools for managing bundles and configurations

Packaged Artifacts

•  Bootstrap bundles •  Directly installed by the Sling Launchpad •  E.g. logging, Apache Sling OSGi installer etc.

•  Start levels can be used •  Advice: only bootstrapping bundles! •  Optional Bootstrap command file

•  Uninstalling bundles for upgrades

16

Page 17: Managing Installations and Provisioning of OSGi Applicationsarchive.apachecon.com/eu2012/presentations/08-Thursday/...• Many different tools for managing bundles and configurations

Example Sling Launchpad JAR

> jar tf launchpad-sample.jar … org/apache/sling/launchpad/app/Main.class org/apache/sling/launchpad/base/shared/Launcher.class resources/bundles/1/org.apache.sling.commons.log-3.0.0.jar resources/bundles/1/slf4j-api-1.6.4.jar resources/bundles/1/org.apache.sling.installer.core-3.4.0.jar resources/org.apache.sling.launchpad.base.jar …

17

Created by the launchpad maven plugin:

Page 18: Managing Installations and Provisioning of OSGi Applicationsarchive.apachecon.com/eu2012/presentations/08-Thursday/...• Many different tools for managing bundles and configurations

Example Application �

����

18

Page 19: Managing Installations and Provisioning of OSGi Applicationsarchive.apachecon.com/eu2012/presentations/08-Thursday/...• Many different tools for managing bundles and configurations

Apache Sling OSGi Installer

•  Bundled service for •  Install •  Update •  Uninstall

•  Of •  Bundles •  Configurations •  Custom artifacts

19

Page 20: Managing Installations and Provisioning of OSGi Applicationsarchive.apachecon.com/eu2012/presentations/08-Thursday/...• Many different tools for managing bundles and configurations

Apache Sling OSGi Installer

20

OSGi Installer

File Provider

JCR Provider

Launchpad Provider

Providers Transformers and Task Factories

Config Admin

Bundles

Add/Remove Update

Artifact

Artifact

Transformed Artifact

State &

Artifact DB

Page 21: Managing Installations and Provisioning of OSGi Applicationsarchive.apachecon.com/eu2012/presentations/08-Thursday/...• Many different tools for managing bundles and configurations

Installer Providers

•  Just provide artifacts or inform about removal •  Don’t need knowledge about artifacts •  Simple trackers

21

Page 22: Managing Installations and Provisioning of OSGi Applicationsarchive.apachecon.com/eu2012/presentations/08-Thursday/...• Many different tools for managing bundles and configurations

Apache Sling Installer File Provider

•  Service for monitoring directories in the file system •  Configurable through sling.properties (and

system properties) •  Informs the OSGi Installer about

•  Add •  Update •  Delete

•  Of artifacts •  Like Apache Felix FileInstall but delegates work!

22

Page 23: Managing Installations and Provisioning of OSGi Applicationsarchive.apachecon.com/eu2012/presentations/08-Thursday/...• Many different tools for managing bundles and configurations

Apache Sling Installer JCR Provider

•  Support for Java Content Repository (Apache Jackrabbit)

•  Service for monitoring nodes in the JCR •  Configurable through Config Admin

•  Informs the OSGi Installer about •  Add •  Update •  Delete

•  Of artifacts

23

Page 24: Managing Installations and Provisioning of OSGi Applicationsarchive.apachecon.com/eu2012/presentations/08-Thursday/...• Many different tools for managing bundles and configurations

Transformers

•  Transformers inspect artifacts •  Detect artifact type

•  Bundle, configuration etc. •  Might transform artifact •  Provide unique id

•  Symbolic name + version •  Configuration PID

24

Page 25: Managing Installations and Provisioning of OSGi Applicationsarchive.apachecon.com/eu2012/presentations/08-Thursday/...• Many different tools for managing bundles and configurations

Installer Task Factories

•  Register for artifact types •  Get transformed artifacts or removal event •  Perform their task •  OSGi Installer manages retry and failure •  A task might add another task

•  Like bundle refresh after all installs etc.

25

Page 26: Managing Installations and Provisioning of OSGi Applicationsarchive.apachecon.com/eu2012/presentations/08-Thursday/...• Many different tools for managing bundles and configurations

Advantages of the OSGi Installer Family

•  Pluggable and highly customizable •  New artifact types: transformer + task factory •  New artifact sources: provider

•  Retry mechanism in the OSGi core •  State management in the OSGi core

26

Page 27: Managing Installations and Provisioning of OSGi Applicationsarchive.apachecon.com/eu2012/presentations/08-Thursday/...• Many different tools for managing bundles and configurations

Example I – Always Install Highest Version

27

Install directory:

-  Bundle A, version 1.0 -  Bundle A, version 1.2

Time

Install directory: -  Bundle A, version 1.2

Install directory:

-  Bundle A, version 1.0 -  Bundle A, version 1.2

Install directory: -  Bundle A, version 1.0

Installed Bundle:

-  Bundle A, version 1.2

Installed Bundle:

-  Bundle A, version 1.2

Installed Bundle:

-  Bundle A, version 1.2

Installed Bundle:

-  Bundle A, version 1.0

Page 28: Managing Installations and Provisioning of OSGi Applicationsarchive.apachecon.com/eu2012/presentations/08-Thursday/...• Many different tools for managing bundles and configurations

Example II – State Management

28

Install directory:

-  Bundle A, version 1.0 -  Bundle A, version 1.2

Time

User Installs through Web Console:

-  Bundle A, version 1.4

Install directory:

-  Bundle A, version 1.2

Install directory: -  Bundle A, version 1.0

Installed Bundle:

-  Bundle A, version 1.2

Installed Bundle:

-  Bundle A, version 1.4

Installed Bundle:

-  Bundle A, version 1.4

Installed Bundle:

-  Bundle A, version 1.4

Page 29: Managing Installations and Provisioning of OSGi Applicationsarchive.apachecon.com/eu2012/presentations/08-Thursday/...• Many different tools for managing bundles and configurations

Example III – State Management + Highest Version

29

Install directory:

-  Bundle A, version 1.0 -  Bundle A, version 1.2

Time

User Installs through Web Console:

-  Bundle A, version 1.1

Install directory:

Install directory: -  Bundle A, version 1.2

Installed Bundle:

-  Bundle A, version 1.2

Installed Bundle:

-  Bundle A, version 1.1

Installed Bundle:

-  Bundle A, version 1.1

Installed Bundle:

-  Bundle A, version 1.2

Page 30: Managing Installations and Provisioning of OSGi Applicationsarchive.apachecon.com/eu2012/presentations/08-Thursday/...• Many different tools for managing bundles and configurations

Change Notification

•  Many different tools for managing bundles and configurations •  OSGi Installer, shell, web console etc.

•  OSGi Installer checks for changes from other sources •  When getting changes from a provider

•  Supports write back of ”external” changes: •  Currently configurations only •  Provider might support write back of changes

•  File and JCR provider do!

30

Page 31: Managing Installations and Provisioning of OSGi Applicationsarchive.apachecon.com/eu2012/presentations/08-Thursday/...• Many different tools for managing bundles and configurations

Apache Sling OSGi Installer

•  Central mechanism for handling •  Install •  Update •  Delete

•  No dependencies except OSGi framework •  Triggered by various providers •  Highly customizable through transformers and

task factories

31

Page 32: Managing Installations and Provisioning of OSGi Applicationsarchive.apachecon.com/eu2012/presentations/08-Thursday/...• Many different tools for managing bundles and configurations

Apache Sling Installer Launchpad Provider

•  Informs the OSGi Installer about •  Artifacts bundled with the launchpad

•  Scans predefined directories inside launchpad •  Supports start level •  Very handy for provisioning in combination with

the Maven Launchpad Plugin

32

Page 33: Managing Installations and Provisioning of OSGi Applicationsarchive.apachecon.com/eu2012/presentations/08-Thursday/...• Many different tools for managing bundles and configurations

Example Application �

����

33

Page 34: Managing Installations and Provisioning of OSGi Applicationsarchive.apachecon.com/eu2012/presentations/08-Thursday/...• Many different tools for managing bundles and configurations

Contents of a Deliverable

•  A deliverable / distribution consists of •  Apache Sling Launchpad •  OSGi framework •  Bootstrap bundles •  Infrastructure bundles •  Application bundles •  Configurations •  (Custom artifacts)

34

Page 35: Managing Installations and Provisioning of OSGi Applicationsarchive.apachecon.com/eu2012/presentations/08-Thursday/...• Many different tools for managing bundles and configurations

Apache Sling Maven Launchpad Plugin

•  Creates two artifacts for a Maven project •  Standalone jar •  Web application

•  Use Apache Sling Launchpad Base Module •  Launchpad Code •  OSGi framework •  Predefined sling.properties

35

Page 36: Managing Installations and Provisioning of OSGi Applicationsarchive.apachecon.com/eu2012/presentations/08-Thursday/...• Many different tools for managing bundles and configurations

Bundle List

•  XML Configuration for the Maven plugin •  Contains list of bundles with their start levels

•  “boot” : bootstrap bundles handled by Launchpad

•  N : Bundle with start level N handled by OSGi installer and Launchpad Provider

•  0 : Bundle with default framework start level •  Bundle list can contain other artifact types!

36

Page 37: Managing Installations and Provisioning of OSGi Applicationsarchive.apachecon.com/eu2012/presentations/08-Thursday/...• Many different tools for managing bundles and configurations

Bundle List Example

37

<?xml version="1.0"?><bundles> <startLevel level="boot"> <bundle> <groupId>org.apache.sling</groupId> <artifactId>org.apache.sling.commons.log</artifactId> <version>2.1.2</version> </bundle> … <startLevel level="9"> <bundle> <groupId>org.apache.felix</groupId> <artifactId>org.apache.felix.eventadmin</artifactId> <version>1.3.2</version> </bundle> … <startLevel level="0"> <bundle> <groupId>org.some.company</groupId> <artifactId>a.strange.artifact</artifactId> <version>1.2.0</version> <type>zip</zip> </bundle>

Page 38: Managing Installations and Provisioning of OSGi Applicationsarchive.apachecon.com/eu2012/presentations/08-Thursday/...• Many different tools for managing bundles and configurations

OSGi Standalone App or OSGi Webapp with Launchpad

38

JAR File Launchpad Main Bootstrap Code

OSGi Framewok OSGi HTTP Service

sling.properties Bootstrap Bundles:

Logging, OSGi Installer Launchpad Installer Provider

WAR File Launchpad Servlet

Bootstrap Code

OSGi Framewok HTTP Bridge

sling.properties

Launchpad Installer Artifacts: Infrastructure bundles Application bundles Configurations (Custom Artifacts)

Bootstrap Bundles: Logging, OSGi Installer Launchpad Installer Provider

Launchpad Installer Artifacts: Infrastructure bundles Application bundles Configurations (Custom Artifacts)

Page 39: Managing Installations and Provisioning of OSGi Applicationsarchive.apachecon.com/eu2012/presentations/08-Thursday/...• Many different tools for managing bundles and configurations

Partial Bundle List aka Feature List

•  Maven artifact for •  A bundle list •  Configurations •  Additional sling.properties •  Additional bootstrap commands

•  Final deliverable can aggregate partial bundle lists

39

Page 40: Managing Installations and Provisioning of OSGi Applicationsarchive.apachecon.com/eu2012/presentations/08-Thursday/...• Many different tools for managing bundles and configurations

Apache Sling Maven Launchpad Plugin

•  Configurated with •  Launchpad base artifact •  Bundle list (+ partial bundle lists) •  OSGi configurations •  Additional sling.properties

•  Common, standalone, webapp •  Bootstrap command file

•  Common, standalone, webapp •  Creates the deliverable

40

Page 41: Managing Installations and Provisioning of OSGi Applicationsarchive.apachecon.com/eu2012/presentations/08-Thursday/...• Many different tools for managing bundles and configurations

Example Application �

����

41

Page 42: Managing Installations and Provisioning of OSGi Applicationsarchive.apachecon.com/eu2012/presentations/08-Thursday/...• Many different tools for managing bundles and configurations

Apache Sling Settings Service

•  Unique instance id : Sling ID •  Created on first installation

•  Run mode support •  Can be used for different setups like

•  Prod, dev, test etc. •  Supported by the OSGi installer providers

•  Sling home directory •  If something needs to be stored outside bundle

data

42

Page 43: Managing Installations and Provisioning of OSGi Applicationsarchive.apachecon.com/eu2012/presentations/08-Thursday/...• Many different tools for managing bundles and configurations

Launchpad Features

•  Startup mode detection •  First install, restart, update

•  Start level handling for install/restart •  Start level is increased one by one •  Waits for OSGi installer to finish on each level

•  Reports startup progress

43

Page 44: Managing Installations and Provisioning of OSGi Applicationsarchive.apachecon.com/eu2012/presentations/08-Thursday/...• Many different tools for managing bundles and configurations

Example Application �

����

44

Page 45: Managing Installations and Provisioning of OSGi Applicationsarchive.apachecon.com/eu2012/presentations/08-Thursday/...• Many different tools for managing bundles and configurations

Apache Sling OSGi Installer + Launchpad

•  Creating a distribution is easy •  Standalone jar files •  Web application

•  Bootstrap bundles get packaged into launchpad •  Including OSGi installer and friends

•  Leveraging JCR Installer (or others) •  Maven Launchpad Plugin

•  Define your deliverable as a package list •  OSGi Installer can be used without Launchpad •  Launchpad does not need OSGi Installer

45

Page 46: Managing Installations and Provisioning of OSGi Applicationsarchive.apachecon.com/eu2012/presentations/08-Thursday/...• Many different tools for managing bundles and configurations

The End…

46