SlideShare a Scribd company logo
© 2014 Adobe Systems Incorporated. All Rights Reserved.
Building Modular Enterprise Applications
Carsten Ziegeler | Adobe Research Switzerland
1
© 2014 Adobe Systems Incorporated. All Rights Reserved.
About
carsten.ziegeler@adobe.com @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
© 2014 Adobe Systems Incorporated. All Rights Reserved.
Motivation
§  Enjoy the power of modularity
§  OSGi is everywhere
§  From embedded systems to enterprise applications and THE CLOUD
§  Adapting a technology is always a challenge
§  Common pitfalls
§  Potential solutions
3
© 2014 Adobe Systems Incorporated. All Rights Reserved.
But wait a second…
§  Adobe & OSGi ?
4
© 2014 Adobe Systems Incorporated. All Rights Reserved.
But wait a second…
§  Adobe & OSGi ?
5
© 2014 Adobe Systems Incorporated. All Rights Reserved.
Adobe & OSGi & Open Source & Open Development
§  Using OSGi in various products
§  Strategic member of the OSGi Alliance
§  Board of directors
§  Participating in CPEG and EEG
§  Highly contributing to open source
§  Especially Apache Software Foundation
§  Participating in open standards
§  Embracing open development
6
© 2014 Adobe Systems Incorporated. All Rights Reserved.
Case Study: The Development of Adobe Experience Manager
7
© 2014 Adobe Systems Incorporated. All Rights Reserved.
Back to the Future: Web Content Management Code History
8
© 2014 Adobe Systems Incorporated. All Rights Reserved.
Back in the Days…CQ 4
9
© 2014 Adobe Systems Incorporated. All Rights Reserved.
OSGi based Enterprise Web Content Management – Adobe CQ5
10
© 2014 Adobe Systems Incorporated. All Rights Reserved.
Adobe Experience Manager
11
© 2014 Adobe Systems Incorporated. All Rights Reserved.
Motivations for Going Modular (2006)
§  Aged code base
§  Monolithic
§  Highly entangled
§  Growing complexity and functionality
§  No clear separation between API and implementation
§  Increasing customer base
§  Team growth
12
© 2014 Adobe Systems Incorporated. All Rights Reserved.
Modularity is Key
§  Manage growing complexity
§  Support dynamic extensibility
§  Define contracts between modules
13
© 2014 Adobe Systems Incorporated. All Rights Reserved.
Potential Solutions (2006)
§  Spring?
§  OSGi?
§  Other open source component frameworks?
§  DIY?
14
© 2014 Adobe Systems Incorporated. All Rights Reserved.
Benefits of OSGi
§  OSGi modules = bundles
§  jars with strict enforcements
§  Exported packages with version
§  Imported packages with version range
§  Private packages
§  Service Registry
§  Separation of Concerns
§  Loose coupling
15
© 2014 Adobe Systems Incorporated. All Rights Reserved.
Modularity - How do we get there? (2006)
§  Start with a single big bundle?
§  Embedding OSGi framework?
§  Complete rewrite?
16
© 2014 Adobe Systems Incorporated. All Rights Reserved.
The Fun Way : Complete Rewrite
§  New architecture
§  New backend (Apache Jackrabbit)
§  New web application framework (Apache Sling)
§  New UI
§  Build modules from the start
§  Control evolution
§  (Provide tools for migration from old solution)
17
© 2014 Adobe Systems Incorporated. All Rights Reserved.
OSGi and Open Source (2006)
§  Apache Felix
§  Equinox
18
© 2014 Adobe Systems Incorporated. All Rights Reserved.
Framework runs and now?
§  We need bundles!
§  Build tools
§  Ant? (BND)
§  Maven? (Apache Felix Maven Bundle Plugin)
19
© 2014 Adobe Systems Incorporated. All Rights Reserved.
Maven Bundle Plugin (2007)
§  Specifying all OSGi metadata in the POM
§  Exported packages
§  Private packages
§  Imported packages and versions get calculated
§  Parent POM to define rules for bundle symbolic name
20
© 2014 Adobe Systems Incorporated. All Rights Reserved.
Maven Bundle Plugin – First problems
§  Specifying all OSGi metadata in the POM
§  Exported packages
§  Private packages
§  Imported packages and versions get calculated
§  Parent POM to define rules for bundle symbolic name
§  Exported package version = POM version
§  New private package needs updating the pom
§  Slight difference in version handling between OSGi and Maven (The SNAPSHOT problem)
§  2.0.1 < (OSGi) 2.0.1-SNAPSHOT < (Maven) 2.0.1
§  Semantic versioning?
21
© 2014 Adobe Systems Incorporated. All Rights Reserved.
Excursion on Versioning
§  Marketing Versions vs. Engineering Versions
§  Versioning Package Exports
§  Engineering Versions
§  Apply versions !
§  Semantic Versioning crucial
§  Bundle Versions
§  Grey area
§  Semantic Versioning helpful
§  Application Versions
§  Marketing Versions
22
© 2014 Adobe Systems Incorporated. All Rights Reserved.
Versioning Best Practice
§  Package Exports
§  Always apply a version to package exports
§  Start with 1.0
§  Only increment when changing the API
§  Think hard before increasing the major version !
§  Package Imports
§  Ensure proper version range import
23
© 2014 Adobe Systems Incorporated. All Rights Reserved.
Semantic Versioning
§  Nice whitepaper on the OSGi homepage
§  Versioning policy for exported packages
§  OSGi versions: <major>.<minor>.<micro>.<qualifier>
§  Updating package versions:
§  Fix/patch (no API change) : update micro
§  Extend API (affects implementers, not clients) : update minor
§  API breakage: update major
24
© 2014 Adobe Systems Incorporated. All Rights Reserved.
Versioning Annotations
§  BND or new with OSGi R6
§  Annotations for documenting semantic versioning information
§  @Version
§  @ProviderType
§  @ConsumerType
25
© 2014 Adobe Systems Incorporated. All Rights Reserved.
Versioning Best Practice (cont.)
§  Bundle Versions
§  Always use and manage bundle version
§  Align bundle version with Maven version
§  Use odd micro versions for SNAPSHOTs
§  e.g. 0.0.1-SNAPSHOT, 1.3.5-SNAPSHOT
§  Use even micro versions for release
§  e.g. 1.0.0, 1.3.6
§  Dependencies
§  Always use least required version for dependencies
26
© 2014 Adobe Systems Incorporated. All Rights Reserved.
Maven Bundle Plugin – Today
§  Specifying all OSGi metadata in the POM
§  Exported packages
§  Private packages
§  Imported packages and versions get calculated
§  Parent POM to define rules for bundle symbolic name
§  Parent POM to define rules for bundle symbolic name and private packages
§  No package versioning information in POM (annotations)
§  Follow semantic versioning
§  Odd/even versioning policy
§  Usually no OSGI metadata in the POM
27
© 2014 Adobe Systems Incorporated. All Rights Reserved.
What about Components and Services (2007)?
§  Framework API is usually too low level
§  Make development as easy as possible
§  Try to hide dynamics
§  And there are OSGi compendium specs
§  Declarative Services
§  Configuration Admin
§  Metatype
28
© 2014 Adobe Systems Incorporated. All Rights Reserved.
Component Development with Declarative Services
§  Declarative Services (OSGi Compendium Spec)
§  Defines Service Component Runtime (SCR)
§  Declarative component model
§  XML descriptor for components including
§  Provided services
§  References to other services
§  Configuration properties
29
© 2014 Adobe Systems Incorporated. All Rights Reserved.
Configuration Admin
•  OSGi Configuration Admin
•  “The” solution to handle configurations
•  Configuration Manager
•  Persistence storage
•  Service API to retrieve/update/remove configuration
•  OSGi Metatype Service
•  Description of bundle metadata
•  Description of service configurations
•  Property type, name, and description
30
© 2014 Adobe Systems Incorporated. All Rights Reserved.
What about Components and Services (2007)?
§  Framework API is usually too low level
§  And there are OSGi compendium specs
§  Declarative Services
§  Configuration Admin
§  Metatype
§  No (Apache) open source implementations available
§  Nearly no tooling
§  Declarative Services uses XML descriptors
§  Metatype uses XML descriptors and property files
31
© 2014 Adobe Systems Incorporated. All Rights Reserved.
DIY – Donations to Apache Felix
§  Apache Felix SCR (Declarative Service Implementation)
§  Apache Felix Config Admin
§  Apache Felix Metatype
§  Apache Felix Preferences
§  Apache Felix SCR Tooling
§  Java annotations for generating DS and Metatype descriptors
§  Maven, ANT, BND
32
© 2014 Adobe Systems Incorporated. All Rights Reserved.
Component Development with Declarative Services
§  Declarative Services (OSGi Compendium Spec)
§  Defines Service Component Runtime (SCR)
§  Apache Felix SCR Annotations (DS annotations)
§  Some advantages (in combination with the tooling)
§  POJO style
§  Declarative
§  Single source: just the Java code, no XML etc.
§  "Integration" with Configuration Admin and Metatype Service
33
© 2014 Adobe Systems Incorporated. All Rights Reserved.
Components and Services with OSGi
§  Service interface
§  Public (if exported for other bundles)
§  Versioned through package version (Semantic versioning)
§  Private for internal services (sometimes useful)
§  Component / service implementation
§  Always private
34
© 2014 Adobe Systems Incorporated. All Rights Reserved.
My First Component
35
package com.adobe.osgitraining.impl;	
	
