SlideShare ist ein Scribd-Unternehmen logo
1 von 48
Downloaden Sie, um offline zu lesen
Introduction to OSGi
              Chris Custine
           ccustine@apache.org




Denver Java User Group - November 12, 2008




                                             1
Introduction - Chris Custine

Apache ServiceMix - Committer
 Open Source ESB
 JBI 1.0 Implementation
 ServiceMix 4 - OSGi Based (Apache Felix)
Apache Directory Server - Committer and PMC Member
 LDAP v3 Certified
 100% Java
 Soon to be OSGi, but currently used in some OSGi services
Organic Element - Open Source Consulting and Software
Development




                                                             2
Presentation Agenda

OSGi Overview and History


OSGi Architecture and Layers


Best Practices


Recommended Tools




                                 3
What is OSGi?

OSGi - Formerly Open Services Gateway Initiative
Now just OSGi due to generalization of market
OSGi Alliance - Consortium of Vendors




                                                   4
What Does the OSGi Alliance Do?

Defines OSGi Service Platform specification
Multiple groups define the specifications
 Core Platform Expert Group (CPEG) – Core framework
 Mobile Expert Group (MEG) – Mobile
 Vehicle Expert Group (VEG) – Automotive
 Enterprise Expert Group (EEG) – Enterprise
 Residential Expert Group (REG) – Home Automation




                                                      5
Where did OSGi come from?

Originally aimed at Home Automation market
 Home Gateway device to monitor and interact with devices
 Multi vendor devices connected throughout the home




                                                            6
Where did OSGi come from?

Requirement for standard plugin model for Gateway device
 GUI Model for administration of devices
 Services available to devices
   Data storage
   Conversion
   Network
Software management and deployment
 Software updates
Security
 Services only available to same device/vendor
 Only allow updates from properly signed jar

“Hello, this is your refrigerator... you need to buy milk”



                                                             7
How we got here

Original use case (Home Automation) faltered around 2000
OSGi used in niche areas (automotive, mobile) for several
years
Eclipse 3.0 released June 2004 - First Eclipse with OSGi
Gradual adoption and recognition for OSGi after Eclipse
Currently undergoing widespread adoption




                                                            8
OSGi is...

About building systems from smaller components
Components working together
Managing components




                                                 9
Why OSGi?

Convergence of mobile and embedded devices creates
huge manageability problems
 Portability - Hardware, OS
 Management - Massive pushes for updates and fixes
 Maintenance - Dynamic library management and
 dependencies causing unmanageable hacks like
 Class.forName()




                                                     10
OSGi Relationship with Java

Always focused on Java
Bundles may contain native libraries used via JNI
 Example: Eclipse uses native libraries for SWT GUI calls
RFC-119 for distributed OSGi allows communication with
external systems (possibly not Java)
Script language support from bundle providers




                                                            11
OSGi Service Platform

Two distinct specifications
Core Specification - Core framework, packaging,
modularity, security, API (interfaces), etc.
Service Compendium - Additional services (some optional),
utilities, logging, event system, configuration admin, etc.




                                                             12
OSGi Architecture and Layers


                                 Service


                            Lifecycle




                                           Security
   Bundles
                        Module


             Execution Environment


               Hardware / OS




                                                      13
Java Execution Environment

Managing the runtime environment
                                                                      Service

What do I require to run?                                        Lifecycle




                                                                                Security
                                        Bundles

 JRE Level                                                   Module


                                                  Execution Environment


 GUI Requirements                                   Hardware / OS




Matching application requirements with the platform




                                                                                           14
Module Layer

Packaging and deployment
standards                                                     Service


                                                         Lifecycle




                                                                        Security
Specify constraints on
                                Bundles
                                                     Module


dependencies and requirements             Execution Environment


                                            Hardware / OS

Visibility between components




                                                                                   15
Lifecycle Layer

Fine grained events for
application and component                                         Service



lifecycle
                                                             Lifecycle




                                                                            Security
                                    Bundles
                                                         Module


 Installing, starting, stopping               Execution Environment




Standard API for registering,
                                                Hardware / OS




listening, and acting on events
No custom API needed for
plugins and extensions




                                                                                       16
Services Layer

Standard methods for registering
service instances                                                Service


                                                            Lifecycle




                                                                           Security
Discover and bind to services
                                   Bundles
                                                        Module


from other components                        Execution Environment


                                               Hardware / OS

Reference tracking




                                                                                      17
Security Layer

Protect Visibility between
components                                                         Service


                                                              Lifecycle




                                                                             Security
 Example: Vendor A only wants to     Bundles
                                                          Module


 use the XYZ service provided by               Execution Environment


 Vendor A (could be multiple other               Hardware / OS


 implementations of XYZ)
Constraints can be expressed
using certificates from signed jars
or attributes for bundle, service,
etc.




                                                                                        18
Layer Details

Module, Lifecycle, and Service layers are where most work
is done for enterprise Java development
Security is important but not as widely utilized




                                                            19
Java Modularity Limitations

Scoping and visibility is limited to packages (no module
scoping)
Dependency management? Managed through classpath
Version handling? First package match on classpath
Modularity is not supported as a first class citizen




                                                           20
Module Layer

Bundles are the primary building
block
                                                                    Service


                                                               Lifecycle




                                                                              Security
Package visibility and sharing
                                      Bundles
                                                           Module




Security constraints on packages
                                                Execution Environment


                                                  Hardware / OS


Classloader per bundle
 Graph of classloaders, resolved at
 deploy time




                                                                                         21
Module Layer

Bundle - Just a jar file                                                                  Service


                                                                                    Lifecycle




                                                                                                   Security
                                                           Bundles




META-INF/manifest.mf
                                                                                Module


                                                                     Execution Environment


                                                                       Hardware / OS




 Dependencies
 Versioning
 Consistency

                          Manifest-Version: 1.0
                          Import-Package: ...
                          Export-Package: ...
                          Bundle-Activator: ...
                          Bundle-Version: 1.1.0.SNAPSHOT
                          Bundle-Name: ...
                          Bundle-ManifestVersion: 2
                          Bundle-SymbolicName: ...




                                                                                                              22
Module Layer - Example Manifest

                          META-INF/manifest.mf

Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.apache.servicemix.kernel.filemonitor
Bundle-Version: 1.1.0.SNAPSHOT
Import-Package: org.apache.commons.logging,org.apache.servicemix.kerne
 l.filemonitor,org.osgi.framework,org.osgi.service.cm;version=quot;1.2quot;,or
 g.osgi.service.packageadmin,org.osgi.util.tracker;version=quot;1.3quot;
