SlideShare a Scribd company logo
1 of 39
Download to read offline
Dependencies, 
dependencies, 
dependencies 
Marcel Offermans 
TECHNOLOGIES
Marcel Offermans 
• Fellow and Software Architect at 
Luminis Technologies 
marcel.offermans@luminis.nl 
! 
•Member and Committer at 
Apache Software Foundation 
marrs@apache.org
Agenda 
• Introduction 
• Basic Concepts 
• Dependencies 
• Design Patterns 
• Custom Dependencies 
• Add-ons 
• Wrap-up 
Software distribution: 
copy both zip archives from the 
memory stick
Introduction
Framework 
Service 
Life$cycle 
Module 
Security 
OSGi$framework 
Bundle Bundle Bundle 
Java$Virtual$Machine
Service Dependencies 
• framework: ServiceListener 
– notification whenever there is a change 
in the service registry 
– but: only changes that occur while you 
are listening 
• utility: ServiceTracker 
– solves the listening issue 
– adds ability to customize services
Problem 
• using the framework supplied 
tooling, you are dealing with 
dependencies at a very low level 
• a lot of boiler plate code is needed 
to implement real world scenarios 
• there are very few design patterns 
that deal with composing an 
application based on services
Declaring your dependencies 
• Service Binder 
• Dependency Manager 
• Declarative Services 
• iPOJO 
• Blueprint 
• ...many more
Dependency Manager 
• Subproject of Apache Felix 
• Nearing a 3.0 release 
• Some interesting new features 
...I’m not unbiased, being it’s author
Basic Concepts
Basic Concepts 
• Component: class that implements 
certain behaviour (a POJO) 
• Dependency: something our 
component needs or wants (ie. a 
service) 
• Service: OSGi service interface(s) 
under which our component is 
registered
Declarative API 
• Declarative ≠ XML 
• Using a Java API has many 
advantages: 
– less error prone because of syntax and 
compile time checking 
– refactoring support, completion 
– very readable through fluid API 
– everything in one place, no magic
On the memory stick: 
! 
a) an Eclipse update site for BndTools 
b) a set of Eclipse projects 
Example code 
• Projects 
– Download: http://www.xs4all.nl/~mfo/projects.zip 
• Uses Eclipse + BndTools 
– Homepage: http://njbartlett.name/bndtools.html 
– Update Site: http://bndtools-updates.s3.amazonaws.com 
• Based on a snapshot release of the 
upcoming Dependency Manager 3.0 
• During the presentation, we will 
switch between slides and Eclipse to 
show running examples
Using the Dependency Manager 
Import-Package = org.apache.felix.dm;version="[3.0,4)" 
public class Activator extends DependencyActivatorBase { 
public void init(BundleContext context, DependencyManager manager) throws Exception { 
manager.add(createComponent() 
.setImplementation(new HelloWorld()) 
); 
} 
! 
public void destroy(BundleContext context, DependencyManager manager) throws Exception { 
} 
}
Basic Use Cases 
• Declare a component 
HelloWorld helloWorld = new HelloWorld(); 
manager.add(createComponent() 
! 
! 
! 
• Declare it lazily 
.setImplementation(helloWorld) 
); 
manager.add(createComponent() 
.setImplementation(HelloWorld.class) 
);
Component Life Cycle 
•methods of the component 
public static class HelloWorldLifeCycle { 
! 
! 
! 
• setCallbacks(“init”, “start”, ...) 
setCallbacks(inst, “init”, “start”, ...) 
private void init() { System.out.println("init"); } 
private void start() { System.out.println("start"); } 
private void stop() { System.out.println("stop"); } 
private void destroy() { System.out.println("destroy"); } 
} 
– to invoke the methods on ‘inst’ 
• ComponentStateListener 
– if you want to listen from the outside
Declaring as a service 
• setInterface(...) 
– allows you to declare multiple services 
– allows you to specify service properties 
manager.add(createComponent() 
.setInterface(LogService.class.getName(), 
new Properties() {{ put(Constants.SERVICE_RANKING, 20); }}) 
.setImplementation(MyLogService.class)
Declaring Dependencies 
• Adding a dependency 
manager.add(createComponent() 
! 
! 
! 
• Injects dependency 
.setImplementation(HelloWorldLogger.class) 
.add(createServiceDependency() 
.setService(LogService.class) 
) 
); 
– uses null object pattern 
– injects other “OSGi” instances 
• setCallbacks(...) 
setCallbacks(inst, ...)
Dependencies
Dependencies 
• Different types: 
– Service Dependencies 
– Configuration Dependencies 
– Bundle Dependencies 
– Resource Dependencies
Configuration Dependencies 
• Based on Configuration Admin 
– designed for required dependencies 
– service.pid to identify the configuration 
– allows you to only accept *valid* 
configurations 
•update() throws ConfigurationException
Bundle Dependencies 
• Depend on a bundle: 
– in certain states 
– with certain manifest entries 
• Bundle instance can be injected
Resource Dependencies 
• Resources are modeled as URLs 
• Are provided by a repository 
– another bundle 
– an Eclipse workspace 
– some external source 
• Filter on host, port, protocol, path 
and URL
Design Patterns
Design Patterns 
•Moving up a level in abstraction 
• OSGi is too low level to expose to 
everybody, but it is a great platform 
to build on 
• Patterns provide a common 
language and describe solutions in 
context
Overview of Design Patterns 
•Whiteboard Pattern 
• Null Object Pattern 
• “Singleton” Service 
• Aspect Service 
• Adapter Service 
• Resource Adapter Service
Whiteboard Pattern 
“don’t call us... 
we’ll call you”
Null Object Pattern 
• An object that implements a certain 
interface, can be safely invoked and 
does nothing
“Singleton” Service 
• Publishes a component as a service 
• Ties its life cycle to that of its 
dependencies 
Document 
Repository 
get() 
getVersions() 
get(version) 
store(Document) 
Singleton 
Storage 
requires
Aspect Service 
•Works at the service level 
• “intercepts” certain services 
• can be chained based on rankings 
• completely dynamic 
Repository Cache 
get() 
getVersions() 
get(version) 
store(Document) 
Aspect 
Repository 
get() 
getVersions() 
get(version) 
store(Document) 
intercepts
Adapter Service 
•Works on existing services 
• Adapts them, publishes a different 
service for each existing one 
Repository Cache 
Manageable 
getCacheHits() 
setSize() 
setTTL() 
flush() 
Adapter 
Repository Cache 
get() 
getVersions() 
get(version) 
store(Document) 
adapts
Resource Adapter Service 
• Adapts resources (instead of 
services) 
• Allows you to expose the behavior 
of certain resources instead of their 
“inner guts” 
Audio Track 
play() 
pause() 
stop() 
Resource 
Adapter 
MP3 
File 
adapts
Custom 
Dependencies
Custom Dependencies 
• Dependency Manager is extensible 
with custom dependencies: 
– depend on time of day 
– depend on some custom instance / 
condition (start level, app state)
Add-ons
Add-ons 
• Shell (Felix, Equinox, Gogo) 
• Annotation based (Java 5 required) 
• Legacy support (2.x API adapter)
Wrap-up
Wrap-up 
• Points to take away: 
– do not expose every developer to the 
OSGi API 
– build higher level abstractions, use 
design patterns 
– consider the dependency manager, it is 
very flexible
More about OSGi 
• ApacheCon 2010 North America 
November 1-5, Atlanta 
– OSGi tutorial 
– full day OSGi track 
•Masterclass on OSGi 
October 12-15, Girona 
– Neil Bartlett and Peter Kriens

More Related Content

What's hot

ASP.NET Core 1.0
ASP.NET Core 1.0ASP.NET Core 1.0
ASP.NET Core 1.0Ido Flatow
 
5 steps to take setting up a streamlined container pipeline
5 steps to take setting up a streamlined container pipeline5 steps to take setting up a streamlined container pipeline
5 steps to take setting up a streamlined container pipelineMichel Schildmeijer
 
Sebastien goasguen cloud stack the next year
Sebastien goasguen   cloud stack the next yearSebastien goasguen   cloud stack the next year
Sebastien goasguen cloud stack the next yearShapeBlue
 
OWIN and Katana Project - Not Only IIS - NoIIS
OWIN and Katana Project - Not Only IIS - NoIISOWIN and Katana Project - Not Only IIS - NoIIS
OWIN and Katana Project - Not Only IIS - NoIISBilal Haidar
 
Introduction to Systems Management with SaltStack
Introduction to Systems Management with SaltStackIntroduction to Systems Management with SaltStack
Introduction to Systems Management with SaltStackCraig Sebenik
 
Oracle SOA suite and Coherence dehydration
Oracle SOA suite and  Coherence dehydrationOracle SOA suite and  Coherence dehydration
Oracle SOA suite and Coherence dehydrationMichel Schildmeijer
 
Extending Alfresco Digital Workspace with Docusign
Extending Alfresco Digital Workspace with DocusignExtending Alfresco Digital Workspace with Docusign
Extending Alfresco Digital Workspace with DocusignLuis Colorado
 
ContainerDays NYC 2015: "Container Orchestration Compared: Kubernetes and Doc...
ContainerDays NYC 2015: "Container Orchestration Compared: Kubernetes and Doc...ContainerDays NYC 2015: "Container Orchestration Compared: Kubernetes and Doc...
ContainerDays NYC 2015: "Container Orchestration Compared: Kubernetes and Doc...DynamicInfraDays
 
Productivity Acceleration Tools for SOA Testers
Productivity Acceleration Tools for SOA TestersProductivity Acceleration Tools for SOA Testers
Productivity Acceleration Tools for SOA TestersWSO2
 
Exploring Openstack Swift(Object Storage) and Swiftstack
Exploring Openstack Swift(Object Storage) and Swiftstack Exploring Openstack Swift(Object Storage) and Swiftstack
Exploring Openstack Swift(Object Storage) and Swiftstack Ramit Surana
 
Netflix0SS Services on Docker
Netflix0SS Services on DockerNetflix0SS Services on Docker
Netflix0SS Services on DockerDocker, Inc.
 
Sebastien goasguen cloud stack and docker
Sebastien goasguen   cloud stack and dockerSebastien goasguen   cloud stack and docker
Sebastien goasguen cloud stack and dockerShapeBlue
 
OpenStack Introduction
OpenStack IntroductionOpenStack Introduction
OpenStack Introductionopenstackindia
 
Alfresco Transform Service DevCon 2019
Alfresco Transform Service DevCon 2019Alfresco Transform Service DevCon 2019
Alfresco Transform Service DevCon 2019J V
 
Laravel introduction
Laravel introductionLaravel introduction
Laravel introductionSimon Funk
 
Microservices with docker swarm and consul
Microservices with docker swarm and consulMicroservices with docker swarm and consul
Microservices with docker swarm and consulNguyen Sy Thanh Son
 

What's hot (20)

ASP.NET Core 1.0
ASP.NET Core 1.0ASP.NET Core 1.0
ASP.NET Core 1.0
 
5 steps to take setting up a streamlined container pipeline
5 steps to take setting up a streamlined container pipeline5 steps to take setting up a streamlined container pipeline
5 steps to take setting up a streamlined container pipeline
 
Owin and katana
Owin and katanaOwin and katana
Owin and katana
 
Sebastien goasguen cloud stack the next year
Sebastien goasguen   cloud stack the next yearSebastien goasguen   cloud stack the next year
Sebastien goasguen cloud stack the next year
 
OWIN and Katana Project - Not Only IIS - NoIIS
OWIN and Katana Project - Not Only IIS - NoIISOWIN and Katana Project - Not Only IIS - NoIIS
OWIN and Katana Project - Not Only IIS - NoIIS
 
Introduction to Systems Management with SaltStack
Introduction to Systems Management with SaltStackIntroduction to Systems Management with SaltStack
Introduction to Systems Management with SaltStack
 
Oracle SOA suite and Coherence dehydration
Oracle SOA suite and  Coherence dehydrationOracle SOA suite and  Coherence dehydration
Oracle SOA suite and Coherence dehydration
 
Extending Alfresco Digital Workspace with Docusign
Extending Alfresco Digital Workspace with DocusignExtending Alfresco Digital Workspace with Docusign
Extending Alfresco Digital Workspace with Docusign
 
ContainerDays NYC 2015: "Container Orchestration Compared: Kubernetes and Doc...
ContainerDays NYC 2015: "Container Orchestration Compared: Kubernetes and Doc...ContainerDays NYC 2015: "Container Orchestration Compared: Kubernetes and Doc...
ContainerDays NYC 2015: "Container Orchestration Compared: Kubernetes and Doc...
 
Introduction to OWIN
Introduction to OWINIntroduction to OWIN
Introduction to OWIN
 
Upgrading to Alfresco 6
Upgrading to Alfresco 6Upgrading to Alfresco 6
Upgrading to Alfresco 6
 
Productivity Acceleration Tools for SOA Testers
Productivity Acceleration Tools for SOA TestersProductivity Acceleration Tools for SOA Testers
Productivity Acceleration Tools for SOA Testers
 
Exploring Openstack Swift(Object Storage) and Swiftstack
Exploring Openstack Swift(Object Storage) and Swiftstack Exploring Openstack Swift(Object Storage) and Swiftstack
Exploring Openstack Swift(Object Storage) and Swiftstack
 
Netflix0SS Services on Docker
Netflix0SS Services on DockerNetflix0SS Services on Docker
Netflix0SS Services on Docker
 
Sebastien goasguen cloud stack and docker
Sebastien goasguen   cloud stack and dockerSebastien goasguen   cloud stack and docker
Sebastien goasguen cloud stack and docker
 
OpenStack Introduction
OpenStack IntroductionOpenStack Introduction
OpenStack Introduction
 
Deploying a secured Flink cluster on Kubernetes
Deploying a secured Flink cluster on KubernetesDeploying a secured Flink cluster on Kubernetes
Deploying a secured Flink cluster on Kubernetes
 
Alfresco Transform Service DevCon 2019
Alfresco Transform Service DevCon 2019Alfresco Transform Service DevCon 2019
Alfresco Transform Service DevCon 2019
 
Laravel introduction
Laravel introductionLaravel introduction
Laravel introduction
 
Microservices with docker swarm and consul
Microservices with docker swarm and consulMicroservices with docker swarm and consul
Microservices with docker swarm and consul
 

Viewers also liked

OO Development 3 - Models And UML
OO Development 3 - Models And UMLOO Development 3 - Models And UML
OO Development 3 - Models And UMLRandy Connolly
 
M02 Uml Overview
M02 Uml OverviewM02 Uml Overview
M02 Uml OverviewDang Tuan
 
8 abstract classes and interfaces
8   abstract classes and interfaces 8   abstract classes and interfaces
8 abstract classes and interfaces Tuan Ngo
 

Viewers also liked (8)

Itt1 sd uml and oo
Itt1 sd uml and ooItt1 sd uml and oo
Itt1 sd uml and oo
 
JavaYDL15
JavaYDL15JavaYDL15
JavaYDL15
 
OO & UML
OO & UMLOO & UML
OO & UML
 
Wrapper classes
Wrapper classesWrapper classes
Wrapper classes
 
OO Development 3 - Models And UML
OO Development 3 - Models And UMLOO Development 3 - Models And UML
OO Development 3 - Models And UML
 
System software
System softwareSystem software
System software
 
M02 Uml Overview
M02 Uml OverviewM02 Uml Overview
M02 Uml Overview
 
8 abstract classes and interfaces
8   abstract classes and interfaces 8   abstract classes and interfaces
8 abstract classes and interfaces
 

Similar to Dependencies, dependencies, dependencies

OSGi Community Event 2010 - Dependencies, dependencies, dependencies
OSGi Community Event 2010 - Dependencies, dependencies, dependenciesOSGi Community Event 2010 - Dependencies, dependencies, dependencies
OSGi Community Event 2010 - Dependencies, dependencies, dependenciesmfrancis
 
Automatically Managing Service Dependencies in an OSGi Environment - Marcel O...
Automatically Managing Service Dependencies in an OSGi Environment - Marcel O...Automatically Managing Service Dependencies in an OSGi Environment - Marcel O...
Automatically Managing Service Dependencies in an OSGi Environment - Marcel O...mfrancis
 
DevOps with Elastic Beanstalk - TCCC-2014
DevOps with Elastic Beanstalk - TCCC-2014DevOps with Elastic Beanstalk - TCCC-2014
DevOps with Elastic Beanstalk - TCCC-2014scolestock
 
CTS2 Development Framework
CTS2 Development FrameworkCTS2 Development Framework
CTS2 Development Frameworkcts2framework
 
Habitat talk at CodeMonsters Sofia, Bulgaria Nov 27 2018
Habitat talk at CodeMonsters Sofia, Bulgaria Nov 27 2018Habitat talk at CodeMonsters Sofia, Bulgaria Nov 27 2018
Habitat talk at CodeMonsters Sofia, Bulgaria Nov 27 2018Mandi Walls
 
Deep Dive: Alfresco Core Repository (... embedded in a micro-services style a...
Deep Dive: Alfresco Core Repository (... embedded in a micro-services style a...Deep Dive: Alfresco Core Repository (... embedded in a micro-services style a...
Deep Dive: Alfresco Core Repository (... embedded in a micro-services style a...J V
 
The Meteor Framework
The Meteor FrameworkThe Meteor Framework
The Meteor FrameworkDamien Magoni
 
Devops continuousintegration and deployment onaws puttingmoneybackintoyourmis...
Devops continuousintegration and deployment onaws puttingmoneybackintoyourmis...Devops continuousintegration and deployment onaws puttingmoneybackintoyourmis...
Devops continuousintegration and deployment onaws puttingmoneybackintoyourmis...Emerson Eduardo Rodrigues Von Staffen
 
DevOps, Continuous Integration and Deployment on AWS: Putting Money Back into...
DevOps, Continuous Integration and Deployment on AWS: Putting Money Back into...DevOps, Continuous Integration and Deployment on AWS: Putting Money Back into...
DevOps, Continuous Integration and Deployment on AWS: Putting Money Back into...Amazon Web Services
 
Day 3 - DevOps Culture - Continuous Integration & Continuous Deployment on th...
Day 3 - DevOps Culture - Continuous Integration & Continuous Deployment on th...Day 3 - DevOps Culture - Continuous Integration & Continuous Deployment on th...
Day 3 - DevOps Culture - Continuous Integration & Continuous Deployment on th...Amazon Web Services
 
HOW TO DRONE.IO IN CI/CD WORLD
HOW TO DRONE.IO IN CI/CD WORLDHOW TO DRONE.IO IN CI/CD WORLD
HOW TO DRONE.IO IN CI/CD WORLDAleksandr Maklakov
 
Introduction to Kubernetes
Introduction to KubernetesIntroduction to Kubernetes
Introduction to KubernetesVishal Biyani
 
Serverless Framework Workshop - Tyler Hendrickson, Chicago/burbs
 Serverless Framework Workshop - Tyler Hendrickson, Chicago/burbs Serverless Framework Workshop - Tyler Hendrickson, Chicago/burbs
Serverless Framework Workshop - Tyler Hendrickson, Chicago/burbsAWS Chicago
 
Integrating Infrastructure as Code into a Continuous Delivery Pipeline | AWS ...
Integrating Infrastructure as Code into a Continuous Delivery Pipeline | AWS ...Integrating Infrastructure as Code into a Continuous Delivery Pipeline | AWS ...
Integrating Infrastructure as Code into a Continuous Delivery Pipeline | AWS ...Amazon Web Services
 

Similar to Dependencies, dependencies, dependencies (20)

OSGi Community Event 2010 - Dependencies, dependencies, dependencies
OSGi Community Event 2010 - Dependencies, dependencies, dependenciesOSGi Community Event 2010 - Dependencies, dependencies, dependencies
OSGi Community Event 2010 - Dependencies, dependencies, dependencies
 
Automatically Managing Service Dependencies in an OSGi Environment - Marcel O...
Automatically Managing Service Dependencies in an OSGi Environment - Marcel O...Automatically Managing Service Dependencies in an OSGi Environment - Marcel O...
Automatically Managing Service Dependencies in an OSGi Environment - Marcel O...
 
DevOps with Elastic Beanstalk - TCCC-2014
DevOps with Elastic Beanstalk - TCCC-2014DevOps with Elastic Beanstalk - TCCC-2014
DevOps with Elastic Beanstalk - TCCC-2014
 
CTS2 Development Framework
CTS2 Development FrameworkCTS2 Development Framework
CTS2 Development Framework
 
Habitat talk at CodeMonsters Sofia, Bulgaria Nov 27 2018
Habitat talk at CodeMonsters Sofia, Bulgaria Nov 27 2018Habitat talk at CodeMonsters Sofia, Bulgaria Nov 27 2018
Habitat talk at CodeMonsters Sofia, Bulgaria Nov 27 2018
 
ITB2017 - Keynote
ITB2017 - KeynoteITB2017 - Keynote
ITB2017 - Keynote
 
OSGi bootcamp - part 2
OSGi bootcamp - part 2OSGi bootcamp - part 2
OSGi bootcamp - part 2
 
Deep Dive: Alfresco Core Repository (... embedded in a micro-services style a...
Deep Dive: Alfresco Core Repository (... embedded in a micro-services style a...Deep Dive: Alfresco Core Repository (... embedded in a micro-services style a...
Deep Dive: Alfresco Core Repository (... embedded in a micro-services style a...
 
Managing Your Cloud Assets
Managing Your Cloud AssetsManaging Your Cloud Assets
Managing Your Cloud Assets
 
Liferay (DXP) 7 Tech Meetup for Developers
Liferay (DXP) 7 Tech Meetup for DevelopersLiferay (DXP) 7 Tech Meetup for Developers
Liferay (DXP) 7 Tech Meetup for Developers
 
DevOps on AWS
DevOps on AWSDevOps on AWS
DevOps on AWS
 
The Meteor Framework
The Meteor FrameworkThe Meteor Framework
The Meteor Framework
 
Devops continuousintegration and deployment onaws puttingmoneybackintoyourmis...
Devops continuousintegration and deployment onaws puttingmoneybackintoyourmis...Devops continuousintegration and deployment onaws puttingmoneybackintoyourmis...
Devops continuousintegration and deployment onaws puttingmoneybackintoyourmis...
 
DevOps, Continuous Integration and Deployment on AWS: Putting Money Back into...
DevOps, Continuous Integration and Deployment on AWS: Putting Money Back into...DevOps, Continuous Integration and Deployment on AWS: Putting Money Back into...
DevOps, Continuous Integration and Deployment on AWS: Putting Money Back into...
 
Day 3 - DevOps Culture - Continuous Integration & Continuous Deployment on th...
Day 3 - DevOps Culture - Continuous Integration & Continuous Deployment on th...Day 3 - DevOps Culture - Continuous Integration & Continuous Deployment on th...
Day 3 - DevOps Culture - Continuous Integration & Continuous Deployment on th...
 
App fabric introduction
App fabric introductionApp fabric introduction
App fabric introduction
 
HOW TO DRONE.IO IN CI/CD WORLD
HOW TO DRONE.IO IN CI/CD WORLDHOW TO DRONE.IO IN CI/CD WORLD
HOW TO DRONE.IO IN CI/CD WORLD
 
Introduction to Kubernetes
Introduction to KubernetesIntroduction to Kubernetes
Introduction to Kubernetes
 
Serverless Framework Workshop - Tyler Hendrickson, Chicago/burbs
 Serverless Framework Workshop - Tyler Hendrickson, Chicago/burbs Serverless Framework Workshop - Tyler Hendrickson, Chicago/burbs
Serverless Framework Workshop - Tyler Hendrickson, Chicago/burbs
 
Integrating Infrastructure as Code into a Continuous Delivery Pipeline | AWS ...
Integrating Infrastructure as Code into a Continuous Delivery Pipeline | AWS ...Integrating Infrastructure as Code into a Continuous Delivery Pipeline | AWS ...
Integrating Infrastructure as Code into a Continuous Delivery Pipeline | AWS ...
 

More from Marcel Offermans

Building Secure OSGi Applications
Building Secure OSGi ApplicationsBuilding Secure OSGi Applications
Building Secure OSGi ApplicationsMarcel Offermans
 
OSGi on Google Android using Apache Felix
OSGi on Google Android using Apache FelixOSGi on Google Android using Apache Felix
OSGi on Google Android using Apache FelixMarcel Offermans
 
Component-based ontwikkelen met OSGi: van embedded tot enterprise
Component-based ontwikkelen met OSGi: van embedded tot enterpriseComponent-based ontwikkelen met OSGi: van embedded tot enterprise
Component-based ontwikkelen met OSGi: van embedded tot enterpriseMarcel Offermans
 
Modular Architectures using Micro Services
Modular Architectures using Micro ServicesModular Architectures using Micro Services
Modular Architectures using Micro ServicesMarcel Offermans
 
Felix HTTP - Paving the road to the future
Felix HTTP - Paving the road to the futureFelix HTTP - Paving the road to the future
Felix HTTP - Paving the road to the futureMarcel Offermans
 
Dynamic Deployment With Apache Felix
Dynamic Deployment With Apache FelixDynamic Deployment With Apache Felix
Dynamic Deployment With Apache FelixMarcel Offermans
 

More from Marcel Offermans (7)

De leukste Bug
De leukste BugDe leukste Bug
De leukste Bug
 
Building Secure OSGi Applications
Building Secure OSGi ApplicationsBuilding Secure OSGi Applications
Building Secure OSGi Applications
 
OSGi on Google Android using Apache Felix
OSGi on Google Android using Apache FelixOSGi on Google Android using Apache Felix
OSGi on Google Android using Apache Felix
 
Component-based ontwikkelen met OSGi: van embedded tot enterprise
Component-based ontwikkelen met OSGi: van embedded tot enterpriseComponent-based ontwikkelen met OSGi: van embedded tot enterprise
Component-based ontwikkelen met OSGi: van embedded tot enterprise
 
Modular Architectures using Micro Services
Modular Architectures using Micro ServicesModular Architectures using Micro Services
Modular Architectures using Micro Services
 
Felix HTTP - Paving the road to the future
Felix HTTP - Paving the road to the futureFelix HTTP - Paving the road to the future
Felix HTTP - Paving the road to the future
 
Dynamic Deployment With Apache Felix
Dynamic Deployment With Apache FelixDynamic Deployment With Apache Felix
Dynamic Deployment With Apache Felix
 

Recently uploaded

VictoriaMetrics Anomaly Detection Updates: Q1 2024
VictoriaMetrics Anomaly Detection Updates: Q1 2024VictoriaMetrics Anomaly Detection Updates: Q1 2024
VictoriaMetrics Anomaly Detection Updates: Q1 2024VictoriaMetrics
 
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full RecordingOpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full RecordingShane Coughlan
 
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxAndreas Kunz
 
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesAmazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesKrzysztofKkol1
 
Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Rob Geurden
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationBradBedford3
 
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfExploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfkalichargn70th171
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsChristian Birchler
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprisepreethippts
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identityteam-WIBU
 
What’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesWhat’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesVictoriaMetrics
 
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Cizo Technology Services
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Developmentvyaparkranti
 
2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shardsChristopher Curtin
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...confluent
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfMarharyta Nedzelska
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...OnePlan Solutions
 
Patterns for automating API delivery. API conference
Patterns for automating API delivery. API conferencePatterns for automating API delivery. API conference
Patterns for automating API delivery. API conferencessuser9e7c64
 
Understanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM ArchitectureUnderstanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM Architecturerahul_net
 

Recently uploaded (20)

VictoriaMetrics Anomaly Detection Updates: Q1 2024
VictoriaMetrics Anomaly Detection Updates: Q1 2024VictoriaMetrics Anomaly Detection Updates: Q1 2024
VictoriaMetrics Anomaly Detection Updates: Q1 2024
 
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full RecordingOpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
 
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
 
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesAmazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
 
Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion Application
 
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfExploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprise
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identity
 
What’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesWhat’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 Updates
 
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Development
 
2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdf
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
 
Patterns for automating API delivery. API conference
Patterns for automating API delivery. API conferencePatterns for automating API delivery. API conference
Patterns for automating API delivery. API conference
 
Understanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM ArchitectureUnderstanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM Architecture
 

Dependencies, dependencies, dependencies

  • 1. Dependencies, dependencies, dependencies Marcel Offermans TECHNOLOGIES
  • 2. Marcel Offermans • Fellow and Software Architect at Luminis Technologies marcel.offermans@luminis.nl ! •Member and Committer at Apache Software Foundation marrs@apache.org
  • 3. Agenda • Introduction • Basic Concepts • Dependencies • Design Patterns • Custom Dependencies • Add-ons • Wrap-up Software distribution: copy both zip archives from the memory stick
  • 5. Framework Service Life$cycle Module Security OSGi$framework Bundle Bundle Bundle Java$Virtual$Machine
  • 6. Service Dependencies • framework: ServiceListener – notification whenever there is a change in the service registry – but: only changes that occur while you are listening • utility: ServiceTracker – solves the listening issue – adds ability to customize services
  • 7. Problem • using the framework supplied tooling, you are dealing with dependencies at a very low level • a lot of boiler plate code is needed to implement real world scenarios • there are very few design patterns that deal with composing an application based on services
  • 8. Declaring your dependencies • Service Binder • Dependency Manager • Declarative Services • iPOJO • Blueprint • ...many more
  • 9. Dependency Manager • Subproject of Apache Felix • Nearing a 3.0 release • Some interesting new features ...I’m not unbiased, being it’s author
  • 11. Basic Concepts • Component: class that implements certain behaviour (a POJO) • Dependency: something our component needs or wants (ie. a service) • Service: OSGi service interface(s) under which our component is registered
  • 12. Declarative API • Declarative ≠ XML • Using a Java API has many advantages: – less error prone because of syntax and compile time checking – refactoring support, completion – very readable through fluid API – everything in one place, no magic
  • 13. On the memory stick: ! a) an Eclipse update site for BndTools b) a set of Eclipse projects Example code • Projects – Download: http://www.xs4all.nl/~mfo/projects.zip • Uses Eclipse + BndTools – Homepage: http://njbartlett.name/bndtools.html – Update Site: http://bndtools-updates.s3.amazonaws.com • Based on a snapshot release of the upcoming Dependency Manager 3.0 • During the presentation, we will switch between slides and Eclipse to show running examples
  • 14. Using the Dependency Manager Import-Package = org.apache.felix.dm;version="[3.0,4)" public class Activator extends DependencyActivatorBase { public void init(BundleContext context, DependencyManager manager) throws Exception { manager.add(createComponent() .setImplementation(new HelloWorld()) ); } ! public void destroy(BundleContext context, DependencyManager manager) throws Exception { } }
  • 15. Basic Use Cases • Declare a component HelloWorld helloWorld = new HelloWorld(); manager.add(createComponent() ! ! ! • Declare it lazily .setImplementation(helloWorld) ); manager.add(createComponent() .setImplementation(HelloWorld.class) );
  • 16. Component Life Cycle •methods of the component public static class HelloWorldLifeCycle { ! ! ! • setCallbacks(“init”, “start”, ...) setCallbacks(inst, “init”, “start”, ...) private void init() { System.out.println("init"); } private void start() { System.out.println("start"); } private void stop() { System.out.println("stop"); } private void destroy() { System.out.println("destroy"); } } – to invoke the methods on ‘inst’ • ComponentStateListener – if you want to listen from the outside
  • 17. Declaring as a service • setInterface(...) – allows you to declare multiple services – allows you to specify service properties manager.add(createComponent() .setInterface(LogService.class.getName(), new Properties() {{ put(Constants.SERVICE_RANKING, 20); }}) .setImplementation(MyLogService.class)
  • 18. Declaring Dependencies • Adding a dependency manager.add(createComponent() ! ! ! • Injects dependency .setImplementation(HelloWorldLogger.class) .add(createServiceDependency() .setService(LogService.class) ) ); – uses null object pattern – injects other “OSGi” instances • setCallbacks(...) setCallbacks(inst, ...)
  • 20. Dependencies • Different types: – Service Dependencies – Configuration Dependencies – Bundle Dependencies – Resource Dependencies
  • 21. Configuration Dependencies • Based on Configuration Admin – designed for required dependencies – service.pid to identify the configuration – allows you to only accept *valid* configurations •update() throws ConfigurationException
  • 22. Bundle Dependencies • Depend on a bundle: – in certain states – with certain manifest entries • Bundle instance can be injected
  • 23. Resource Dependencies • Resources are modeled as URLs • Are provided by a repository – another bundle – an Eclipse workspace – some external source • Filter on host, port, protocol, path and URL
  • 25. Design Patterns •Moving up a level in abstraction • OSGi is too low level to expose to everybody, but it is a great platform to build on • Patterns provide a common language and describe solutions in context
  • 26. Overview of Design Patterns •Whiteboard Pattern • Null Object Pattern • “Singleton” Service • Aspect Service • Adapter Service • Resource Adapter Service
  • 27. Whiteboard Pattern “don’t call us... we’ll call you”
  • 28. Null Object Pattern • An object that implements a certain interface, can be safely invoked and does nothing
  • 29. “Singleton” Service • Publishes a component as a service • Ties its life cycle to that of its dependencies Document Repository get() getVersions() get(version) store(Document) Singleton Storage requires
  • 30. Aspect Service •Works at the service level • “intercepts” certain services • can be chained based on rankings • completely dynamic Repository Cache get() getVersions() get(version) store(Document) Aspect Repository get() getVersions() get(version) store(Document) intercepts
  • 31. Adapter Service •Works on existing services • Adapts them, publishes a different service for each existing one Repository Cache Manageable getCacheHits() setSize() setTTL() flush() Adapter Repository Cache get() getVersions() get(version) store(Document) adapts
  • 32. Resource Adapter Service • Adapts resources (instead of services) • Allows you to expose the behavior of certain resources instead of their “inner guts” Audio Track play() pause() stop() Resource Adapter MP3 File adapts
  • 34. Custom Dependencies • Dependency Manager is extensible with custom dependencies: – depend on time of day – depend on some custom instance / condition (start level, app state)
  • 36. Add-ons • Shell (Felix, Equinox, Gogo) • Annotation based (Java 5 required) • Legacy support (2.x API adapter)
  • 38. Wrap-up • Points to take away: – do not expose every developer to the OSGi API – build higher level abstractions, use design patterns – consider the dependency manager, it is very flexible
  • 39. More about OSGi • ApacheCon 2010 North America November 1-5, Atlanta – OSGi tutorial – full day OSGi track •Masterclass on OSGi October 12-15, Girona – Neil Bartlett and Peter Kriens