SlideShare a Scribd company logo
1 of 36
OSGi & Blueprint
Apache Karaf OSGi Container and Apache Aries
Agenda
• OSGi in a Nutshell
• Apache Felix Karaf
• Blueprint
OSGi in a Nutshell
• What is OSGi?
• Why OSGi?
• OSGi Architecture
• Modular Layer
• Lifecycle Layer
• Service Layer
• Bundles in depth
• OSGi Service Registry
What is OSGi?
•Modularity layer for the Java platform
Modularity, where the code of application is divided into logical parts representing separate concerns
•From OSGi Alliance (http://www.osgi.org)
standard for service-oriented, component-based Java applications
Why OSGi?
• Reduced Complexity & Reuse - Developing with OSGi technology means developing bundles: the OSGi components.
Bundles are modules. They hide their internals from other bundles and communicate through well defined services.
• Dynamic Updates - The OSGi component model is a dynamic model. Bundles can be installed, started, stopped, updated, and
uninstalled without bringing down the whole system.
• Adaptive - The OSGi service registry is a dynamic registry where bundles can register, get, and listen to services. This dynamic
service model allows bundles to find out what capabilities are available on the system and adapt the functionality they can
provide. This makes code more flexible and resilient to changes.
• Versioning - OSGi technology solves JAR hell. JAR hell is the problem that library A works with library B;version=2, but library C
can only work with B;version=3. In standard Java, you're out of luck. In the OSGi environment, all bundles are carefully versioned
and only bundles that can collaborate are wired together in the same class space. This allows both bundle A and C to function
with their own library.
• Small - The OSGi Release 4 Framework can be implemented in about a 300KB JAR file. This is a small overhead for the amount of
functionality that is added to an application by including OSGi. OSGi therefore runs on a large range of devices: from very small, to
small, to mainframes. It only asks for a minimal Java VM to run and adds very little on top of it.
• Fast - One of the primary responsibilities of the OSGi framework is loading the classes from bundles. In traditional Java, the JARs
are completely visible and placed on a linear list. Searching a class requires searching through this (often very long, 150 is not
uncommon) list. In contrast, OSGi pre-wires bundles and knows for each bundle exactly which bundle provides the class. This lack
of searching is a significant speed up factor at startup.
OSGi Architecture
• Bundles - Bundles are the OSGi components made by the developers.
• Services - The services layer connects bundles in a dynamic way by offering a publish-find-bind model for plain old Java
objects. This layer concerned with interaction and communication among modules.
• Life-Cycle - The API to install, start, stop, update, and uninstall bundles. This provides execution time module management
and access to the underlying OSGi framework.
• Modules - The layer that defines how a bundle can import and export code. Basically concerned with packaging and sharing
the code.
• Security - The layer that handles the security aspects.
• Execution Environment - Defines what methods and classes are available in a specific platform.
Modular Layer
• The module layer defines the OSGi module concept,
called a bundle, which is a JAR file with extra metadata
and resources.
• Bundles typically aren’t an entire application packaged
into a single JAR file; rather, they’re the logical modules
that combine to form a given application.
• Bundles are more powerful than standard JAR files,
because you can explicitly declare which contained
packages are externally visible (that is, exported
packages).
• Another important advantage of bundles over standard
JAR files is the fact that you can explicitly declare on
which external packages the bundles depend (that is,
imported packages).
• The main benefit of explicitly declaring your bundles’
exported and imported packages is that the OSGi
framework can manage and verify their consistency
automatically.
Lifecycle Layer
• The lifecycle layer defines how bundles are dynamically
installed and managed in the OSGi framework.
• The lifecycle layer serves two different purposes.
External to your application, the lifecycle layer precisely
defines the bundle lifecycle operations (install, update,
start, stop, and uninstall). These lifecycle operations
allow you to dynamically administer, manage, and evolve
your application in a well-defined way. This means
bundles can be safely added to and removed from the
framework without restarting the application process.
• Internal to your application, the lifecycle layer defines
how your bundles gain access to their execution context,
which provides them with a way to interact with the
OSGi framework and the facilities it provides during
execution. This overall approach to the lifecycle layer is
powerful because it lets you create externally (and
remotely) managed applications or completely self-
managed applications (or any combination).
Service Layer
• Service layer supports and promotes a flexible
application programming model incorporating concepts
popularized by service-oriented computing.
• The main concepts revolve around the service-oriented
publish, find, and bind interaction pattern: service
providers publish their services into a service registry,
while service clients search the registry to find available
services to use.
Bundles
What is (in) an OSGi bundle?
• JAR file containing classes and resources
• Extra manifest headers
• Human-readable Information
• Bundle Identification
• Code Visibility
• Class-search order
Bundles
OSGi bundle manifest headers
• Human-readable Information
− Bundle-Name
− Bundle-Name
− Bundle-Description
− Bundle-DocURL
− Bundle-Category
− Bundle-Vendor
− Bundle-ContactAddress
− Bundle-Copyright
• Bundle Identification
− Bundle-ManifestVersion
− Bundle-SymbolicName
− Bundle-Version
• Code Visibility
− Bundle-ClassPath
− Export-Package
− Import-Package
Syntax Meaning
"[min,max)" min <= x < max
"[min,max]" min <= x <= max
"(min,max)" min < x < max
"(min,max]" min < x <= max
"min" min <= x
Versions and version ranges
• minimum version
• version range
• include version with [ and ]
• exclude version with ( and )
Bundle Class-Search Order
• If the class is from a package starting with java., the parent class loader is asked for the class. If the class is
found, it’s used. If there is no such class, the search ends with an exception.
• If the class is from a package imported by the bundle, the framework asks the exporting bundle for the class.
If the class is found, it’s used. If there is no such class, the search ends with an exception.
• At last the bundle class path is searched for the class. If it’s found, it’s used. If there is no such class, the
search ends with an exception.
Note : Each OSGi bundle has a class loader associated with it.
Example: manifest information
Dependency Resolution
• Highest priority is given to already-resolved candidates, where multiple matches of resolved
candidates are sorted according to version and then installation order.
• Next priority is given to unresolved candidates, where multiple matches of unresolved candidates
are sorted according to version and then installation order.
Bundle States
OSGi Service Registry
• Provider Bundle
• implement interface
• register service
• Client Bundle
• find in registry
• react when registered/unregistered
• Core interfaces
• ServiceRegistration
• ServiceReference
• ServiceTracker
• Often registered/used using
• Spring DM
• Declarative Services
• Blueprint
Limitations of OSGi
• Runs on a single VM
• Hardware Limitations (processor arch and memory)
• Does not support non java services or applications
• Inefficient Concurrency Programming
• Limit to Grow
Apache Felix Karaf
• Introduction
• Installation
• Command shell
• Hot-deployment
• Web console
Introduction
Apache Felix Karaf
• A flexible OSGi-based server runtime
• Choice of OSGi Framework implementation:
• Equinox
• Apache Felix
• Manage the container using
• Command shell
• Web console
• JMX
• Some other features
• Provisioning through feature descriptors
• Applications
• Spring DM and Blueprint
• Hot-deployment
Installation
• Download Apache Karaf and Maven:
• Apache Karaf :
http://karaf.apache.org/index/community/download.html
• Apache Maven :
http://maven.apache.org/download.cgi
• Path Setup:
• $KARAF_HOME
• M2 Setup:
• $M2_HOME
• Maven configuration for Karaf
• Maven repository setup in karaf config
Command Shell
Starting Karaf Command Shell
• start - Start the karaf container
• karaf - Start the karaf container and connect console
• client - Connect to the karaf console
• Unix-like TAB-completion, |, grep, cat, ...
Command Shell : osgi
Commands to interact with OSGi Framework
• osgi:shutdown to stop container
• osgi:list to show bundles
• osgi:headers $id to show bundle metadata
• osgi:ls $id to show bundle services
Command Shell : osgi
Commands to interact with bundles
• osgi:install
• Install from URL
• file:$bundlepath, http:, mvn:$group.id/$aartifact.id/$version
• osgi:start $id, osgi:stop $id
• osgi:update $id
• osgi:uninstall $id
• osgi:diag $id (Apache Karaf 3.0.0)
Command Shell : packages
Allows interacting with OSGi PackageAdmin
• packages:exports shows lists of exported packages
• packages:imports shows
• wired imports
• bundles providing the matching export
• Difference between osgi:headers and packages:
Command Shell : config
Interact with ConfigAdmin service
• config:list
• for changing the runtime config
• config:edit
• config:propset, config:propdel, config:propappend
• config:update or config:cancel
Command Shell
Some other examples
• dev: shell holds some developer tools
• log: shell interacts with log service
• ssh: shell to work with SSH client and server
Type “help” to see all the commands and their description in karaf.
Type “man <command>” to see the details and usage of a command.
Hot Deployment
Karaf supports deployment of
• Bundles
• XML files (Blueprint and Features)
Web Console
Blueprint with Apache Aries
• Introduction
• Service Registration
• Service Reference
• Listeners
• Feature
Introduction
• OSGi standard for IoC/DI
• Inspired by Spring DM (is also the RI)
• Aries implementation
• XML configuration files
• Register beans as services in OSGi Service
• Reference other services in OSGi Service Registry
Service Registration
• Create a bean with class reference
• Expose the service with interface reference
Service Reference
• Create reference for the implementation
• Inject to your service
reference-list
reference
Listeners
• Listener
• Registration listener
• Reference listener
Registration Listener
Reference Listener
Feature
• Group of other features and bundles
• Easy to maintain dependency in large project
• Easy to deploy all the application bundles and related features at one go
• Uses maven as repository of bundles and features
• Other options apart from maven is file and url as bundle installation
features:addurl mvn:$groupid/$artifactid/$version/xml/features
features:install $artifactid
References
• http://karaf.apache.org/
• http://www.osgi.org/Main/HomePage
• https://github.com/karasatishkumar/osgi-labs
• https://github.com/seijoed/osgi-starter
• http://www.hascode.com/2010/07/how-to-create-a-simple-osgi-web-application-using-maven/
• http://pic.dhe.ibm.com/infocenter/wasinfo/v7r0/index.jsp?topic=%2Fcom.ibm.websphere.osgifep.multiplatform.doc%2Ftopics
%2Fca_blueprint_dynamism.html
• http://fusesource.com/docs/esb/4.2/deploy_osgi/DeployFeatures-Create.html
Questions???
Thanks
Kara Satish Kumar
https://www.linkedin.com/in/techgeeksatish

More Related Content

What's hot

Modular Java applications with OSGi on Apache Karaf
Modular Java applications with OSGi on Apache KarafModular Java applications with OSGi on Apache Karaf
Modular Java applications with OSGi on Apache KarafIoan Eugen Stan
 
Modular Architectures using Micro Services
Modular Architectures using Micro ServicesModular Architectures using Micro Services
Modular Architectures using Micro ServicesMarcel Offermans
 
Best Practices - PHP and the Oracle Database
Best Practices - PHP and the Oracle DatabaseBest Practices - PHP and the Oracle Database
Best Practices - PHP and the Oracle DatabaseChristopher Jones
 
JBoss Fuse - Fuse workshop EAP container
JBoss Fuse - Fuse workshop EAP containerJBoss Fuse - Fuse workshop EAP container
JBoss Fuse - Fuse workshop EAP containerChristina Lin
 
OSGi and Java EE: A Hybrid Approach to Enterprise Java Application Development
OSGi and Java EE: A Hybrid Approach to Enterprise Java Application DevelopmentOSGi and Java EE: A Hybrid Approach to Enterprise Java Application Development
OSGi and Java EE: A Hybrid Approach to Enterprise Java Application DevelopmentSanjeeb Sahoo
 
Apache Sling Scripting Reloaded
Apache Sling Scripting ReloadedApache Sling Scripting Reloaded
Apache Sling Scripting ReloadedRadu Cotescu
 
Moving From Actions & Behaviors to Microservices
Moving From Actions & Behaviors to MicroservicesMoving From Actions & Behaviors to Microservices
Moving From Actions & Behaviors to MicroservicesJeff Potts
 
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
 
Java EE 7 for WebLogic 12c Developers
Java EE 7 for WebLogic 12c DevelopersJava EE 7 for WebLogic 12c Developers
Java EE 7 for WebLogic 12c DevelopersBruno Borges
 
Changes in WebLogic 12.1.3 Every Administrator Must Know
Changes in WebLogic 12.1.3 Every Administrator Must KnowChanges in WebLogic 12.1.3 Every Administrator Must Know
Changes in WebLogic 12.1.3 Every Administrator Must KnowBruno Borges
 
Moving Gigantic Files Into and Out of the Alfresco Repository
Moving Gigantic Files Into and Out of the Alfresco RepositoryMoving Gigantic Files Into and Out of the Alfresco Repository
Moving Gigantic Files Into and Out of the Alfresco RepositoryJeff Potts
 
RESTful web service with JBoss Fuse
RESTful web service with JBoss FuseRESTful web service with JBoss Fuse
RESTful web service with JBoss Fuseejlp12
 
201511 - Alfresco Day - Platform Update and Roadmap - Gabriele Columbro - Bo...
201511 -  Alfresco Day - Platform Update and Roadmap - Gabriele Columbro - Bo...201511 -  Alfresco Day - Platform Update and Roadmap - Gabriele Columbro - Bo...
201511 - Alfresco Day - Platform Update and Roadmap - Gabriele Columbro - Bo...Symphony Software Foundation
 
JBoss Fuse Workshop 101 part 5
JBoss Fuse Workshop 101 part 5JBoss Fuse Workshop 101 part 5
JBoss Fuse Workshop 101 part 5Christina Lin
 
Oracle Blockchain Platform_Wonjo Yoo
Oracle Blockchain Platform_Wonjo YooOracle Blockchain Platform_Wonjo Yoo
Oracle Blockchain Platform_Wonjo YooOracle Korea
 
Deploying FuseMQ with Fuse Fabric
Deploying FuseMQ with Fuse FabricDeploying FuseMQ with Fuse Fabric
Deploying FuseMQ with Fuse Fabricdejanb
 
Bee con2016 presentation_20160125004_installing
Bee con2016 presentation_20160125004_installingBee con2016 presentation_20160125004_installing
Bee con2016 presentation_20160125004_installingAngel Borroy López
 

What's hot (20)

Modular Java applications with OSGi on Apache Karaf
Modular Java applications with OSGi on Apache KarafModular Java applications with OSGi on Apache Karaf
Modular Java applications with OSGi on Apache Karaf
 
Karaf ee-apachecon eu-2012
Karaf ee-apachecon eu-2012Karaf ee-apachecon eu-2012
Karaf ee-apachecon eu-2012
 
Modular Architectures using Micro Services
Modular Architectures using Micro ServicesModular Architectures using Micro Services
Modular Architectures using Micro Services
 
Best Practices - PHP and the Oracle Database
Best Practices - PHP and the Oracle DatabaseBest Practices - PHP and the Oracle Database
Best Practices - PHP and the Oracle Database
 
MySQL Replication
MySQL ReplicationMySQL Replication
MySQL Replication
 
JBoss Fuse - Fuse workshop EAP container
JBoss Fuse - Fuse workshop EAP containerJBoss Fuse - Fuse workshop EAP container
JBoss Fuse - Fuse workshop EAP container
 
OSGi and Java EE: A Hybrid Approach to Enterprise Java Application Development
OSGi and Java EE: A Hybrid Approach to Enterprise Java Application DevelopmentOSGi and Java EE: A Hybrid Approach to Enterprise Java Application Development
OSGi and Java EE: A Hybrid Approach to Enterprise Java Application Development
 
Apache Sling Scripting Reloaded
Apache Sling Scripting ReloadedApache Sling Scripting Reloaded
Apache Sling Scripting Reloaded
 
Moving From Actions & Behaviors to Microservices
Moving From Actions & Behaviors to MicroservicesMoving From Actions & Behaviors to Microservices
Moving From Actions & Behaviors to Microservices
 
Oracle Essentials Oracle Database 11g
Oracle Essentials   Oracle Database 11gOracle Essentials   Oracle Database 11g
Oracle Essentials Oracle Database 11g
 
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
 
Java EE 7 for WebLogic 12c Developers
Java EE 7 for WebLogic 12c DevelopersJava EE 7 for WebLogic 12c Developers
Java EE 7 for WebLogic 12c Developers
 
Changes in WebLogic 12.1.3 Every Administrator Must Know
Changes in WebLogic 12.1.3 Every Administrator Must KnowChanges in WebLogic 12.1.3 Every Administrator Must Know
Changes in WebLogic 12.1.3 Every Administrator Must Know
 
Moving Gigantic Files Into and Out of the Alfresco Repository
Moving Gigantic Files Into and Out of the Alfresco RepositoryMoving Gigantic Files Into and Out of the Alfresco Repository
Moving Gigantic Files Into and Out of the Alfresco Repository
 
RESTful web service with JBoss Fuse
RESTful web service with JBoss FuseRESTful web service with JBoss Fuse
RESTful web service with JBoss Fuse
 
201511 - Alfresco Day - Platform Update and Roadmap - Gabriele Columbro - Bo...
201511 -  Alfresco Day - Platform Update and Roadmap - Gabriele Columbro - Bo...201511 -  Alfresco Day - Platform Update and Roadmap - Gabriele Columbro - Bo...
201511 - Alfresco Day - Platform Update and Roadmap - Gabriele Columbro - Bo...
 
JBoss Fuse Workshop 101 part 5
JBoss Fuse Workshop 101 part 5JBoss Fuse Workshop 101 part 5
JBoss Fuse Workshop 101 part 5
 
Oracle Blockchain Platform_Wonjo Yoo
Oracle Blockchain Platform_Wonjo YooOracle Blockchain Platform_Wonjo Yoo
Oracle Blockchain Platform_Wonjo Yoo
 
Deploying FuseMQ with Fuse Fabric
Deploying FuseMQ with Fuse FabricDeploying FuseMQ with Fuse Fabric
Deploying FuseMQ with Fuse Fabric
 
Bee con2016 presentation_20160125004_installing
Bee con2016 presentation_20160125004_installingBee con2016 presentation_20160125004_installing
Bee con2016 presentation_20160125004_installing
 

Similar to OSGi & Blueprint

OSGi User Forum US DC Metro
OSGi User Forum US DC MetroOSGi User Forum US DC Metro
OSGi User Forum US DC MetropjhInovex
 
OSGi user forum dc metro v1
OSGi user forum dc metro v1OSGi user forum dc metro v1
OSGi user forum dc metro v1pjhInovex
 
Introduction to OSGi - Part-1
Introduction to OSGi - Part-1Introduction to OSGi - Part-1
Introduction to OSGi - Part-1kshanth2101
 
Jax london 2011
Jax london 2011Jax london 2011
Jax london 2011njbartlett
 
Java Core | Java 8 and OSGi Modularisation | Tim Ellison & Neil Bartlett
Java Core | Java 8 and OSGi Modularisation | Tim Ellison & Neil BartlettJava Core | Java 8 and OSGi Modularisation | Tim Ellison & Neil Bartlett
Java Core | Java 8 and OSGi Modularisation | Tim Ellison & Neil BartlettJAX London
 
OSGi Service Platform Release 4 Overview - BJ Hargrave, IBM & Peter Kriens, a...
OSGi Service Platform Release 4 Overview - BJ Hargrave, IBM & Peter Kriens, a...OSGi Service Platform Release 4 Overview - BJ Hargrave, IBM & Peter Kriens, a...
OSGi Service Platform Release 4 Overview - BJ Hargrave, IBM & Peter Kriens, a...mfrancis
 
Practical OSGi Subsystems - Glyn Normington
Practical OSGi Subsystems - Glyn NormingtonPractical OSGi Subsystems - Glyn Normington
Practical OSGi Subsystems - Glyn Normingtonmfrancis
 
OSGi and Java EE in GlassFish - Tech Days 2010 India
OSGi and Java EE in GlassFish - Tech Days 2010 IndiaOSGi and Java EE in GlassFish - Tech Days 2010 India
OSGi and Java EE in GlassFish - Tech Days 2010 IndiaArun Gupta
 
Create *real* modular Java applications - a brief introduction -
Create *real* modular Java applications - a brief introduction -Create *real* modular Java applications - a brief introduction -
Create *real* modular Java applications - a brief introduction -Jeffrey Groneberg
 
What's new in the OSGi Enterprise Release 5.0
What's new in the OSGi Enterprise Release 5.0What's new in the OSGi Enterprise Release 5.0
What's new in the OSGi Enterprise Release 5.0David Bosschaert
 
OSGi & Java EE: A hybrid approach to Enterprise Java Application Development,...
OSGi & Java EE: A hybrid approach to Enterprise Java Application Development,...OSGi & Java EE: A hybrid approach to Enterprise Java Application Development,...
OSGi & Java EE: A hybrid approach to Enterprise Java Application Development,...OpenBlend society
 
Building a server platform with os gi
Building a server platform with os giBuilding a server platform with os gi
Building a server platform with os giDileepa Jayakody
 
OpenJDK Penrose Presentation (JavaOne 2012)
OpenJDK Penrose Presentation (JavaOne 2012)OpenJDK Penrose Presentation (JavaOne 2012)
OpenJDK Penrose Presentation (JavaOne 2012)David Bosschaert
 
OSGi For Java Infrastructures [5th IndicThreads Conference On Java 2010, Pune...
OSGi For Java Infrastructures [5th IndicThreads Conference On Java 2010, Pune...OSGi For Java Infrastructures [5th IndicThreads Conference On Java 2010, Pune...
OSGi For Java Infrastructures [5th IndicThreads Conference On Java 2010, Pune...IndicThreads
 
Building a Modular Server Platform with OSGi - Harshana Eranga Martin, Dileep...
Building a Modular Server Platform with OSGi - Harshana Eranga Martin, Dileep...Building a Modular Server Platform with OSGi - Harshana Eranga Martin, Dileep...
Building a Modular Server Platform with OSGi - Harshana Eranga Martin, Dileep...mfrancis
 
Building a Modular Server Platform with OSGi
Building a Modular Server Platform with OSGiBuilding a Modular Server Platform with OSGi
Building a Modular Server Platform with OSGiDileepa Jayakody
 

Similar to OSGi & Blueprint (20)

OSGi introduction
OSGi introductionOSGi introduction
OSGi introduction
 
OSGi User Forum US DC Metro
OSGi User Forum US DC MetroOSGi User Forum US DC Metro
OSGi User Forum US DC Metro
 
OSGi user forum dc metro v1
OSGi user forum dc metro v1OSGi user forum dc metro v1
OSGi user forum dc metro v1
 
Osgi
OsgiOsgi
Osgi
 
Introduction to OSGi - Part-1
Introduction to OSGi - Part-1Introduction to OSGi - Part-1
Introduction to OSGi - Part-1
 
Jax london 2011
Jax london 2011Jax london 2011
Jax london 2011
 
Java Core | Java 8 and OSGi Modularisation | Tim Ellison & Neil Bartlett
Java Core | Java 8 and OSGi Modularisation | Tim Ellison & Neil BartlettJava Core | Java 8 and OSGi Modularisation | Tim Ellison & Neil Bartlett
Java Core | Java 8 and OSGi Modularisation | Tim Ellison & Neil Bartlett
 
OSGi Service Platform Release 4 Overview - BJ Hargrave, IBM & Peter Kriens, a...
OSGi Service Platform Release 4 Overview - BJ Hargrave, IBM & Peter Kriens, a...OSGi Service Platform Release 4 Overview - BJ Hargrave, IBM & Peter Kriens, a...
OSGi Service Platform Release 4 Overview - BJ Hargrave, IBM & Peter Kriens, a...
 
Practical OSGi Subsystems - Glyn Normington
Practical OSGi Subsystems - Glyn NormingtonPractical OSGi Subsystems - Glyn Normington
Practical OSGi Subsystems - Glyn Normington
 
OSGi bootcamp - part 1
OSGi bootcamp - part 1OSGi bootcamp - part 1
OSGi bootcamp - part 1
 
OSGi and Java EE in GlassFish - Tech Days 2010 India
OSGi and Java EE in GlassFish - Tech Days 2010 IndiaOSGi and Java EE in GlassFish - Tech Days 2010 India
OSGi and Java EE in GlassFish - Tech Days 2010 India
 
Create *real* modular Java applications - a brief introduction -
Create *real* modular Java applications - a brief introduction -Create *real* modular Java applications - a brief introduction -
Create *real* modular Java applications - a brief introduction -
 
What's new in the OSGi Enterprise Release 5.0
What's new in the OSGi Enterprise Release 5.0What's new in the OSGi Enterprise Release 5.0
What's new in the OSGi Enterprise Release 5.0
 
OSGi & Java EE: A hybrid approach to Enterprise Java Application Development,...
OSGi & Java EE: A hybrid approach to Enterprise Java Application Development,...OSGi & Java EE: A hybrid approach to Enterprise Java Application Development,...
OSGi & Java EE: A hybrid approach to Enterprise Java Application Development,...
 
OSGi
OSGiOSGi
OSGi
 
Building a server platform with os gi
Building a server platform with os giBuilding a server platform with os gi
Building a server platform with os gi
 
OpenJDK Penrose Presentation (JavaOne 2012)
OpenJDK Penrose Presentation (JavaOne 2012)OpenJDK Penrose Presentation (JavaOne 2012)
OpenJDK Penrose Presentation (JavaOne 2012)
 
OSGi For Java Infrastructures [5th IndicThreads Conference On Java 2010, Pune...
OSGi For Java Infrastructures [5th IndicThreads Conference On Java 2010, Pune...OSGi For Java Infrastructures [5th IndicThreads Conference On Java 2010, Pune...
OSGi For Java Infrastructures [5th IndicThreads Conference On Java 2010, Pune...
 
Building a Modular Server Platform with OSGi - Harshana Eranga Martin, Dileep...
Building a Modular Server Platform with OSGi - Harshana Eranga Martin, Dileep...Building a Modular Server Platform with OSGi - Harshana Eranga Martin, Dileep...
Building a Modular Server Platform with OSGi - Harshana Eranga Martin, Dileep...
 
Building a Modular Server Platform with OSGi
Building a Modular Server Platform with OSGiBuilding a Modular Server Platform with OSGi
Building a Modular Server Platform with OSGi
 

Recently uploaded

CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfAsst.prof M.Gokilavani
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.eptoze12
 
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEINFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEroselinkalist12
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...asadnawaz62
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxDeepakSakkari2
 
DATA ANALYTICS PPT definition usage example
DATA ANALYTICS PPT definition usage exampleDATA ANALYTICS PPT definition usage example
DATA ANALYTICS PPT definition usage examplePragyanshuParadkar1
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
pipeline in computer architecture design
pipeline in computer architecture  designpipeline in computer architecture  design
pipeline in computer architecture designssuser87fa0c1
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)dollysharma2066
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxPoojaBan
 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)Dr SOUNDIRARAJ N
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxbritheesh05
 
Churning of Butter, Factors affecting .
Churning of Butter, Factors affecting  .Churning of Butter, Factors affecting  .
Churning of Butter, Factors affecting .Satyam Kumar
 

Recently uploaded (20)

CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.
 
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEINFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptx
 
DATA ANALYTICS PPT definition usage example
DATA ANALYTICS PPT definition usage exampleDATA ANALYTICS PPT definition usage example
DATA ANALYTICS PPT definition usage example
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
 
Design and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdfDesign and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdf
 
pipeline in computer architecture design
pipeline in computer architecture  designpipeline in computer architecture  design
pipeline in computer architecture design
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptx
 
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptx
 
Churning of Butter, Factors affecting .
Churning of Butter, Factors affecting  .Churning of Butter, Factors affecting  .
Churning of Butter, Factors affecting .
 

OSGi & Blueprint

  • 1. OSGi & Blueprint Apache Karaf OSGi Container and Apache Aries
  • 2. Agenda • OSGi in a Nutshell • Apache Felix Karaf • Blueprint
  • 3. OSGi in a Nutshell • What is OSGi? • Why OSGi? • OSGi Architecture • Modular Layer • Lifecycle Layer • Service Layer • Bundles in depth • OSGi Service Registry
  • 4. What is OSGi? •Modularity layer for the Java platform Modularity, where the code of application is divided into logical parts representing separate concerns •From OSGi Alliance (http://www.osgi.org) standard for service-oriented, component-based Java applications
  • 5. Why OSGi? • Reduced Complexity & Reuse - Developing with OSGi technology means developing bundles: the OSGi components. Bundles are modules. They hide their internals from other bundles and communicate through well defined services. • Dynamic Updates - The OSGi component model is a dynamic model. Bundles can be installed, started, stopped, updated, and uninstalled without bringing down the whole system. • Adaptive - The OSGi service registry is a dynamic registry where bundles can register, get, and listen to services. This dynamic service model allows bundles to find out what capabilities are available on the system and adapt the functionality they can provide. This makes code more flexible and resilient to changes. • Versioning - OSGi technology solves JAR hell. JAR hell is the problem that library A works with library B;version=2, but library C can only work with B;version=3. In standard Java, you're out of luck. In the OSGi environment, all bundles are carefully versioned and only bundles that can collaborate are wired together in the same class space. This allows both bundle A and C to function with their own library. • Small - The OSGi Release 4 Framework can be implemented in about a 300KB JAR file. This is a small overhead for the amount of functionality that is added to an application by including OSGi. OSGi therefore runs on a large range of devices: from very small, to small, to mainframes. It only asks for a minimal Java VM to run and adds very little on top of it. • Fast - One of the primary responsibilities of the OSGi framework is loading the classes from bundles. In traditional Java, the JARs are completely visible and placed on a linear list. Searching a class requires searching through this (often very long, 150 is not uncommon) list. In contrast, OSGi pre-wires bundles and knows for each bundle exactly which bundle provides the class. This lack of searching is a significant speed up factor at startup.
  • 6. OSGi Architecture • Bundles - Bundles are the OSGi components made by the developers. • Services - The services layer connects bundles in a dynamic way by offering a publish-find-bind model for plain old Java objects. This layer concerned with interaction and communication among modules. • Life-Cycle - The API to install, start, stop, update, and uninstall bundles. This provides execution time module management and access to the underlying OSGi framework. • Modules - The layer that defines how a bundle can import and export code. Basically concerned with packaging and sharing the code. • Security - The layer that handles the security aspects. • Execution Environment - Defines what methods and classes are available in a specific platform.
  • 7. Modular Layer • The module layer defines the OSGi module concept, called a bundle, which is a JAR file with extra metadata and resources. • Bundles typically aren’t an entire application packaged into a single JAR file; rather, they’re the logical modules that combine to form a given application. • Bundles are more powerful than standard JAR files, because you can explicitly declare which contained packages are externally visible (that is, exported packages). • Another important advantage of bundles over standard JAR files is the fact that you can explicitly declare on which external packages the bundles depend (that is, imported packages). • The main benefit of explicitly declaring your bundles’ exported and imported packages is that the OSGi framework can manage and verify their consistency automatically.
  • 8. Lifecycle Layer • The lifecycle layer defines how bundles are dynamically installed and managed in the OSGi framework. • The lifecycle layer serves two different purposes. External to your application, the lifecycle layer precisely defines the bundle lifecycle operations (install, update, start, stop, and uninstall). These lifecycle operations allow you to dynamically administer, manage, and evolve your application in a well-defined way. This means bundles can be safely added to and removed from the framework without restarting the application process. • Internal to your application, the lifecycle layer defines how your bundles gain access to their execution context, which provides them with a way to interact with the OSGi framework and the facilities it provides during execution. This overall approach to the lifecycle layer is powerful because it lets you create externally (and remotely) managed applications or completely self- managed applications (or any combination).
  • 9. Service Layer • Service layer supports and promotes a flexible application programming model incorporating concepts popularized by service-oriented computing. • The main concepts revolve around the service-oriented publish, find, and bind interaction pattern: service providers publish their services into a service registry, while service clients search the registry to find available services to use.
  • 10. Bundles What is (in) an OSGi bundle? • JAR file containing classes and resources • Extra manifest headers • Human-readable Information • Bundle Identification • Code Visibility • Class-search order
  • 11. Bundles OSGi bundle manifest headers • Human-readable Information − Bundle-Name − Bundle-Name − Bundle-Description − Bundle-DocURL − Bundle-Category − Bundle-Vendor − Bundle-ContactAddress − Bundle-Copyright • Bundle Identification − Bundle-ManifestVersion − Bundle-SymbolicName − Bundle-Version • Code Visibility − Bundle-ClassPath − Export-Package − Import-Package Syntax Meaning "[min,max)" min <= x < max "[min,max]" min <= x <= max "(min,max)" min < x < max "(min,max]" min < x <= max "min" min <= x Versions and version ranges • minimum version • version range • include version with [ and ] • exclude version with ( and )
  • 12. Bundle Class-Search Order • If the class is from a package starting with java., the parent class loader is asked for the class. If the class is found, it’s used. If there is no such class, the search ends with an exception. • If the class is from a package imported by the bundle, the framework asks the exporting bundle for the class. If the class is found, it’s used. If there is no such class, the search ends with an exception. • At last the bundle class path is searched for the class. If it’s found, it’s used. If there is no such class, the search ends with an exception. Note : Each OSGi bundle has a class loader associated with it. Example: manifest information
  • 13. Dependency Resolution • Highest priority is given to already-resolved candidates, where multiple matches of resolved candidates are sorted according to version and then installation order. • Next priority is given to unresolved candidates, where multiple matches of unresolved candidates are sorted according to version and then installation order.
  • 15. OSGi Service Registry • Provider Bundle • implement interface • register service • Client Bundle • find in registry • react when registered/unregistered • Core interfaces • ServiceRegistration • ServiceReference • ServiceTracker • Often registered/used using • Spring DM • Declarative Services • Blueprint
  • 16. Limitations of OSGi • Runs on a single VM • Hardware Limitations (processor arch and memory) • Does not support non java services or applications • Inefficient Concurrency Programming • Limit to Grow
  • 17. Apache Felix Karaf • Introduction • Installation • Command shell • Hot-deployment • Web console
  • 18. Introduction Apache Felix Karaf • A flexible OSGi-based server runtime • Choice of OSGi Framework implementation: • Equinox • Apache Felix • Manage the container using • Command shell • Web console • JMX • Some other features • Provisioning through feature descriptors • Applications • Spring DM and Blueprint • Hot-deployment
  • 19. Installation • Download Apache Karaf and Maven: • Apache Karaf : http://karaf.apache.org/index/community/download.html • Apache Maven : http://maven.apache.org/download.cgi • Path Setup: • $KARAF_HOME • M2 Setup: • $M2_HOME • Maven configuration for Karaf • Maven repository setup in karaf config
  • 20. Command Shell Starting Karaf Command Shell • start - Start the karaf container • karaf - Start the karaf container and connect console • client - Connect to the karaf console • Unix-like TAB-completion, |, grep, cat, ...
  • 21. Command Shell : osgi Commands to interact with OSGi Framework • osgi:shutdown to stop container • osgi:list to show bundles • osgi:headers $id to show bundle metadata • osgi:ls $id to show bundle services
  • 22. Command Shell : osgi Commands to interact with bundles • osgi:install • Install from URL • file:$bundlepath, http:, mvn:$group.id/$aartifact.id/$version • osgi:start $id, osgi:stop $id • osgi:update $id • osgi:uninstall $id • osgi:diag $id (Apache Karaf 3.0.0)
  • 23. Command Shell : packages Allows interacting with OSGi PackageAdmin • packages:exports shows lists of exported packages • packages:imports shows • wired imports • bundles providing the matching export • Difference between osgi:headers and packages:
  • 24. Command Shell : config Interact with ConfigAdmin service • config:list • for changing the runtime config • config:edit • config:propset, config:propdel, config:propappend • config:update or config:cancel
  • 25. Command Shell Some other examples • dev: shell holds some developer tools • log: shell interacts with log service • ssh: shell to work with SSH client and server Type “help” to see all the commands and their description in karaf. Type “man <command>” to see the details and usage of a command.
  • 26. Hot Deployment Karaf supports deployment of • Bundles • XML files (Blueprint and Features)
  • 28. Blueprint with Apache Aries • Introduction • Service Registration • Service Reference • Listeners • Feature
  • 29. Introduction • OSGi standard for IoC/DI • Inspired by Spring DM (is also the RI) • Aries implementation • XML configuration files • Register beans as services in OSGi Service • Reference other services in OSGi Service Registry
  • 30. Service Registration • Create a bean with class reference • Expose the service with interface reference
  • 31. Service Reference • Create reference for the implementation • Inject to your service reference-list reference
  • 32. Listeners • Listener • Registration listener • Reference listener Registration Listener Reference Listener
  • 33. Feature • Group of other features and bundles • Easy to maintain dependency in large project • Easy to deploy all the application bundles and related features at one go • Uses maven as repository of bundles and features • Other options apart from maven is file and url as bundle installation features:addurl mvn:$groupid/$artifactid/$version/xml/features features:install $artifactid
  • 34. References • http://karaf.apache.org/ • http://www.osgi.org/Main/HomePage • https://github.com/karasatishkumar/osgi-labs • https://github.com/seijoed/osgi-starter • http://www.hascode.com/2010/07/how-to-create-a-simple-osgi-web-application-using-maven/ • http://pic.dhe.ibm.com/infocenter/wasinfo/v7r0/index.jsp?topic=%2Fcom.ibm.websphere.osgifep.multiplatform.doc%2Ftopics %2Fca_blueprint_dynamism.html • http://fusesource.com/docs/esb/4.2/deploy_osgi/DeployFeatures-Create.html