Export-Package: org.apache.servicemix.kernel.filemonitor;uses:=quot;org.os
 gi.framework,org.apache.commons.logging,org.osgi.service.cm,org.osgi.
                                        Text
 service.packageadmin,org.osgi.util.trackerquot;
Bundle-Activator: org.apache.servicemix.kernel.filemonitor.FileMonitorActivator
Bundle-Name: Apache ServiceMix Kernel :: File Monitor
Bundle-Description: This bundle monitors the deploy directory for new
 OSGi bundles in jar form, expanded form or for      configuration f
 ile changes and undeploys/redeploys them




                                                                                 23
Module Layer - Example Manifest

                          META-INF/manifest.mf

Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.apache.servicemix.kernel.filemonitor
Bundle-Version: 1.1.0.SNAPSHOT
Import-Package: org.apache.commons.logging,org.apache.servicemix.kerne
 l.filemonitor,org.osgi.framework,org.osgi.service.cm;version=quot;1.2quot;,or
 g.osgi.service.packageadmin,org.osgi.util.tracker;version=quot;1.3quot;
Export-Package: org.apache.servicemix.kernel.filemonitor;uses:=quot;org.os
 gi.framework,org.apache.commons.logging,org.osgi.service.cm,org.osgi.
                                        Text
 service.packageadmin,org.osgi.util.trackerquot;
Bundle-Activator: org.apache.servicemix.kernel.filemonitor.FileMonitorActivator
Bundle-Name: Apache ServiceMix Kernel :: File Monitor
Bundle-Description: This bundle monitors the deploy directory for new
 OSGi bundles in jar form, expanded form or for      configuration f
 ile changes and undeploys/redeploys them




                                                                                 24
Module Layer - Example Manifest

                          META-INF/manifest.mf

Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.apache.servicemix.kernel.filemonitor
Bundle-Version: 1.1.0.SNAPSHOT
Import-Package: org.apache.commons.logging,org.apache.servicemix.kerne
 l.filemonitor,org.osgi.framework,org.osgi.service.cm;version=quot;1.2quot;,or
 g.osgi.service.packageadmin,org.osgi.util.tracker;version=quot;1.3quot;
Export-Package: org.apache.servicemix.kernel.filemonitor;uses:=quot;org.os
 gi.framework,org.apache.commons.logging,org.osgi.service.cm,org.osgi.
                                        Text
 service.packageadmin,org.osgi.util.trackerquot;
Bundle-Activator: org.apache.servicemix.kernel.filemonitor.FileMonitorActivator
Bundle-Name: Apache ServiceMix Kernel :: File Monitor
Bundle-Description: This bundle monitors the deploy directory for new
 OSGi bundles in jar form, expanded form or for      configuration f
 ile changes and undeploys/redeploys them




                                                                                 25
Module Layer - Example Manifest

                          META-INF/manifest.mf

Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.apache.servicemix.kernel.filemonitor
Bundle-Version: 1.1.0.SNAPSHOT
Import-Package: org.apache.commons.logging,org.apache.servicemix.kerne
 l.filemonitor,org.osgi.framework,org.osgi.service.cm;version=quot;1.2quot;,or
 g.osgi.service.packageadmin,org.osgi.util.tracker;version=quot;1.3quot;
Export-Package: org.apache.servicemix.kernel.filemonitor;uses:=quot;org.os
 gi.framework,org.apache.commons.logging,org.osgi.service.cm,org.osgi.
                                        Text
 service.packageadmin,org.osgi.util.trackerquot;
Bundle-Activator: org.apache.servicemix.kernel.filemonitor.FileMonitorActivator
Bundle-Name: Apache ServiceMix Kernel :: File Monitor
Bundle-Description: This bundle monitors the deploy directory for new
 OSGi bundles in jar form, expanded form or for      configuration f
 ile changes and undeploys/redeploys them




                                                                                 26
Module Layer - Example Manifest

                          META-INF/manifest.mf

Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.apache.servicemix.kernel.filemonitor
Bundle-Version: 1.1.0.SNAPSHOT
Import-Package: org.apache.commons.logging,org.apache.servicemix.kerne
 l.filemonitor,org.osgi.framework,org.osgi.service.cm;version=quot;1.2quot;,or
 g.osgi.service.packageadmin,org.osgi.util.tracker;version=quot;1.3quot;
Export-Package: org.apache.servicemix.kernel.filemonitor;uses:=quot;org.os
 gi.framework,org.apache.commons.logging,org.osgi.service.cm,org.osgi.
                                        Text
 service.packageadmin,org.osgi.util.trackerquot;
Bundle-Activator: org.apache.servicemix.kernel.filemonitor.FileMonitorActivator
Bundle-Name: Apache ServiceMix Kernel :: File Monitor
Bundle-Description: This bundle monitors the deploy directory for new
 OSGi bundles in jar form, expanded form or for      configuration f
 ile changes and undeploys/redeploys them




                                                                                 27
Module Layer - Example Manifest

                          META-INF/manifest.mf

Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.apache.servicemix.kernel.filemonitor
Bundle-Version: 1.1.0.SNAPSHOT
Import-Package: org.apache.commons.logging,org.apache.servicemix.kerne
 l.filemonitor,org.osgi.framework,org.osgi.service.cm;version=quot;1.2quot;,or
 g.osgi.service.packageadmin,org.osgi.util.tracker;version=quot;1.3quot;
Export-Package: org.apache.servicemix.kernel.filemonitor;uses:=quot;org.os
 gi.framework,org.apache.commons.logging,org.osgi.service.cm,org.osgi.
                                        Text
 service.packageadmin,org.osgi.util.trackerquot;
Bundle-Activator: org.apache.servicemix.kernel.filemonitor.FileMonitorActivator
Bundle-Name: Apache ServiceMix Kernel :: File Monitor
Bundle-Description: This bundle monitors the deploy directory for new
 OSGi bundles in jar form, expanded form or for      configuration f
 ile changes and undeploys/redeploys them




                                                                                 28
Module Layer - Bundle Contents

Bundles may contain additional contents not
usually included in jars.
 Native code - Multiple platforms, OS, etc.
 loading rules specified in manifest
 Embedded jar files - Bundle-Classpath allows
 embedded jars to be referenced from
 manifest.mf (not recommended)
 Resource files - images, configuration, html




                                               29
Module Layer - Bundle State


                           install

                                     update
                    INSTALLED


        uninstall                    resolve

                     uninstall
   UNINSTALLED                       RESOLVED


                           start

                    STARTING                    STOPPING


                                                stop


                                      ACTIVE




                                                           30
Module Layer - Bundle State

Resolution of dependencies at
deployment                                                   install

                                                      INSTALLED
                                                                       update




If resolution fails, bundle is not
                                          uninstall                    resolve

                                                       uninstall
                                     UNINSTALLED                       RESOLVED