import org.apache.felix.scr.annotations.Component;	
	
@Component	
public class MyComponent {	
	
}
© 2014 Adobe Systems Incorporated. All Rights Reserved.
Component Lifecycle
36
package com.adobe.osgitraining.impl;	
	
import org.apache.felix.scr.annotations.Activate;	
import org.apache.felix.scr.annotations.Component;	
import org.apache.felix.scr.annotations.Deactivate;	
	
@Component	
public class MyComponent {	
	
@Activate	
protected void activate() {	
// do something	
}	
	
@Deactivate	
protected void deactivate() {	
// do something	
}	
}
© 2014 Adobe Systems Incorporated. All Rights Reserved.
Providing a Service
37
package com.adobe.osgitraining.impl;	
	
import org.apache.felix.scr.annotations.Component;	
import org.apache.felix.scr.annotations.Service;	
import org.osgi.service.event.EventHandler;	
	
@Component	
@Service(value=EventHandler.class)	
public class MyComponent implements EventHandler {	
	
…
© 2014 Adobe Systems Incorporated. All Rights Reserved.
Using a Service
38
package com.adobe.osgitraining.impl;	
	
import org.apache.felix.scr.annotations.Component;	
import org.apache.felix.scr.annotations.Service;	
import org.osgi.service.event.EventHandler;	
	
@Component	
@Service(value=EventHandler.class)	
public class MyComponent implements EventHandler {	
	
@Reference	
privateTThreadPool threadPool;	
	
…
© 2014 Adobe Systems Incorporated. All Rights Reserved.
Using an Optional Service
39
package com.adobe.osgitraining.impl;	
	
import org.apache.felix.scr.annotations.Component;	
import org.apache.felix.scr.annotations.Service;	
import org.osgi.service.event.EventHandler;	
	
@Component	
@Service(value=EventHandler.class)	
public class MyComponent implements EventHandler {	
	
@Reference(cardinality=ReferenceCardinality.OPTIONAL_UNARY,	
policy=ReferencePolicy.DYNAMIC)	
private volatileTThreadPool threadPool;	
	
@Reference(cardinality=ReferenceCardinality.MANDATORY_UNARY)	
privateTDistributor distributor;
© 2014 Adobe Systems Incorporated. All Rights Reserved.
Component Properties -> Service Properties
40
import org.apache.sling.commons.osgi.PropertiesUtil;	
	
@Component	
@Service(value=EventHandler.class)	
@Properties({	
@Property(name="service.vendor", value="Who?”),	
@Property(name="service.ranking", intValue=500)	
})	
public class DistributingEventHandler	
implements EventHandler {
© 2014 Adobe Systems Incorporated. All Rights Reserved.
Configuration Admin
•  OSGi Configuration Admin
•  “The” solution to handle configurations
•  Configuration Manager
•  Persistence storage
•  Service API to retrieve/update/remove configuration
•  Integration with Declarative Services
•  Configuration changes are propagated to the components
•  Configurations are stored using the PID
41
© 2014 Adobe Systems Incorporated. All Rights Reserved.
Configuration – Supports Configuration Admin
§  Provided map contains
§  Configuration properties from Configuration Admin
§  Defined component properties
42
	
@Activate	
protected void activate(final Map<String, Object> props) {	
…	
}
© 2014 Adobe Systems Incorporated. All Rights Reserved.
Configuration – Supports Configuration Admin
43
import org.apache.sling.commons.osgi.PropertiesUtil;	
	
@Component	
@Service(value=EventHandler.class)	
@Properties({	
@Property(name="event.topics", value="*", propertyPrivate=true),	
@Property(name="event.filter", value="(event.distribute=*)",	
propertyPrivate=true)	
})	
public class DistributingEventHandler	
implements EventHandler {	
	
private static final int DEFAULT_CLEANUP_PERIOD = 15;	
	
@Property(intValue=DEFAULT_CLEANUP_PERIOD)	
private static final String PROP_CLEANUP_PERIOD ="cleanup.period";	
	
private int cleanupPeriod;	
	
@Activate	
protected void activate(final Map<String, Object> props) {	
this.cleanupPeriod = 	
PropertiesUtil.toInteger(props.get(PROP_CLEANUP_PERIOD));	
}
© 2014 Adobe Systems Incorporated. All Rights Reserved.
Configuration Update
44
import org.apache.sling.commons.osgi.OsgiUtil;	
	
public class DistributingEventHandler	
implements EventHandler {	
	
…	
	
@Modified	
protected void update(final Map<String, Object> props) {	
this.cleanupPeriod = 	
PropertiesUtil.toInteger(props.get(PROP_CLEANUP_PERIOD));	
}	
Without @Modified:
Component is restarted on config change!
© 2014 Adobe Systems Incorporated. All Rights Reserved.
Metatype
§  OSGi Metatype Service
§  Description of bundle metadata
§  Description of service configurations
§  Property type, name, and description
45
© 2014 Adobe Systems Incorporated. All Rights Reserved.
Configuration – Supports Metatype
46
import org.apache.sling.commons.osgi.PropertiesUtil;	
	
@Component(metatype=true, label="Distributing Event Handler", 	
description="This handler is awesome.")	
	
@Properties({	
@Property(name="event.topics", value="*", propertyPrivate=true)	
})	
public class DistributingEventHandler	
implements EventHandler {	
	
private static final int DEFAULT_CLEANUP_PERIOD = 15;	
	
@Property(intValue=DEFAULT_CLEANUP_PERIOD,	
label="Cleanup Period", 	
description="This is the cleanup period in seconds.")	
private static final String PROP_CLEANUP_PERIOD ="cleanup.period";
© 2014 Adobe Systems Incorporated. All Rights Reserved.
Component Development with Declarative Services
§  Straight forward component development
§  Single source of truth
§  (Will even be easier with new Declarative Service spec from R6)
§  Typical problems
§  OSGi dynamics is hidden
§  Handling references of cardinality multiple
§  Copying of bad practices
47
© 2014 Adobe Systems Incorporated. All Rights Reserved.
And what about THE WEB? (2007)
§  OSGi Http Service Specification
§  Based on servlet API 2.1
§  Programmatic API to register servlets and resources
§  Apache Felix HTTP implementation
§  Later whiteboard support in Apache Felix implementation for
§  Servlets
§  Filters
§  Some listeners
48
© 2014 Adobe Systems Incorporated. All Rights Reserved.
And what about THE WEB?
§  OSGi Http Service Specification
§  Based on servlet API 2.1
§  Programmatic API to register servlets and resources
§  Apache Felix HTTP implementation
§  Invented Apache Sling Web Framework
§  Resource based approach
§  Scripting
§  Written as OSGi bundles
§  Later whiteboard support in Apache Felix implementation for
§  Servlets
§  Filters
§  Some listeners
§  New OSGi Http Whiteboard Service Spec in R6
49
© 2014 Adobe Systems Incorporated. All Rights Reserved.
But what about Provisioning and Deliverables? (2007)
§  Wishes
§  Single definition of deliverable (bundles, configurations, proprietary packages)
§  Different flavors: web application, standalone
§  Easy and flexible updates
50
© 2014 Adobe Systems Incorporated. All Rights Reserved.
But what about Provisioning and Deliverables? (2007)
§  Wishes
§  Single definition of deliverable (bundles, configurations, proprietary packages)
§  Different flavors: web application, standalone
§  Easy and flexible updates
§  No open source solution available
51
© 2014 Adobe Systems Incorporated. All Rights Reserved.
Contributing Apache Sling Launchpad Ecosystem
§  Creating a distribution is easy
§  Standalone jar file and/or web application
§  Maven Launchpad Plugin
§  Define bundle list
§  Add other artifacts
§  Configurations
§  Leverages Apache Sling’s OSGi installer
52
© 2014 Adobe Systems Incorporated. All Rights Reserved.
Bundle List Example
53
<?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>
© 2014 Adobe Systems Incorporated. All Rights Reserved.
Apache Sling Launchpad
§  Bootstrap code
§  Includes Apache Felix
§  Handles framework updates
§  Launch an OSGi framework
§  Standalone jar with http service
§  As a web application with http bridge
§  Deploy packaged artifacts
§  Configurable
§  sling.properties
§  (system properties / servlet parameters)
54
© 2014 Adobe Systems Incorporated. All Rights Reserved.
OSGi Standalone App or OSGi Webapp with Launchpad
55
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 / OSGi HTTP Service
sling.properties
Deployable Artifacts
WE
I
R
N
IR
JO
S-
H
BA
B
G
S
EL
@AD
OBE
© 2014 Adobe Systems Incorporated. All Rights Reserved.
Apache Sling OSGi Installer
§  General service covering
§  Install
§  Update
§  Uninstall
§  Of
§  Bundles
§  Configurations
§  Custom artifacts
56
© 2014 Adobe Systems Incorporated. All Rights Reserved.
Apache Sling OSGi Installer
57
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
© 2014 Adobe Systems Incorporated. All Rights Reserved.
Advantages of the OSGi Installer Family
§  Pluggable and highly customizable
§  New artifact types: transformer + task factory
§  New artifact sources: provider
§  Batch handling
§  Retry mechanism in the installer core
§  Bundle installation order doesn’t matter
§  State management in the installer core
§  Defined workflow
§  Copes with 3rd party changes
58
© 2014 Adobe Systems Incorporated. All Rights Reserved.
Running Deliverables and what about administration? (2007)
§  Nothing really available in the open source world
§  Especially not web based
59
© 2014 Adobe Systems Incorporated. All Rights Reserved.
Donating Apache Felix Web Console + Plugins
§  Rich set of core functionality
§  Bundles
§  Services
§  Configuration Admin
§  System Information
§  (JQuery based UI)
§  Extensible
§  Pluggable authentication
§  Still light-weight
§  REST interface
60
© 2014 Adobe Systems Incorporated. All Rights Reserved.
Web Console Demo I
61
© 2014 Adobe Systems Incorporated. All Rights Reserved.
Web Console Demo II
62
© 2014 Adobe Systems Incorporated. All Rights Reserved.
Web Console Demo III
63
© 2014 Adobe Systems Incorporated. All Rights Reserved.
Web Console - Offline Usage
§  Status zip contains
§  Output from all inventory printers
§  Output from special web console plugins
§  Attachments
§  JSON files
§  Automated analysis
§  Bundle list and status
§  Configurations
§  Log files
64
© 2014 Adobe Systems Incorporated. All Rights Reserved.
Problems solved…
§  Modularity
§  OSGi bundles
§  Semantic versioning
§  Services and components
§  Development
§  Frameworks and tooling
§  Deliverables and provisioning
§  Administration
65
© 2014 Adobe Systems Incorporated. All Rights Reserved.
Hitting the Real World – 3rd Party Libraries
§  Use them as bundles
§  Project delivers already a bundle
§  Apache Commons, Apache Sling etc.
§  Use special bundle repositories
§  Apache Felix Commons, Spring etc.
§  But check included metadata!
§  Create your own wrapper
§  Easy with the Felix maven bundle plugin
§  Include classes in your bundle
§  Again: easy with the Felix maven bundle plugin
§  Convince the projects to provide useful OSGi metadata!
66
© 2014 Adobe Systems Incorporated. All Rights Reserved.
Hitting the Real World – "Enterprise" Requirements
§  Testing under high load / high concurrency
§  Reimplementing some (open source) modules
§  Not every developer is aware that code can be called concurrently
§  And how to solve this in an acceptable way
§  Dynamic nature of OSGi
§  Relatively painless with DS and annotations
§  Gets trickier with plain framework API and/or cardinality multiple
§  Again: concurrency
67
© 2014 Adobe Systems Incorporated. All Rights Reserved.
Hitting the Real World – All Time Favorites
§  When is my system ready?
§  Different strategies
§  All bundles started and specific start level reached
§  Special startup handler service for notification (Apache Sling)
§  Fighting against FUD
§  OSGi is slow, consumes too much memory, complicated,
§  has no dependency injection, is not used in the enterprise…
68
© 2014 Adobe Systems Incorporated. All Rights Reserved.
Additional Challenges
§  Clustering
§  Discovery
§  Distributed Eventing
69
© 2014 Adobe Systems Incorporated. All Rights Reserved.
On the Roadmap
§  OSGi subsystems
§  Grouping of bundles
§  Export / import boundaries on subsystem level
§  OSGi Remote Services
§  OSGi Asynchronous Services
§  OSGi Distributed Eventing
70
© 2014 Adobe Systems Incorporated. All Rights Reserved.
Think Modular…
•  This is not a new concept or latest hype!
•  Think about modularity!
•  Create a clean package space
•  What is your API?
•  public vs private
•  Make things only public if necessary/used
•  Starting with private stuff going public is easy
•  Use proper versioning contracts
•  Semantic Versioning
71
© 2014 Adobe Systems Incorporated. All Rights Reserved.
…Be Modular!
•  Provide bundles
•  Add manifest information
•  Think about dependencies
•  Additional bundle vs include
•  Optional
•  Version ranges
•  Manage releases and versions properly
•  Benefits even without OSGi
72
© 2014 Adobe Systems Incorporated. All Rights Reserved.
Component Development
§  Contract defined by service interface
§  Declarative Services is a powerful component model
§  Minimal OSGi knowledge required with available solutions
§  Apache Felix SCR Tooling
§  Alternatives available J
§  Inter-operability through OSGi service registry
73
© 2014 Adobe Systems Incorporated. All Rights Reserved.
Conclusion
§  Today a lot of the hard work is already done
§  Open Source & Open Development are your friends
§  OSGi made the Adobe Experience Manager success story possible
§  Team growth from 40+ to several hundreds
§  Immense growth in functionality
§  Still (dynamically) extensible and manageable
§  OSGi Core and Compendium provide nearly everything you need
§  Framework, Declarative Services, Configuration Admin, Metatype, Event Admin
§  Open Source Implementations and Extensions
§  Apache Felix and friends
74
© 2014 Adobe Systems Incorporated. All Rights Reserved.
Check It Out!
•  Read the OSGi specs
•  Framework
•  Declarative Services, Config Admin, Metatype, Event Admin
•  Checkout the various Apache projects!
•  Explore available tooling
•  Embrace modularity!
•  Join the OSGi Alliance and help shaping the future!
75
© 2014 Adobe Systems Incorporated. All Rights Reserved.
And…New OSGi Specifications!
§  Last week (week of June 2nd) the OSGi Core Release 6 Specification received its final
approval and will be available this week to the public for downloading.
§  http://www.osgi.org/Specifications/HomePage
§  Also happening last week, the OSGi Board of Directors approved the publication of an
Early Draft Specification of OSGi Enterprise Release 6 for downloading.
§  http://www.osgi.org/Specifications/Drafts
76
© 2014 Adobe Systems Incorporated. All Rights Reserved.
References
§  OSGi Semantic Versioning Whitepaper: http://www.osgi.org/wiki/uploads/Links/SemanticVersioning.pdf
§  OSGi Specifications: http://www.osgi.org
§  Apache Felix: http://felix.apache.org
§  Apache Sling: http://sling.apache.org
§  Apache Aries: http://aries.apache.org
§  BND: http://www.aqute.biz/Bnd/Bnd
§  Bndtools: http://njbartlett.name/bndtools.html
§  Planet OSGi: http://www.osgi.org/Planet/Feed
77
© 2014 Adobe Systems Incorporated. All Rights Reserved.

More Related Content

PDF
OSGi enRoute Unveiled - P Kriens
PDF
OSGi & Java EE: A hybrid approach to Enterprise Java Application Development,...
PDF
Lessons learned from a large scale OSGii web app - P Bakker & J de Vreede
PDF
Embrace Change - Embrace OSGi
PDF
Benefits of OSGi in Practise
PDF
Robust collaboration services with OSGi - Satya Maheshwari
PDF
Concierge - Bringing OSGi (back) to Embedded Devices
PPTX
#JavaOne What's in an object?
OSGi enRoute Unveiled - P Kriens
OSGi & Java EE: A hybrid approach to Enterprise Java Application Development,...
Lessons learned from a large scale OSGii web app - P Bakker & J de Vreede
Embrace Change - Embrace OSGi
Benefits of OSGi in Practise
Robust collaboration services with OSGi - Satya Maheshwari
Concierge - Bringing OSGi (back) to Embedded Devices
#JavaOne What's in an object?

What's hot (20)

PDF
Require js training
PPTX
Java Modularity with OSGi
PDF
What's next for Java API for WebSocket (JSR 356)
PPT
Developing modular Java applications
PDF
Domino OSGi Development
PPTX
FAST for SharePoint Deep Dive
PPTX
An XPager's Guide to Process Server-Side Jobs on Domino
PDF
RESTful Services and Distributed OSGi - 04/2009
PDF
OSGi in Java EE Servers - Sneak Peek Under the Hood - Krasimir Semerdzhiev
PPTX
CollabSphere 2021 - DEV114 - The Nuts and Bolts of CI/CD With a Large XPages ...
ODP
Spring Mvc,Java, Spring
PDF
MuleSoft Nashik Virtual Meetup#4 - Implementing CI/CD pipeline for deploying ...
PDF
JVMs in Containers
PDF
GlassFish Community and future larochelle
PPTX
Modular Java
PDF
Arquillian 소개
PDF
Where is cold fusion headed
PPT
JavaFX vs AJAX vs Flex
PPTX
The Next Step in Responsive - RESS
PPTX
Developing Web Application Using J2EE - Nex
Require js training
Java Modularity with OSGi
What's next for Java API for WebSocket (JSR 356)
Developing modular Java applications
Domino OSGi Development
FAST for SharePoint Deep Dive
An XPager's Guide to Process Server-Side Jobs on Domino
RESTful Services and Distributed OSGi - 04/2009
OSGi in Java EE Servers - Sneak Peek Under the Hood - Krasimir Semerdzhiev
CollabSphere 2021 - DEV114 - The Nuts and Bolts of CI/CD With a Large XPages ...
Spring Mvc,Java, Spring
MuleSoft Nashik Virtual Meetup#4 - Implementing CI/CD pipeline for deploying ...
JVMs in Containers
GlassFish Community and future larochelle
Modular Java
Arquillian 소개
Where is cold fusion headed
JavaFX vs AJAX vs Flex
The Next Step in Responsive - RESS
Developing Web Application Using J2EE - Nex
Ad

Similar to Building Modular Enterprise Applications - C Ziegeler (20)

PDF
Monoliths are so 2001 – What you need is Modularity
PPTX
New and cool in OSGi R7 - David Bosschaert & Carsten Ziegeler
PDF
Maximize the power of OSGi in AEM
PDF
OSGi Enterprise R6 specs are out! - David Bosschaert & Carsten Ziegeler
PDF
Calling All Modularity Solutions: A Comparative Study from eBay
PDF
Calling all modularity solutions
PPT
OSGi For Java Infrastructures [5th IndicThreads Conference On Java 2010, Pune...
PPTX
Java 9 Modules: The Duke Yet Lives That OSGi Shall Depose
PDF
10 clues showing that you are doing OSGi in the wrong manner - Jerome Moliere
PDF
Tuscany : Applying OSGi After The Fact
PDF
BeJUG Meetup - What's coming in the OSGi R7 Specification
PDF
Strengthening Adobe’s Enterprise Platform with Day Software and Open Development
PDF
OSGi Best Practices – Learn how to prevent common mistakes and build robust, ...
PDF
Crx 2.2 Deep-Dive
PPTX
PDF
Maximise the Power of OSGi - Carsten Ziegeler & David Bosschaert
PDF
Maximize the power of OSGi
PPTX
TDD on OSGi, in practice.
PDF
Osgi In Depth 1st Edition Alexandre De Castro Alves
PDF
OSGi at eBay: JavaOne 2010
Monoliths are so 2001 – What you need is Modularity
New and cool in OSGi R7 - David Bosschaert & Carsten Ziegeler
Maximize the power of OSGi in AEM
OSGi Enterprise R6 specs are out! - David Bosschaert & Carsten Ziegeler
Calling All Modularity Solutions: A Comparative Study from eBay
Calling all modularity solutions
OSGi For Java Infrastructures [5th IndicThreads Conference On Java 2010, Pune...
Java 9 Modules: The Duke Yet Lives That OSGi Shall Depose
10 clues showing that you are doing OSGi in the wrong manner - Jerome Moliere
Tuscany : Applying OSGi After The Fact
BeJUG Meetup - What's coming in the OSGi R7 Specification
Strengthening Adobe’s Enterprise Platform with Day Software and Open Development
OSGi Best Practices – Learn how to prevent common mistakes and build robust, ...
Crx 2.2 Deep-Dive
Maximise the Power of OSGi - Carsten Ziegeler & David Bosschaert
Maximize the power of OSGi
TDD on OSGi, in practice.
Osgi In Depth 1st Edition Alexandre De Castro Alves
OSGi at eBay: JavaOne 2010
Ad

More from mfrancis (20)

PDF
Eclipse Modeling Framework and plain OSGi the easy way - Mark Hoffman (Data I...
PDF
OSGi and Java 9+ - BJ Hargrave (IBM)
PDF
Simplify Web UX Coding using OSGi Modularity Magic - Paul Fraser (A2Z Living)
PDF
OSGi for the data centre - Connecting OSGi to Kubernetes - Frank Lyaruu
PDF
Remote Management and Monitoring of Distributed OSGi Applications - Tim Verbe...
PDF
OSGi with Docker - a powerful way to develop Java systems - Udo Hafermann (So...
PDF
A real world use case with OSGi R7 - Jurgen Albert (Data In Motion Consulting...
PDF
OSGi Feature Model - Where Art Thou - David Bosschaert (Adobe)
PDF
Migrating from PDE to Bndtools in Practice - Amit Kumar Mondal (Deutsche Tele...
PDF
OSGi CDI Integration Specification - Ray Augé (Liferay)
PDF
How OSGi drives cross-sector energy management - Jörn Tümmler (SMA Solar Tech...
PDF
Improved developer productivity thanks to Maven and OSGi - Lukasz Dywicki (Co...
PDF
It Was Twenty Years Ago Today - Building an OSGi based Smart Home System - Ch...
PDF
Popular patterns revisited on OSGi - Christian Schneider (Adobe)
PDF
Integrating SLF4J and the new OSGi LogService 1.4 - BJ Hargrave (IBM)
PDF
OSG(a)i: because AI needs a runtime - Tim Verbelen (imec)
PDF
Flying to Jupiter with OSGi - Tony Walsh (ESA) & Hristo Indzhov (Telespazio V...
PDF
MicroProfile, OSGi was meant for this - Ray Auge (Liferay)
PDF
Prototyping IoT systems with a hybrid OSGi & Node-RED platform - Bruce Jackso...
PDF
How to connect your OSGi application - Dirk Fauth (Bosch)
Eclipse Modeling Framework and plain OSGi the easy way - Mark Hoffman (Data I...
OSGi and Java 9+ - BJ Hargrave (IBM)
Simplify Web UX Coding using OSGi Modularity Magic - Paul Fraser (A2Z Living)
OSGi for the data centre - Connecting OSGi to Kubernetes - Frank Lyaruu
Remote Management and Monitoring of Distributed OSGi Applications - Tim Verbe...
OSGi with Docker - a powerful way to develop Java systems - Udo Hafermann (So...
A real world use case with OSGi R7 - Jurgen Albert (Data In Motion Consulting...
OSGi Feature Model - Where Art Thou - David Bosschaert (Adobe)
Migrating from PDE to Bndtools in Practice - Amit Kumar Mondal (Deutsche Tele...
OSGi CDI Integration Specification - Ray Augé (Liferay)
How OSGi drives cross-sector energy management - Jörn Tümmler (SMA Solar Tech...
Improved developer productivity thanks to Maven and OSGi - Lukasz Dywicki (Co...
It Was Twenty Years Ago Today - Building an OSGi based Smart Home System - Ch...
Popular patterns revisited on OSGi - Christian Schneider (Adobe)
Integrating SLF4J and the new OSGi LogService 1.4 - BJ Hargrave (IBM)
OSG(a)i: because AI needs a runtime - Tim Verbelen (imec)
Flying to Jupiter with OSGi - Tony Walsh (ESA) & Hristo Indzhov (Telespazio V...
MicroProfile, OSGi was meant for this - Ray Auge (Liferay)
Prototyping IoT systems with a hybrid OSGi & Node-RED platform - Bruce Jackso...
How to connect your OSGi application - Dirk Fauth (Bosch)

Recently uploaded (20)

PDF
Network Security Unit 5.pdf for BCA BBA.
PPTX
Spectroscopy.pptx food analysis technology
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Machine learning based COVID-19 study performance prediction
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
Big Data Technologies - Introduction.pptx
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Spectral efficient network and resource selection model in 5G networks
PPTX
MYSQL Presentation for SQL database connectivity
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Network Security Unit 5.pdf for BCA BBA.
Spectroscopy.pptx food analysis technology
Advanced methodologies resolving dimensionality complications for autism neur...
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
The AUB Centre for AI in Media Proposal.docx
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Machine learning based COVID-19 study performance prediction
sap open course for s4hana steps from ECC to s4
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Per capita expenditure prediction using model stacking based on satellite ima...
Big Data Technologies - Introduction.pptx
20250228 LYD VKU AI Blended-Learning.pptx
Digital-Transformation-Roadmap-for-Companies.pptx
Chapter 3 Spatial Domain Image Processing.pdf
NewMind AI Weekly Chronicles - August'25 Week I
Spectral efficient network and resource selection model in 5G networks
MYSQL Presentation for SQL database connectivity
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx

Building Modular Enterprise Applications - C Ziegeler

  • 1. © 2014 Adobe Systems Incorporated. All Rights Reserved. Building Modular Enterprise Applications Carsten Ziegeler | Adobe Research Switzerland 1
  • 2. © 2014 Adobe Systems Incorporated. All Rights Reserved. About carsten.ziegeler@adobe.com @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
  • 3. © 2014 Adobe Systems Incorporated. All Rights Reserved. Motivation §  Enjoy the power of modularity §  OSGi is everywhere §  From embedded systems to enterprise applications and THE CLOUD §  Adapting a technology is always a challenge §  Common pitfalls §  Potential solutions 3
  • 4. © 2014 Adobe Systems Incorporated. All Rights Reserved. But wait a second… §  Adobe & OSGi ? 4
  • 5. © 2014 Adobe Systems Incorporated. All Rights Reserved. But wait a second… §  Adobe & OSGi ? 5
  • 6. © 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe & OSGi & Open Source & Open Development §  Using OSGi in various products §  Strategic member of the OSGi Alliance §  Board of directors §  Participating in CPEG and EEG §  Highly contributing to open source §  Especially Apache Software Foundation §  Participating in open standards §  Embracing open development 6
  • 7. © 2014 Adobe Systems Incorporated. All Rights Reserved. Case Study: The Development of Adobe Experience Manager 7
  • 8. © 2014 Adobe Systems Incorporated. All Rights Reserved. Back to the Future: Web Content Management Code History 8
  • 9. © 2014 Adobe Systems Incorporated. All Rights Reserved. Back in the Days…CQ 4 9
  • 10. © 2014 Adobe Systems Incorporated. All Rights Reserved. OSGi based Enterprise Web Content Management – Adobe CQ5 10
  • 11. © 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Experience Manager 11
  • 12. © 2014 Adobe Systems Incorporated. All Rights Reserved. Motivations for Going Modular (2006) §  Aged code base §  Monolithic §  Highly entangled §  Growing complexity and functionality §  No clear separation between API and implementation §  Increasing customer base §  Team growth 12
  • 13. © 2014 Adobe Systems Incorporated. All Rights Reserved. Modularity is Key §  Manage growing complexity §  Support dynamic extensibility §  Define contracts between modules 13
  • 14. © 2014 Adobe Systems Incorporated. All Rights Reserved. Potential Solutions (2006) §  Spring? §  OSGi? §  Other open source component frameworks? §  DIY? 14
  • 15. © 2014 Adobe Systems Incorporated. All Rights Reserved. Benefits of OSGi §  OSGi modules = bundles §  jars with strict enforcements §  Exported packages with version §  Imported packages with version range §  Private packages §  Service Registry §  Separation of Concerns §  Loose coupling 15
  • 16. © 2014 Adobe Systems Incorporated. All Rights Reserved. Modularity - How do we get there? (2006) §  Start with a single big bundle? §  Embedding OSGi framework? §  Complete rewrite? 16
  • 17. © 2014 Adobe Systems Incorporated. All Rights Reserved. The Fun Way : Complete Rewrite §  New architecture §  New backend (Apache Jackrabbit) §  New web application framework (Apache Sling) §  New UI §  Build modules from the start §  Control evolution §  (Provide tools for migration from old solution) 17
  • 18. © 2014 Adobe Systems Incorporated. All Rights Reserved. OSGi and Open Source (2006) §  Apache Felix §  Equinox 18
  • 19. © 2014 Adobe Systems Incorporated. All Rights Reserved. Framework runs and now? §  We need bundles! §  Build tools §  Ant? (BND) §  Maven? (Apache Felix Maven Bundle Plugin) 19
  • 20. © 2014 Adobe Systems Incorporated. All Rights Reserved. Maven Bundle Plugin (2007) §  Specifying all OSGi metadata in the POM §  Exported packages §  Private packages §  Imported packages and versions get calculated §  Parent POM to define rules for bundle symbolic name 20
  • 21. © 2014 Adobe Systems Incorporated. All Rights Reserved. Maven Bundle Plugin – First problems §  Specifying all OSGi metadata in the POM §  Exported packages §  Private packages §  Imported packages and versions get calculated §  Parent POM to define rules for bundle symbolic name §  Exported package version = POM version §  New private package needs updating the pom §  Slight difference in version handling between OSGi and Maven (The SNAPSHOT problem) §  2.0.1 < (OSGi) 2.0.1-SNAPSHOT < (Maven) 2.0.1 §  Semantic versioning? 21
  • 22. © 2014 Adobe Systems Incorporated. All Rights Reserved. Excursion on Versioning §  Marketing Versions vs. Engineering Versions §  Versioning Package Exports §  Engineering Versions §  Apply versions ! §  Semantic Versioning crucial §  Bundle Versions §  Grey area §  Semantic Versioning helpful §  Application Versions §  Marketing Versions 22
  • 23. © 2014 Adobe Systems Incorporated. All Rights Reserved. Versioning Best Practice §  Package Exports §  Always apply a version to package exports §  Start with 1.0 §  Only increment when changing the API §  Think hard before increasing the major version ! §  Package Imports §  Ensure proper version range import 23
  • 24. © 2014 Adobe Systems Incorporated. All Rights Reserved. Semantic Versioning §  Nice whitepaper on the OSGi homepage §  Versioning policy for exported packages §  OSGi versions: <major>.<minor>.<micro>.<qualifier> §  Updating package versions: §  Fix/patch (no API change) : update micro §  Extend API (affects implementers, not clients) : update minor §  API breakage: update major 24
  • 25. © 2014 Adobe Systems Incorporated. All Rights Reserved. Versioning Annotations §  BND or new with OSGi R6 §  Annotations for documenting semantic versioning information §  @Version §  @ProviderType §  @ConsumerType 25
  • 26. © 2014 Adobe Systems Incorporated. All Rights Reserved. Versioning Best Practice (cont.) §  Bundle Versions §  Always use and manage bundle version §  Align bundle version with Maven version §  Use odd micro versions for SNAPSHOTs §  e.g. 0.0.1-SNAPSHOT, 1.3.5-SNAPSHOT §  Use even micro versions for release §  e.g. 1.0.0, 1.3.6 §  Dependencies §  Always use least required version for dependencies 26
  • 27. © 2014 Adobe Systems Incorporated. All Rights Reserved. Maven Bundle Plugin – Today §  Specifying all OSGi metadata in the POM §  Exported packages §  Private packages §  Imported packages and versions get calculated §  Parent POM to define rules for bundle symbolic name §  Parent POM to define rules for bundle symbolic name and private packages §  No package versioning information in POM (annotations) §  Follow semantic versioning §  Odd/even versioning policy §  Usually no OSGI metadata in the POM 27
  • 28. © 2014 Adobe Systems Incorporated. All Rights Reserved. What about Components and Services (2007)? §  Framework API is usually too low level §  Make development as easy as possible §  Try to hide dynamics §  And there are OSGi compendium specs §  Declarative Services §  Configuration Admin §  Metatype 28
  • 29. © 2014 Adobe Systems Incorporated. All Rights Reserved. Component Development with Declarative Services §  Declarative Services (OSGi Compendium Spec) §  Defines Service Component Runtime (SCR) §  Declarative component model §  XML descriptor for components including §  Provided services §  References to other services §  Configuration properties 29
  • 30. © 2014 Adobe Systems Incorporated. All Rights Reserved. Configuration Admin •  OSGi Configuration Admin •  “The” solution to handle configurations •  Configuration Manager •  Persistence storage •  Service API to retrieve/update/remove configuration •  OSGi Metatype Service •  Description of bundle metadata •  Description of service configurations •  Property type, name, and description 30
  • 31. © 2014 Adobe Systems Incorporated. All Rights Reserved. What about Components and Services (2007)? §  Framework API is usually too low level §  And there are OSGi compendium specs §  Declarative Services §  Configuration Admin §  Metatype §  No (Apache) open source implementations available §  Nearly no tooling §  Declarative Services uses XML descriptors §  Metatype uses XML descriptors and property files 31
  • 32. © 2014 Adobe Systems Incorporated. All Rights Reserved. DIY – Donations to Apache Felix §  Apache Felix SCR (Declarative Service Implementation) §  Apache Felix Config Admin §  Apache Felix Metatype §  Apache Felix Preferences §  Apache Felix SCR Tooling §  Java annotations for generating DS and Metatype descriptors §  Maven, ANT, BND 32
  • 33. © 2014 Adobe Systems Incorporated. All Rights Reserved. Component Development with Declarative Services §  Declarative Services (OSGi Compendium Spec) §  Defines Service Component Runtime (SCR) §  Apache Felix SCR Annotations (DS annotations) §  Some advantages (in combination with the tooling) §  POJO style §  Declarative §  Single source: just the Java code, no XML etc. §  "Integration" with Configuration Admin and Metatype Service 33
  • 34. © 2014 Adobe Systems Incorporated. All Rights Reserved. Components and Services with OSGi §  Service interface §  Public (if exported for other bundles) §  Versioned through package version (Semantic versioning) §  Private for internal services (sometimes useful) §  Component / service implementation §  Always private 34
  • 35. © 2014 Adobe Systems Incorporated. All Rights Reserved. My First Component 35 package com.adobe.osgitraining.impl; import org.apache.felix.scr.annotations.Component; @Component public class MyComponent { }
  • 36. © 2014 Adobe Systems Incorporated. All Rights Reserved. Component Lifecycle 36 package com.adobe.osgitraining.impl; import org.apache.felix.scr.annotations.Activate; import org.apache.felix.scr.annotations.Component; import org.apache.felix.scr.annotations.Deactivate; @Component public class MyComponent { @Activate protected void activate() { // do something } @Deactivate protected void deactivate() { // do something } }
  • 37. © 2014 Adobe Systems Incorporated. All Rights Reserved. Providing a Service 37 package com.adobe.osgitraining.impl; import org.apache.felix.scr.annotations.Component; import org.apache.felix.scr.annotations.Service; import org.osgi.service.event.EventHandler; @Component @Service(value=EventHandler.class) public class MyComponent implements EventHandler { …
  • 38. © 2014 Adobe Systems Incorporated. All Rights Reserved. Using a Service 38 package com.adobe.osgitraining.impl; import org.apache.felix.scr.annotations.Component; import org.apache.felix.scr.annotations.Service; import org.osgi.service.event.EventHandler; @Component @Service(value=EventHandler.class) public class MyComponent implements EventHandler { @Reference privateTThreadPool threadPool; …
  • 39. © 2014 Adobe Systems Incorporated. All Rights Reserved. Using an Optional Service 39 package com.adobe.osgitraining.impl; import org.apache.felix.scr.annotations.Component; import org.apache.felix.scr.annotations.Service; import org.osgi.service.event.EventHandler; @Component @Service(value=EventHandler.class) public class MyComponent implements EventHandler { @Reference(cardinality=ReferenceCardinality.OPTIONAL_UNARY, policy=ReferencePolicy.DYNAMIC) private volatileTThreadPool threadPool; @Reference(cardinality=ReferenceCardinality.MANDATORY_UNARY) privateTDistributor distributor;
  • 40. © 2014 Adobe Systems Incorporated. All Rights Reserved. Component Properties -> Service Properties 40 import org.apache.sling.commons.osgi.PropertiesUtil; @Component @Service(value=EventHandler.class) @Properties({ @Property(name="service.vendor", value="Who?”), @Property(name="service.ranking", intValue=500) }) public class DistributingEventHandler implements EventHandler {
  • 41. © 2014 Adobe Systems Incorporated. All Rights Reserved. Configuration Admin •  OSGi Configuration Admin •  “The” solution to handle configurations •  Configuration Manager •  Persistence storage •  Service API to retrieve/update/remove configuration •  Integration with Declarative Services •  Configuration changes are propagated to the components •  Configurations are stored using the PID 41
  • 42. © 2014 Adobe Systems Incorporated. All Rights Reserved. Configuration – Supports Configuration Admin §  Provided map contains §  Configuration properties from Configuration Admin §  Defined component properties 42 @Activate protected void activate(final Map<String, Object> props) { … }
  • 43. © 2014 Adobe Systems Incorporated. All Rights Reserved. Configuration – Supports Configuration Admin 43 import org.apache.sling.commons.osgi.PropertiesUtil; @Component @Service(value=EventHandler.class) @Properties({ @Property(name="event.topics", value="*", propertyPrivate=true), @Property(name="event.filter", value="(event.distribute=*)", propertyPrivate=true) }) public class DistributingEventHandler implements EventHandler { private static final int DEFAULT_CLEANUP_PERIOD = 15; @Property(intValue=DEFAULT_CLEANUP_PERIOD) private static final String PROP_CLEANUP_PERIOD ="cleanup.period"; private int cleanupPeriod; @Activate protected void activate(final Map<String, Object> props) { this.cleanupPeriod = PropertiesUtil.toInteger(props.get(PROP_CLEANUP_PERIOD)); }
  • 44. © 2014 Adobe Systems Incorporated. All Rights Reserved. Configuration Update 44 import org.apache.sling.commons.osgi.OsgiUtil; public class DistributingEventHandler implements EventHandler { … @Modified protected void update(final Map<String, Object> props) { this.cleanupPeriod = PropertiesUtil.toInteger(props.get(PROP_CLEANUP_PERIOD)); } Without @Modified: Component is restarted on config change!
  • 45. © 2014 Adobe Systems Incorporated. All Rights Reserved. Metatype §  OSGi Metatype Service §  Description of bundle metadata §  Description of service configurations §  Property type, name, and description 45
  • 46. © 2014 Adobe Systems Incorporated. All Rights Reserved. Configuration – Supports Metatype 46 import org.apache.sling.commons.osgi.PropertiesUtil; @Component(metatype=true, label="Distributing Event Handler", description="This handler is awesome.") @Properties({ @Property(name="event.topics", value="*", propertyPrivate=true) }) public class DistributingEventHandler implements EventHandler { private static final int DEFAULT_CLEANUP_PERIOD = 15; @Property(intValue=DEFAULT_CLEANUP_PERIOD, label="Cleanup Period", description="This is the cleanup period in seconds.") private static final String PROP_CLEANUP_PERIOD ="cleanup.period";
  • 47. © 2014 Adobe Systems Incorporated. All Rights Reserved. Component Development with Declarative Services §  Straight forward component development §  Single source of truth §  (Will even be easier with new Declarative Service spec from R6) §  Typical problems §  OSGi dynamics is hidden §  Handling references of cardinality multiple §  Copying of bad practices 47
  • 48. © 2014 Adobe Systems Incorporated. All Rights Reserved. And what about THE WEB? (2007) §  OSGi Http Service Specification §  Based on servlet API 2.1 §  Programmatic API to register servlets and resources §  Apache Felix HTTP implementation §  Later whiteboard support in Apache Felix implementation for §  Servlets §  Filters §  Some listeners 48
  • 49. © 2014 Adobe Systems Incorporated. All Rights Reserved. And what about THE WEB? §  OSGi Http Service Specification §  Based on servlet API 2.1 §  Programmatic API to register servlets and resources §  Apache Felix HTTP implementation §  Invented Apache Sling Web Framework §  Resource based approach §  Scripting §  Written as OSGi bundles §  Later whiteboard support in Apache Felix implementation for §  Servlets §  Filters §  Some listeners §  New OSGi Http Whiteboard Service Spec in R6 49
  • 50. © 2014 Adobe Systems Incorporated. All Rights Reserved. But what about Provisioning and Deliverables? (2007) §  Wishes §  Single definition of deliverable (bundles, configurations, proprietary packages) §  Different flavors: web application, standalone §  Easy and flexible updates 50
  • 51. © 2014 Adobe Systems Incorporated. All Rights Reserved. But what about Provisioning and Deliverables? (2007) §  Wishes §  Single definition of deliverable (bundles, configurations, proprietary packages) §  Different flavors: web application, standalone §  Easy and flexible updates §  No open source solution available 51
  • 52. © 2014 Adobe Systems Incorporated. All Rights Reserved. Contributing Apache Sling Launchpad Ecosystem §  Creating a distribution is easy §  Standalone jar file and/or web application §  Maven Launchpad Plugin §  Define bundle list §  Add other artifacts §  Configurations §  Leverages Apache Sling’s OSGi installer 52
  • 53. © 2014 Adobe Systems Incorporated. All Rights Reserved. Bundle List Example 53 <?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>
  • 54. © 2014 Adobe Systems Incorporated. All Rights Reserved. Apache Sling Launchpad §  Bootstrap code §  Includes Apache Felix §  Handles framework updates §  Launch an OSGi framework §  Standalone jar with http service §  As a web application with http bridge §  Deploy packaged artifacts §  Configurable §  sling.properties §  (system properties / servlet parameters) 54
  • 55. © 2014 Adobe Systems Incorporated. All Rights Reserved. OSGi Standalone App or OSGi Webapp with Launchpad 55 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 / OSGi HTTP Service sling.properties Deployable Artifacts WE I R N IR JO S- H BA B G S EL @AD OBE
  • 56. © 2014 Adobe Systems Incorporated. All Rights Reserved. Apache Sling OSGi Installer §  General service covering §  Install §  Update §  Uninstall §  Of §  Bundles §  Configurations §  Custom artifacts 56
  • 57. © 2014 Adobe Systems Incorporated. All Rights Reserved. Apache Sling OSGi Installer 57 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
  • 58. © 2014 Adobe Systems Incorporated. All Rights Reserved. Advantages of the OSGi Installer Family §  Pluggable and highly customizable §  New artifact types: transformer + task factory §  New artifact sources: provider §  Batch handling §  Retry mechanism in the installer core §  Bundle installation order doesn’t matter §  State management in the installer core §  Defined workflow §  Copes with 3rd party changes 58
  • 59. © 2014 Adobe Systems Incorporated. All Rights Reserved. Running Deliverables and what about administration? (2007) §  Nothing really available in the open source world §  Especially not web based 59
  • 60. © 2014 Adobe Systems Incorporated. All Rights Reserved. Donating Apache Felix Web Console + Plugins §  Rich set of core functionality §  Bundles §  Services §  Configuration Admin §  System Information §  (JQuery based UI) §  Extensible §  Pluggable authentication §  Still light-weight §  REST interface 60
  • 61. © 2014 Adobe Systems Incorporated. All Rights Reserved. Web Console Demo I 61
  • 62. © 2014 Adobe Systems Incorporated. All Rights Reserved. Web Console Demo II 62
  • 63. © 2014 Adobe Systems Incorporated. All Rights Reserved. Web Console Demo III 63
  • 64. © 2014 Adobe Systems Incorporated. All Rights Reserved. Web Console - Offline Usage §  Status zip contains §  Output from all inventory printers §  Output from special web console plugins §  Attachments §  JSON files §  Automated analysis §  Bundle list and status §  Configurations §  Log files 64
  • 65. © 2014 Adobe Systems Incorporated. All Rights Reserved. Problems solved… §  Modularity §  OSGi bundles §  Semantic versioning §  Services and components §  Development §  Frameworks and tooling §  Deliverables and provisioning §  Administration 65
  • 66. © 2014 Adobe Systems Incorporated. All Rights Reserved. Hitting the Real World – 3rd Party Libraries §  Use them as bundles §  Project delivers already a bundle §  Apache Commons, Apache Sling etc. §  Use special bundle repositories §  Apache Felix Commons, Spring etc. §  But check included metadata! §  Create your own wrapper §  Easy with the Felix maven bundle plugin §  Include classes in your bundle §  Again: easy with the Felix maven bundle plugin §  Convince the projects to provide useful OSGi metadata! 66
  • 67. © 2014 Adobe Systems Incorporated. All Rights Reserved. Hitting the Real World – "Enterprise" Requirements §  Testing under high load / high concurrency §  Reimplementing some (open source) modules §  Not every developer is aware that code can be called concurrently §  And how to solve this in an acceptable way §  Dynamic nature of OSGi §  Relatively painless with DS and annotations §  Gets trickier with plain framework API and/or cardinality multiple §  Again: concurrency 67
  • 68. © 2014 Adobe Systems Incorporated. All Rights Reserved. Hitting the Real World – All Time Favorites §  When is my system ready? §  Different strategies §  All bundles started and specific start level reached §  Special startup handler service for notification (Apache Sling) §  Fighting against FUD §  OSGi is slow, consumes too much memory, complicated, §  has no dependency injection, is not used in the enterprise… 68
  • 69. © 2014 Adobe Systems Incorporated. All Rights Reserved. Additional Challenges §  Clustering §  Discovery §  Distributed Eventing 69
  • 70. © 2014 Adobe Systems Incorporated. All Rights Reserved. On the Roadmap §  OSGi subsystems §  Grouping of bundles §  Export / import boundaries on subsystem level §  OSGi Remote Services §  OSGi Asynchronous Services §  OSGi Distributed Eventing 70
  • 71. © 2014 Adobe Systems Incorporated. All Rights Reserved. Think Modular… •  This is not a new concept or latest hype! •  Think about modularity! •  Create a clean package space •  What is your API? •  public vs private •  Make things only public if necessary/used •  Starting with private stuff going public is easy •  Use proper versioning contracts •  Semantic Versioning 71
  • 72. © 2014 Adobe Systems Incorporated. All Rights Reserved. …Be Modular! •  Provide bundles •  Add manifest information •  Think about dependencies •  Additional bundle vs include •  Optional •  Version ranges •  Manage releases and versions properly •  Benefits even without OSGi 72
  • 73. © 2014 Adobe Systems Incorporated. All Rights Reserved. Component Development §  Contract defined by service interface §  Declarative Services is a powerful component model §  Minimal OSGi knowledge required with available solutions §  Apache Felix SCR Tooling §  Alternatives available J §  Inter-operability through OSGi service registry 73
  • 74. © 2014 Adobe Systems Incorporated. All Rights Reserved. Conclusion §  Today a lot of the hard work is already done §  Open Source & Open Development are your friends §  OSGi made the Adobe Experience Manager success story possible §  Team growth from 40+ to several hundreds §  Immense growth in functionality §  Still (dynamically) extensible and manageable §  OSGi Core and Compendium provide nearly everything you need §  Framework, Declarative Services, Configuration Admin, Metatype, Event Admin §  Open Source Implementations and Extensions §  Apache Felix and friends 74
  • 75. © 2014 Adobe Systems Incorporated. All Rights Reserved. Check It Out! •  Read the OSGi specs •  Framework •  Declarative Services, Config Admin, Metatype, Event Admin •  Checkout the various Apache projects! •  Explore available tooling •  Embrace modularity! •  Join the OSGi Alliance and help shaping the future! 75
  • 76. © 2014 Adobe Systems Incorporated. All Rights Reserved. And…New OSGi Specifications! §  Last week (week of June 2nd) the OSGi Core Release 6 Specification received its final approval and will be available this week to the public for downloading. §  http://www.osgi.org/Specifications/HomePage §  Also happening last week, the OSGi Board of Directors approved the publication of an Early Draft Specification of OSGi Enterprise Release 6 for downloading. §  http://www.osgi.org/Specifications/Drafts 76
  • 77. © 2014 Adobe Systems Incorporated. All Rights Reserved. References §  OSGi Semantic Versioning Whitepaper: http://www.osgi.org/wiki/uploads/Links/SemanticVersioning.pdf §  OSGi Specifications: http://www.osgi.org §  Apache Felix: http://felix.apache.org §  Apache Sling: http://sling.apache.org §  Apache Aries: http://aries.apache.org §  BND: http://www.aqute.biz/Bnd/Bnd §  Bndtools: http://njbartlett.name/bndtools.html §  Planet OSGi: http://www.osgi.org/Planet/Feed 77
  • 78. © 2014 Adobe Systems Incorporated. All Rights Reserved.