available for use
                                                             start

                                                      STARTING                    STOPPING


                                                                                  stop


No runtime CNFE                                                         ACTIVE




Services and lifecycle not
called until AFTER resolution




                                                                                             31
Module Layer - Resolution Goodies

Exporters can name arbitrary attributes for matching
 Attributes can be mandatory for matching


            org.apache.mypackagea-1.0.0.jar                          org.apache.mypackageb-1.0.0.jar



                          META-INF/manifest.mf                                     META-INF/manifest.mf
              Export-Package:                                          Export-Package:
              org.apache.mypackage;                                    org.apache.mypackage;
              version=”1.0.0”                                          version=”1.0.0”;flavor=”vanilla”




                                      org.apache.bundlea-1.0.0.jar



                                                     META-INF/manifest.mf
                                         Import-Package:
                                         org.apache.mypackage;
                                         version=”1.0.0”;flavor=”vanilla”




                                                                                                          32
Module Layer - Resolution Goodies

Same package can be installed with different versions
 Importers can specify version ranges for compatibility
 Allows staged migration of multiple components
       org.apache.mypackage-1.0.1.jar                           org.apache.mypackage-2.0.0.jar



                     META-INF/manifest.mf                                     META-INF/manifest.mf
         Export-Package:                                          Export-Package:
         org.apache.mypackage;                                    org.apache.mypackage;
         version=”1.0.1”                                          version=”2.0.0”




                                 org.apache.bundlea-1.0.0.jar



                                                META-INF/manifest.mf
                                    Import-Package:
                                    org.apache.mypackage;
                                    version=”[1.0.1,2.0.0)”




                                                                                                     33
Lifecycle Layer

Bundle-Activator: Like main() for                                  Service


your bundle.                                                  Lifecycle




                                                                             Security
                                     Bundles


Bundles can tap into the lifecycle
                                                          Module


                                               Execution Environment

events of the framework                          Hardware / OS


Extremely powerful when
combined with startlevel features
Ability to register listeners for
bundle state changes




                                                                                        34
Lifecycle Layer

Bundle activation provides the                                                                 Service




bundle context to the bundle                                                              Lifecycle




                                                                                                         Security
                                                                 Bundles
                                                                                      Module




Bundle context provides access
                                                                           Execution Environment


                                                                             Hardware / OS




to the framework and all services
Creates and registers service
instances
Get reference to required services
Register listeners for bundle
lifecycle                                             BundleActivator.java
                                package org.osgi.framework;

                                public interface BundleActivator {
                                  public void start(BundleContext context) throws Exception;
                                  public void stop(BundleContext context) throws Exception;
                                }




                                                                                                                    35
Service Layer

Primary means of collaboration
between components
                                                                  Service


                                                             Lifecycle




                                                                            Security
Service Registry for discovering
                                    Bundles
                                                         Module


and binding to services                       Execution Environment


                                                Hardware / OS

Ability to listen for services
(Service Tracker)
Service oriented model for in VM
interactions
RFC-119 Brings distributed
services across instances




                                                                                       36
Start Level Service

Setting bundle start order
Similar to Unix init scripts
Start level can be changed up and down at runtime
Persistent start level on restarts




                                                    37
OSGi Compendium Services

Log Service            UPnP
Http Service           Declarative Services
Device Access          Event Admin
Configuration Admin     Deployment Admin
Metatype Service       Auto Configuration
Preferences Service    Application Admin
User Admin             DMT Admin
Wire Admin             Monitor Admin
IO Connector           Service Tracker
Initial Provisioning




                                              38
Configuration Admin

Configuration provided by framework service
Notification to bundles when configuration changed




                                                   39
Best Practices

Use package names consistently - We use package name
for artifact name (Eclipse plugins do too), with one package
heirarchy per bundle. Quick recognition of artifact and
package purpose.
Keep public and private classes in separate packages
Use explicit Import-Package. Don’t use Require-Bundle.
Easy to use initially, but causes problems down the road.
Avoid Dynamic-Import - Defers classloading to runtime
 Allows arbitrary Class.forName() use case but causes trouble
Use tools to compose manifest files and package bundles
(Maven plugins, Eclipse PDE, etc.)




                                                                40
Tools for OSGi - BND

Peter Kriens - BND
 Tool for analyzing dependencies and validating manifest.mf
 Uses reflection to analyze imports and lists dependencies
 Great tool for analyzing non-OSGi jar files and converting




                                                              41
Tools for OSGi - Maven Felix Plugin

            Uses BND to automate creation of manifest.mf
            Use packaging=bundle to invoke plugin in package lifecycle
                                                      pom.xml

            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <configuration>
                    <instructions>
                        <Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
                        <Export-Package>org.apache.servicemix.kernel.gshell.activemq;version=${project.version};-
split-package:=merge-first</Export-Package>
                        <Import-Package>
                          org.apache.geronimo.gshell.wisdom.command,
                          org.apache.servicemix.kernel.gshell.core,
                          org.apache.geronimo.gshell.wisdom.registry,
                          *
                        </Import-Package>
                        <Private-Package>!*</Private-Package>
                        <Spring-Context>*;publish-context:=false;create-asynchronously:=false</Spring-Context>
                    </instructions>
                </configuration>
            </plugin>




                                                                                                                    42
Tools for OSGi - Spring DM

SpringDM bridges the Spring world with OSGi Service
Platform
Reuse existing knowledge of Spring
Limited knowledge of OSGi required
Expose spring beans in the OSGi Service Registry
 Can be bound to by pure OSGi service consumers
Lookup and bind bean refs to OSGi services




                                                      43
Tools for OSGi - Spring DM

Example: ActiveMQ broker definition using SpringDM and
OSGi
                                         broker.xml


<bean id=quot;pooledConnectionFactoryquot; class=quot;org.apache.activemq.pool.PooledConnectionFactoryBeanquot;>
    <property name=quot;maxConnectionsquot; value=quot;8quot; />
    <property name=quot;transactionManagerquot; ref=quot;transactionManagerquot; />
    <property name=quot;connectionFactoryquot; ref=quot;activemqConnectionFactoryquot; />
    <property name=quot;resourceNamequot; value=quot;activemq.${name}quot; />
</bean>

<osgi:reference id=quot;transactionManagerquot; interface=quot;javax.transaction.TransactionManagerquot;
                cardinality=quot;0..1quot;/>

<osgi:service ref=quot;pooledConnectionFactoryquot;>
    <osgi:interfaces>
        <value>javax.jms.ConnectionFactory</value>
    </osgi:interfaces>
    <osgi:service-properties>
        <entry key=quot;namequot; value=quot;${name}quot;/>
    </osgi:service-properties>
</osgi:service>




                                                                                                   44
Tools for OSGi - Spring DM

Example: Using OSGi Configuration Admin for Property
Placeholder


                                     beans.xml


    <bean id=quot;myTransformquot; class=quot;org.apache.servicemix.examples.camel.MyTransformquot;>
        <property name=quot;prefixquot; value=quot;${prefix}quot;/>
    </bean>

    <osgix:property-placeholder persistent-id=quot;org.apache.servicemix.examplesquot;>
        <osgix:default-properties>
            <prop key=quot;prefixquot;>MyTransform</prop>
        </osgix:default-properties>
    </osgix:property-placeholder>




                                                                                       45
Conclusion

OSGi forces planning and engineering of bundle
interactions
More work up front, but rewards come later
No silver bullet, bad code and bad ideas are still bad
Many built in features and services provided for applications
Modularization is rewarded when creating new systems and
modifying existing ones




                                                                46
Tour of ServiceMix 4 OSGi Features




                                     47
Questions?



             48

Weitere ähnliche Inhalte

Was ist angesagt?

Build 4 The Cloud By Cisco&VMware1
Build 4 The Cloud By Cisco&VMware1Build 4 The Cloud By Cisco&VMware1
Build 4 The Cloud By Cisco&VMware1Azlan NL
 
OSGi-based Workflow Engine
OSGi-based Workflow EngineOSGi-based Workflow Engine
OSGi-based Workflow Engineyocaba
 
Equinox -The adoption of the OSGi standard in enterprise solutions
Equinox -The adoption of the OSGi standard in enterprise solutions Equinox -The adoption of the OSGi standard in enterprise solutions
Equinox -The adoption of the OSGi standard in enterprise solutions SpagoWorld
 
Using OSGi to Build Better Software
Using OSGi to Build Better SoftwareUsing OSGi to Build Better Software
Using OSGi to Build Better Softwareyocaba
 
Tool support for semi-automatic modularization of existing code bases
Tool support for semi-automatic modularization of existing code basesTool support for semi-automatic modularization of existing code bases
Tool support for semi-automatic modularization of existing code basesyocaba
 
Embedding Existing Heterogeneous Monitoring Techniques into a Lightweight, Di...
Embedding Existing Heterogeneous Monitoring Techniques into a Lightweight, Di...Embedding Existing Heterogeneous Monitoring Techniques into a Lightweight, Di...
Embedding Existing Heterogeneous Monitoring Techniques into a Lightweight, Di...yocaba
 
Qualipso factory
Qualipso factoryQualipso factory
Qualipso factoryfunckychris
 
Xen summit 2010 extending xen into embedded
Xen summit 2010 extending xen into embeddedXen summit 2010 extending xen into embedded
Xen summit 2010 extending xen into embeddedThe Linux Foundation
 
Roger boesch xen desktop mit cisco
Roger boesch xen desktop mit ciscoRoger boesch xen desktop mit cisco
Roger boesch xen desktop mit ciscoDigicomp Academy AG
 
SOA Testing Challenges
SOA Testing ChallengesSOA Testing Challenges
SOA Testing ChallengesScott Barber
 
Triangle OpenStack Meetup
Triangle OpenStack MeetupTriangle OpenStack Meetup
Triangle OpenStack Meetupmestery
 
GlassFish in the Virtual World
GlassFish in the Virtual WorldGlassFish in the Virtual World
GlassFish in the Virtual WorldArun Gupta
 
ActionPacked! Networks Hosts Cisco Application Visibility & Control Webinar
ActionPacked! Networks Hosts Cisco Application Visibility & Control WebinarActionPacked! Networks Hosts Cisco Application Visibility & Control Webinar
ActionPacked! Networks Hosts Cisco Application Visibility & Control WebinarActionPacked Networks
 
21st Century SOA
21st Century SOA21st Century SOA
21st Century SOABob Rhubart
 

Was ist angesagt? (19)

102 1630 1700
102 1630 1700102 1630 1700
102 1630 1700
 
Build 4 The Cloud By Cisco&VMware1
Build 4 The Cloud By Cisco&VMware1Build 4 The Cloud By Cisco&VMware1
Build 4 The Cloud By Cisco&VMware1
 
OSGi-based Workflow Engine
OSGi-based Workflow EngineOSGi-based Workflow Engine
OSGi-based Workflow Engine
 
Osgi Sun 20080820
Osgi Sun 20080820Osgi Sun 20080820
Osgi Sun 20080820
 
Equinox -The adoption of the OSGi standard in enterprise solutions
Equinox -The adoption of the OSGi standard in enterprise solutions Equinox -The adoption of the OSGi standard in enterprise solutions
Equinox -The adoption of the OSGi standard in enterprise solutions
 
101 cd 1345-1415
101 cd 1345-1415101 cd 1345-1415
101 cd 1345-1415
 
Cisco ios versions
Cisco ios versionsCisco ios versions
Cisco ios versions
 
Using OSGi to Build Better Software
Using OSGi to Build Better SoftwareUsing OSGi to Build Better Software
Using OSGi to Build Better Software
 
Tool support for semi-automatic modularization of existing code bases
Tool support for semi-automatic modularization of existing code basesTool support for semi-automatic modularization of existing code bases
Tool support for semi-automatic modularization of existing code bases
 
Embedding Existing Heterogeneous Monitoring Techniques into a Lightweight, Di...
Embedding Existing Heterogeneous Monitoring Techniques into a Lightweight, Di...Embedding Existing Heterogeneous Monitoring Techniques into a Lightweight, Di...
Embedding Existing Heterogeneous Monitoring Techniques into a Lightweight, Di...
 
Qualipso factory
Qualipso factoryQualipso factory
Qualipso factory
 
Nemo intro-100811
Nemo intro-100811Nemo intro-100811
Nemo intro-100811
 
Xen summit 2010 extending xen into embedded
Xen summit 2010 extending xen into embeddedXen summit 2010 extending xen into embedded
Xen summit 2010 extending xen into embedded
 
Roger boesch xen desktop mit cisco
Roger boesch xen desktop mit ciscoRoger boesch xen desktop mit cisco
Roger boesch xen desktop mit cisco
 
SOA Testing Challenges
SOA Testing ChallengesSOA Testing Challenges
SOA Testing Challenges
 
Triangle OpenStack Meetup
Triangle OpenStack MeetupTriangle OpenStack Meetup
Triangle OpenStack Meetup
 
GlassFish in the Virtual World
GlassFish in the Virtual WorldGlassFish in the Virtual World
GlassFish in the Virtual World
 
ActionPacked! Networks Hosts Cisco Application Visibility & Control Webinar
ActionPacked! Networks Hosts Cisco Application Visibility & Control WebinarActionPacked! Networks Hosts Cisco Application Visibility & Control Webinar
ActionPacked! Networks Hosts Cisco Application Visibility & Control Webinar
 
21st Century SOA
21st Century SOA21st Century SOA
21st Century SOA
 

Andere mochten auch

The Web on OSGi: Here's How
The Web on OSGi: Here's HowThe Web on OSGi: Here's How
The Web on OSGi: Here's Howmrdon
 
Common Security Services. Consolidation patterns for legacy components - Stef...
Common Security Services. Consolidation patterns for legacy components - Stef...Common Security Services. Consolidation patterns for legacy components - Stef...
Common Security Services. Consolidation patterns for legacy components - Stef...mfrancis
 
Security in OSGi applications: Robust OSGi Platforms, secure Bundles
Security in OSGi applications: Robust OSGi Platforms, secure BundlesSecurity in OSGi applications: Robust OSGi Platforms, secure Bundles
Security in OSGi applications: Robust OSGi Platforms, secure BundlesKai Hackbarth
 
Security Policy Enforcement for the OSGi Framework using Aspect-Oriented Pr...
Security Policy Enforcement for the OSGi Framework using Aspect-Oriented Pr...Security Policy Enforcement for the OSGi Framework using Aspect-Oriented Pr...
Security Policy Enforcement for the OSGi Framework using Aspect-Oriented Pr...Phú Phùng
 
Benefits of OSGi in Practise
Benefits of OSGi in PractiseBenefits of OSGi in Practise
Benefits of OSGi in PractiseDavid Bosschaert
 

Andere mochten auch (7)

The Web on OSGi: Here's How
The Web on OSGi: Here's HowThe Web on OSGi: Here's How
The Web on OSGi: Here's How
 
Common Security Services. Consolidation patterns for legacy components - Stef...
Common Security Services. Consolidation patterns for legacy components - Stef...Common Security Services. Consolidation patterns for legacy components - Stef...
Common Security Services. Consolidation patterns for legacy components - Stef...
 
Intro To OSGi
Intro To OSGiIntro To OSGi
Intro To OSGi
 
Security in OSGi applications: Robust OSGi Platforms, secure Bundles
Security in OSGi applications: Robust OSGi Platforms, secure BundlesSecurity in OSGi applications: Robust OSGi Platforms, secure Bundles
Security in OSGi applications: Robust OSGi Platforms, secure Bundles
 
Security Policy Enforcement for the OSGi Framework using Aspect-Oriented Pr...
Security Policy Enforcement for the OSGi Framework using Aspect-Oriented Pr...Security Policy Enforcement for the OSGi Framework using Aspect-Oriented Pr...
Security Policy Enforcement for the OSGi Framework using Aspect-Oriented Pr...
 
Benefits of OSGi in Practise
Benefits of OSGi in PractiseBenefits of OSGi in Practise
Benefits of OSGi in Practise
 
Why OSGi?
Why OSGi?Why OSGi?
Why OSGi?
 

Ähnlich wie Introduction To OSGi

Java Modularity with OSGi
Java Modularity with OSGiJava Modularity with OSGi
Java Modularity with OSGiIlya Rybak
 
Enabling modularization through OSGi and SpringDM
Enabling modularization through OSGi and SpringDMEnabling modularization through OSGi and SpringDM
Enabling modularization through OSGi and SpringDMmukulobject
 
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
 
Spring basics for freshers
Spring basics for freshersSpring basics for freshers
Spring basics for freshersSwati Bansal
 
Liferay Module Framework
Liferay Module FrameworkLiferay Module Framework
Liferay Module FrameworkMiguel Pastor
 
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
 
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
 
What is os gi and what does osgi
What is os gi and what does osgiWhat is os gi and what does osgi
What is os gi and what does osgiYunChang Lee
 
Framework adoption for java enterprise application development
Framework adoption for java enterprise application developmentFramework adoption for java enterprise application development
Framework adoption for java enterprise application developmentClarence Ho
 
OSGi DevCon 2009 Review
OSGi DevCon 2009 ReviewOSGi DevCon 2009 Review
OSGi DevCon 2009 Reviewnjbartlett
 
SCOM 2012 & SCCM 2012
SCOM 2012 & SCCM 2012SCOM 2012 & SCCM 2012
SCOM 2012 & SCCM 2012Amit Gatenyo
 
OSGi-enabled Java EE applications in GlassFish
OSGi-enabled Java EE applications in GlassFishOSGi-enabled Java EE applications in GlassFish
OSGi-enabled Java EE applications in GlassFishArun Gupta
 
Introduction to Software-defined Networking
Introduction to Software-defined NetworkingIntroduction to Software-defined Networking
Introduction to Software-defined NetworkingAnees Shaikh
 
Liberate your components with OSGi services - Graham Charters
Liberate your components with OSGi services - Graham ChartersLiberate your components with OSGi services - Graham Charters
Liberate your components with OSGi services - Graham Chartersmfrancis
 
OSGi-enabled Java EE Applications using GlassFish
OSGi-enabled Java EE Applications using GlassFishOSGi-enabled Java EE Applications using GlassFish
OSGi-enabled Java EE Applications using GlassFishArun Gupta
 
Cisco Data Center Orchestration Solution
Cisco Data Center Orchestration SolutionCisco Data Center Orchestration Solution
Cisco Data Center Orchestration SolutionCisco Canada
 

Ähnlich wie Introduction To OSGi (20)

OSGi tech session
OSGi tech sessionOSGi tech session
OSGi tech session
 
Java Modularity with OSGi
Java Modularity with OSGiJava Modularity with OSGi
Java Modularity with OSGi
 
Enabling modularization through OSGi and SpringDM
Enabling modularization through OSGi and SpringDMEnabling modularization through OSGi and SpringDM
Enabling modularization through OSGi and SpringDM
 
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...
 
Spring basics for freshers
Spring basics for freshersSpring basics for freshers
Spring basics for freshers
 
Liferay Module Framework
Liferay Module FrameworkLiferay Module Framework
Liferay Module Framework
 
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 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
 
What is os gi and what does osgi
What is os gi and what does osgiWhat is os gi and what does osgi
What is os gi and what does osgi
 
Framework adoption for java enterprise application development
Framework adoption for java enterprise application developmentFramework adoption for java enterprise application development
Framework adoption for java enterprise application development
 
OSGi DevCon 2009 Review
OSGi DevCon 2009 ReviewOSGi DevCon 2009 Review
OSGi DevCon 2009 Review
 
SCOM 2012 & SCCM 2012
SCOM 2012 & SCCM 2012SCOM 2012 & SCCM 2012
SCOM 2012 & SCCM 2012
 
OSGi-enabled Java EE applications in GlassFish
OSGi-enabled Java EE applications in GlassFishOSGi-enabled Java EE applications in GlassFish
OSGi-enabled Java EE applications in GlassFish
 
Introduction to Software-defined Networking
Introduction to Software-defined NetworkingIntroduction to Software-defined Networking
Introduction to Software-defined Networking
 
Liberate your components with OSGi services - Graham Charters
Liberate your components with OSGi services - Graham ChartersLiberate your components with OSGi services - Graham Charters
Liberate your components with OSGi services - Graham Charters
 
OSGi-enabled Java EE Applications using GlassFish
OSGi-enabled Java EE Applications using GlassFishOSGi-enabled Java EE Applications using GlassFish
OSGi-enabled Java EE Applications using GlassFish
 
Beyond OSGi Software Architecture
Beyond OSGi Software ArchitectureBeyond OSGi Software Architecture
Beyond OSGi Software Architecture
 
Framework
FrameworkFramework
Framework
 
Cisco Data Center Orchestration Solution
Cisco Data Center Orchestration SolutionCisco Data Center Orchestration Solution
Cisco Data Center Orchestration Solution
 

Kürzlich hochgeladen

My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 

Kürzlich hochgeladen (20)

My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 

Introduction To OSGi

  • 1. Introduction to OSGi Chris Custine ccustine@apache.org Denver Java User Group - November 12, 2008 1
  • 2. Introduction - Chris Custine Apache ServiceMix - Committer Open Source ESB JBI 1.0 Implementation ServiceMix 4 - OSGi Based (Apache Felix) Apache Directory Server - Committer and PMC Member LDAP v3 Certified 100% Java Soon to be OSGi, but currently used in some OSGi services Organic Element - Open Source Consulting and Software Development 2
  • 3. Presentation Agenda OSGi Overview and History OSGi Architecture and Layers Best Practices Recommended Tools 3
  • 4. What is OSGi? OSGi - Formerly Open Services Gateway Initiative Now just OSGi due to generalization of market OSGi Alliance - Consortium of Vendors 4
  • 5. What Does the OSGi Alliance Do? Defines OSGi Service Platform specification Multiple groups define the specifications Core Platform Expert Group (CPEG) – Core framework Mobile Expert Group (MEG) – Mobile Vehicle Expert Group (VEG) – Automotive Enterprise Expert Group (EEG) – Enterprise Residential Expert Group (REG) – Home Automation 5
  • 6. Where did OSGi come from? Originally aimed at Home Automation market Home Gateway device to monitor and interact with devices Multi vendor devices connected throughout the home 6
  • 7. Where did OSGi come from? Requirement for standard plugin model for Gateway device GUI Model for administration of devices Services available to devices Data storage Conversion Network Software management and deployment Software updates Security Services only available to same device/vendor Only allow updates from properly signed jar “Hello, this is your refrigerator... you need to buy milk” 7
  • 8. How we got here Original use case (Home Automation) faltered around 2000 OSGi used in niche areas (automotive, mobile) for several years Eclipse 3.0 released June 2004 - First Eclipse with OSGi Gradual adoption and recognition for OSGi after Eclipse Currently undergoing widespread adoption 8
  • 9. OSGi is... About building systems from smaller components Components working together Managing components 9
  • 10. Why OSGi? Convergence of mobile and embedded devices creates huge manageability problems Portability - Hardware, OS Management - Massive pushes for updates and fixes Maintenance - Dynamic library management and dependencies causing unmanageable hacks like Class.forName() 10
  • 11. OSGi Relationship with Java Always focused on Java Bundles may contain native libraries used via JNI Example: Eclipse uses native libraries for SWT GUI calls RFC-119 for distributed OSGi allows communication with external systems (possibly not Java) Script language support from bundle providers 11
  • 12. OSGi Service Platform Two distinct specifications Core Specification - Core framework, packaging, modularity, security, API (interfaces), etc. Service Compendium - Additional services (some optional), utilities, logging, event system, configuration admin, etc. 12
  • 13. OSGi Architecture and Layers Service Lifecycle Security Bundles Module Execution Environment Hardware / OS 13
  • 14. Java Execution Environment Managing the runtime environment Service What do I require to run? Lifecycle Security Bundles JRE Level Module Execution Environment GUI Requirements Hardware / OS Matching application requirements with the platform 14
  • 15. Module Layer Packaging and deployment standards Service Lifecycle Security Specify constraints on Bundles Module dependencies and requirements Execution Environment Hardware / OS Visibility between components 15
  • 16. Lifecycle Layer Fine grained events for application and component Service lifecycle Lifecycle Security Bundles Module Installing, starting, stopping Execution Environment Standard API for registering, Hardware / OS listening, and acting on events No custom API needed for plugins and extensions 16
  • 17. Services Layer Standard methods for registering service instances Service Lifecycle Security Discover and bind to services Bundles Module from other components Execution Environment Hardware / OS Reference tracking 17
  • 18. Security Layer Protect Visibility between components Service Lifecycle Security Example: Vendor A only wants to Bundles Module use the XYZ service provided by Execution Environment Vendor A (could be multiple other Hardware / OS implementations of XYZ) Constraints can be expressed using certificates from signed jars or attributes for bundle, service, etc. 18
  • 19. Layer Details Module, Lifecycle, and Service layers are where most work is done for enterprise Java development Security is important but not as widely utilized 19
  • 20. Java Modularity Limitations Scoping and visibility is limited to packages (no module scoping) Dependency management? Managed through classpath Version handling? First package match on classpath Modularity is not supported as a first class citizen 20
  • 21. Module Layer Bundles are the primary building block Service Lifecycle Security Package visibility and sharing Bundles Module Security constraints on packages Execution Environment Hardware / OS Classloader per bundle Graph of classloaders, resolved at deploy time 21
  • 22. Module Layer Bundle - Just a jar file Service Lifecycle Security Bundles META-INF/manifest.mf Module Execution Environment Hardware / OS Dependencies Versioning Consistency Manifest-Version: 1.0 Import-Package: ... Export-Package: ... Bundle-Activator: ... Bundle-Version: 1.1.0.SNAPSHOT Bundle-Name: ... Bundle-ManifestVersion: 2 Bundle-SymbolicName: ... 22
  • 23. Module Layer - Example Manifest META-INF/manifest.mf Bundle-ManifestVersion: 2 Bundle-SymbolicName: org.apache.servicemix.kernel.filemonitor Bundle-Version: 1.1.0.SNAPSHOT Import-Package: org.apache.commons.logging,org.apache.servicemix.kerne l.filemonitor,org.osgi.framework,org.osgi.service.cm;version=quot;1.2quot;,or g.osgi.service.packageadmin,org.osgi.util.tracker;version=quot;1.3quot; Export-Package: org.apache.servicemix.kernel.filemonitor;uses:=quot;org.os gi.framework,org.apache.commons.logging,org.osgi.service.cm,org.osgi. Text service.packageadmin,org.osgi.util.trackerquot; Bundle-Activator: org.apache.servicemix.kernel.filemonitor.FileMonitorActivator Bundle-Name: Apache ServiceMix Kernel :: File Monitor Bundle-Description: This bundle monitors the deploy directory for new OSGi bundles in jar form, expanded form or for configuration f ile changes and undeploys/redeploys them 23
  • 24. Module Layer - Example Manifest META-INF/manifest.mf Bundle-ManifestVersion: 2 Bundle-SymbolicName: org.apache.servicemix.kernel.filemonitor Bundle-Version: 1.1.0.SNAPSHOT Import-Package: org.apache.commons.logging,org.apache.servicemix.kerne l.filemonitor,org.osgi.framework,org.osgi.service.cm;version=quot;1.2quot;,or g.osgi.service.packageadmin,org.osgi.util.tracker;version=quot;1.3quot; Export-Package: org.apache.servicemix.kernel.filemonitor;uses:=quot;org.os gi.framework,org.apache.commons.logging,org.osgi.service.cm,org.osgi. Text service.packageadmin,org.osgi.util.trackerquot; Bundle-Activator: org.apache.servicemix.kernel.filemonitor.FileMonitorActivator Bundle-Name: Apache ServiceMix Kernel :: File Monitor Bundle-Description: This bundle monitors the deploy directory for new OSGi bundles in jar form, expanded form or for configuration f ile changes and undeploys/redeploys them 24
  • 25. Module Layer - Example Manifest META-INF/manifest.mf Bundle-ManifestVersion: 2 Bundle-SymbolicName: org.apache.servicemix.kernel.filemonitor Bundle-Version: 1.1.0.SNAPSHOT Import-Package: org.apache.commons.logging,org.apache.servicemix.kerne l.filemonitor,org.osgi.framework,org.osgi.service.cm;version=quot;1.2quot;,or g.osgi.service.packageadmin,org.osgi.util.tracker;version=quot;1.3quot; Export-Package: org.apache.servicemix.kernel.filemonitor;uses:=quot;org.os gi.framework,org.apache.commons.logging,org.osgi.service.cm,org.osgi. Text service.packageadmin,org.osgi.util.trackerquot; Bundle-Activator: org.apache.servicemix.kernel.filemonitor.FileMonitorActivator Bundle-Name: Apache ServiceMix Kernel :: File Monitor Bundle-Description: This bundle monitors the deploy directory for new OSGi bundles in jar form, expanded form or for configuration f ile changes and undeploys/redeploys them 25
  • 26. Module Layer - Example Manifest META-INF/manifest.mf Bundle-ManifestVersion: 2 Bundle-SymbolicName: org.apache.servicemix.kernel.filemonitor Bundle-Version: 1.1.0.SNAPSHOT Import-Package: org.apache.commons.logging,org.apache.servicemix.kerne l.filemonitor,org.osgi.framework,org.osgi.service.cm;version=quot;1.2quot;,or g.osgi.service.packageadmin,org.osgi.util.tracker;version=quot;1.3quot; Export-Package: org.apache.servicemix.kernel.filemonitor;uses:=quot;org.os gi.framework,org.apache.commons.logging,org.osgi.service.cm,org.osgi. Text service.packageadmin,org.osgi.util.trackerquot; Bundle-Activator: org.apache.servicemix.kernel.filemonitor.FileMonitorActivator Bundle-Name: Apache ServiceMix Kernel :: File Monitor Bundle-Description: This bundle monitors the deploy directory for new OSGi bundles in jar form, expanded form or for configuration f ile changes and undeploys/redeploys them 26
  • 27. Module Layer - Example Manifest META-INF/manifest.mf Bundle-ManifestVersion: 2 Bundle-SymbolicName: org.apache.servicemix.kernel.filemonitor Bundle-Version: 1.1.0.SNAPSHOT Import-Package: org.apache.commons.logging,org.apache.servicemix.kerne l.filemonitor,org.osgi.framework,org.osgi.service.cm;version=quot;1.2quot;,or g.osgi.service.packageadmin,org.osgi.util.tracker;version=quot;1.3quot; Export-Package: org.apache.servicemix.kernel.filemonitor;uses:=quot;org.os gi.framework,org.apache.commons.logging,org.osgi.service.cm,org.osgi. Text service.packageadmin,org.osgi.util.trackerquot; Bundle-Activator: org.apache.servicemix.kernel.filemonitor.FileMonitorActivator Bundle-Name: Apache ServiceMix Kernel :: File Monitor Bundle-Description: This bundle monitors the deploy directory for new OSGi bundles in jar form, expanded form or for configuration f ile changes and undeploys/redeploys them 27
  • 28. Module Layer - Example Manifest META-INF/manifest.mf Bundle-ManifestVersion: 2 Bundle-SymbolicName: org.apache.servicemix.kernel.filemonitor Bundle-Version: 1.1.0.SNAPSHOT Import-Package: org.apache.commons.logging,org.apache.servicemix.kerne l.filemonitor,org.osgi.framework,org.osgi.service.cm;version=quot;1.2quot;,or g.osgi.service.packageadmin,org.osgi.util.tracker;version=quot;1.3quot; Export-Package: org.apache.servicemix.kernel.filemonitor;uses:=quot;org.os gi.framework,org.apache.commons.logging,org.osgi.service.cm,org.osgi. Text service.packageadmin,org.osgi.util.trackerquot; Bundle-Activator: org.apache.servicemix.kernel.filemonitor.FileMonitorActivator Bundle-Name: Apache ServiceMix Kernel :: File Monitor Bundle-Description: This bundle monitors the deploy directory for new OSGi bundles in jar form, expanded form or for configuration f ile changes and undeploys/redeploys them 28
  • 29. Module Layer - Bundle Contents Bundles may contain additional contents not usually included in jars. Native code - Multiple platforms, OS, etc. loading rules specified in manifest Embedded jar files - Bundle-Classpath allows embedded jars to be referenced from manifest.mf (not recommended) Resource files - images, configuration, html 29
  • 30. Module Layer - Bundle State install update INSTALLED uninstall resolve uninstall UNINSTALLED RESOLVED start STARTING STOPPING stop ACTIVE 30
  • 31. Module Layer - Bundle State Resolution of dependencies at deployment install INSTALLED update If resolution fails, bundle is not uninstall resolve uninstall UNINSTALLED RESOLVED available for use start STARTING STOPPING stop No runtime CNFE ACTIVE Services and lifecycle not called until AFTER resolution 31
  • 32. Module Layer - Resolution Goodies Exporters can name arbitrary attributes for matching Attributes can be mandatory for matching org.apache.mypackagea-1.0.0.jar org.apache.mypackageb-1.0.0.jar META-INF/manifest.mf META-INF/manifest.mf Export-Package: Export-Package: org.apache.mypackage; org.apache.mypackage; version=”1.0.0” version=”1.0.0”;flavor=”vanilla” org.apache.bundlea-1.0.0.jar META-INF/manifest.mf Import-Package: org.apache.mypackage; version=”1.0.0”;flavor=”vanilla” 32
  • 33. Module Layer - Resolution Goodies Same package can be installed with different versions Importers can specify version ranges for compatibility Allows staged migration of multiple components org.apache.mypackage-1.0.1.jar org.apache.mypackage-2.0.0.jar META-INF/manifest.mf META-INF/manifest.mf Export-Package: Export-Package: org.apache.mypackage; org.apache.mypackage; version=”1.0.1” version=”2.0.0” org.apache.bundlea-1.0.0.jar META-INF/manifest.mf Import-Package: org.apache.mypackage; version=”[1.0.1,2.0.0)” 33
  • 34. Lifecycle Layer Bundle-Activator: Like main() for Service your bundle. Lifecycle Security Bundles Bundles can tap into the lifecycle Module Execution Environment events of the framework Hardware / OS Extremely powerful when combined with startlevel features Ability to register listeners for bundle state changes 34
  • 35. Lifecycle Layer Bundle activation provides the Service bundle context to the bundle Lifecycle Security Bundles Module Bundle context provides access Execution Environment Hardware / OS to the framework and all services Creates and registers service instances Get reference to required services Register listeners for bundle lifecycle BundleActivator.java package org.osgi.framework; public interface BundleActivator { public void start(BundleContext context) throws Exception; public void stop(BundleContext context) throws Exception; } 35
  • 36. Service Layer Primary means of collaboration between components Service Lifecycle Security Service Registry for discovering Bundles Module and binding to services Execution Environment Hardware / OS Ability to listen for services (Service Tracker) Service oriented model for in VM interactions RFC-119 Brings distributed services across instances 36
  • 37. Start Level Service Setting bundle start order Similar to Unix init scripts Start level can be changed up and down at runtime Persistent start level on restarts 37
  • 38. OSGi Compendium Services Log Service UPnP Http Service Declarative Services Device Access Event Admin Configuration Admin Deployment Admin Metatype Service Auto Configuration Preferences Service Application Admin User Admin DMT Admin Wire Admin Monitor Admin IO Connector Service Tracker Initial Provisioning 38
  • 39. Configuration Admin Configuration provided by framework service Notification to bundles when configuration changed 39
  • 40. Best Practices Use package names consistently - We use package name for artifact name (Eclipse plugins do too), with one package heirarchy per bundle. Quick recognition of artifact and package purpose. Keep public and private classes in separate packages Use explicit Import-Package. Don’t use Require-Bundle. Easy to use initially, but causes problems down the road. Avoid Dynamic-Import - Defers classloading to runtime Allows arbitrary Class.forName() use case but causes trouble Use tools to compose manifest files and package bundles (Maven plugins, Eclipse PDE, etc.) 40
  • 41. Tools for OSGi - BND Peter Kriens - BND Tool for analyzing dependencies and validating manifest.mf Uses reflection to analyze imports and lists dependencies Great tool for analyzing non-OSGi jar files and converting 41
  • 42. Tools for OSGi - Maven Felix Plugin Uses BND to automate creation of manifest.mf Use packaging=bundle to invoke plugin in package lifecycle pom.xml <plugin> <groupId>org.apache.felix</groupId> <artifactId>maven-bundle-plugin</artifactId> <configuration> <instructions> <Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName> <Export-Package>org.apache.servicemix.kernel.gshell.activemq;version=${project.version};- split-package:=merge-first</Export-Package> <Import-Package> org.apache.geronimo.gshell.wisdom.command, org.apache.servicemix.kernel.gshell.core, org.apache.geronimo.gshell.wisdom.registry, * </Import-Package> <Private-Package>!*</Private-Package> <Spring-Context>*;publish-context:=false;create-asynchronously:=false</Spring-Context> </instructions> </configuration> </plugin> 42
  • 43. Tools for OSGi - Spring DM SpringDM bridges the Spring world with OSGi Service Platform Reuse existing knowledge of Spring Limited knowledge of OSGi required Expose spring beans in the OSGi Service Registry Can be bound to by pure OSGi service consumers Lookup and bind bean refs to OSGi services 43
  • 44. Tools for OSGi - Spring DM Example: ActiveMQ broker definition using SpringDM and OSGi broker.xml <bean id=quot;pooledConnectionFactoryquot; class=quot;org.apache.activemq.pool.PooledConnectionFactoryBeanquot;> <property name=quot;maxConnectionsquot; value=quot;8quot; /> <property name=quot;transactionManagerquot; ref=quot;transactionManagerquot; /> <property name=quot;connectionFactoryquot; ref=quot;activemqConnectionFactoryquot; /> <property name=quot;resourceNamequot; value=quot;activemq.${name}quot; /> </bean> <osgi:reference id=quot;transactionManagerquot; interface=quot;javax.transaction.TransactionManagerquot; cardinality=quot;0..1quot;/> <osgi:service ref=quot;pooledConnectionFactoryquot;> <osgi:interfaces> <value>javax.jms.ConnectionFactory</value> </osgi:interfaces> <osgi:service-properties> <entry key=quot;namequot; value=quot;${name}quot;/> </osgi:service-properties> </osgi:service> 44
  • 45. Tools for OSGi - Spring DM Example: Using OSGi Configuration Admin for Property Placeholder beans.xml <bean id=quot;myTransformquot; class=quot;org.apache.servicemix.examples.camel.MyTransformquot;> <property name=quot;prefixquot; value=quot;${prefix}quot;/> </bean> <osgix:property-placeholder persistent-id=quot;org.apache.servicemix.examplesquot;> <osgix:default-properties> <prop key=quot;prefixquot;>MyTransform</prop> </osgix:default-properties> </osgix:property-placeholder> 45
  • 46. Conclusion OSGi forces planning and engineering of bundle interactions More work up front, but rewards come later No silver bullet, bad code and bad ideas are still bad Many built in features and services provided for applications Modularization is rewarded when creating new systems and modifying existing ones 46
  • 47. Tour of ServiceMix 4 OSGi Features 47