SlideShare una empresa de Scribd logo
1 de 78
Descargar para leer sin conexión
OSGi
 Embrace          Change
A Developer's Quickstart

       Carsten Ziegeler
    cziegeler@apache.org
About
• Member of the ASF
  – Sling, Felix, Cocoon, Portals, Sanselan,
    Excalibur, Incubator
  – PMC: Felix, Portals, Cocoon, Incubator,
    Excalibur (Chair)
• RnD Team at Day Software
• Article/Book Author, Technical Reviewer
• JSR 286 Spec Group (Portlet API 2.0)


                                               2
Agenda
1 Motivation
2 And Action...
3 Why OSGi?
4 Apache Felix
5-7 Bundles, Services, Dynamics
8 Famous Final Words



                                  3

1 Example Application
   Motivation
               


                        4
Motivation
• Modularity is key
  – Manage growing complexity
  – Support dynamic extensibility
• No solution in standard Java
  – OSGi: tried and trusted
• Embrace change – Embrace OSGi
  – Only a few concepts – easy to get started




                                                5

2 Example Action...
   And Application
           


                  6
Paint Program
• Swing-based paint program
• Interface SimpleShape for drawing
  – Different implementations
  – Each shape has name and icon properties
  – Available shapes are displayed in tool bar
• Select shape and then select location
  – Shapes can be dragged, but not resized
• Support dynamic deployment of shapes



                                                 7
Shape Abstraction
• Conceptual SimpleShape interface

public interface SimpleShape
{
    /**
     * Method to draw the shape of the service.
     * @param g2 The graphics object used for
     *           painting.
     * @param p The position to paint the shape.
    **/
    public void draw(Graphics2D g2, Point p);
}




                                               8
Paint Program Mock Up




                        9
High-Level Architecture

          1   1               1   *
Shape              Drawing            Default
Tracker             Frame             Shape
                  1    1               1

                  1    *               1

                    Shape             Simple
                  Component           Shape




                                                10
High-Level Architecture
                   Best practice – Try to
                    centralize interaction
                   with OSGi API * that
                                    so
          1   1              1
Shape            Drawing componentsDefault
                     other
Tracker           Frame POJOs...only     Shape
                    remain
                     Shape Tracker will 1
                1     1
                  interact with OSGi API.
                 1     *                1

                  Shape                Simple
                Component              Shape




                                                 11
High-Level Architecture

          1      1              1     *
Shape                Drawing              Default
Tracker               Frame               Shape
                     1    1                1

                     1    *                1
                 Main application
                  window – gets
                       Shape              Simple
              dynamically injected
                    Component             Shape
              with available shapes
                 from the Shape
                     Tracker.

                                                    12
High-Level Architecture

          1     1               1   *
Shape               Drawing             Default
Tracker              Frame              Shape
                    1   1                1

                    1   *                1

                       Shape            Simple
                Actual shape
                    Component           Shape
              implementation.



                                                  13
High-Level Architecture

    Injected “proxied” shape
           1     1              1   *
     implementation to hide
Shape                 Drawing           Default
      aspects of dynamism
Tracker                Frame            Shape
      and provide a default
        implementation. 1
                     1                   1

                   1     *               1

                      Shape             Simple
               Actual shape
                   Component            Shape
             implementation.



                                                  14
High-Level Architecture
           Component that draws the
          shape in parent frame; looks
          up shape via Drawing 1
          1     1                      *
Shape                 Drawing Frame        Default
Tracker                Frame               Shape
           rather than having a direct
                    reference.
                    1     1                 1

                    1     *                 1

                     Shape                 Simple
                   Component               Shape




                                                     15

    LIVE DEMO
    Example Application

                 


                          16

3 Example Application
   Why OSGi?
               


                        17
Class Path Hell




• Can you spot some potential problems?




                                      18
Class Path Hell




• What libs are used? Versions?
• Which jar is used? Version?
• No difference between private and public
  classes

                                        19
Java's Shortcomings
• Simplistic version handling
  – “First” class from class path
  – JAR files assume backwards compatibility at
    best
• Implicit dependencies
  – Dependencies are implicit in class path
    ordering
  – JAR files add improvements for extensions,
    but cannot control visibility



                                            20
Java's Shortcomings
• Split packages by default
  – Class path approach searches until it finds,
    which leads to shadowing or version mixing
• Limited scoping mechanisms
  – No module access modifier
  – Impossible to declare all private stuff as
    private
• Missing module concept
  – Classes are too fine grained, packages are
    too simplistic, class loaders are too low level
• No deployment/lifecycle support
                                                 21
Java Dynamism Limitations
• Low-level support for dynamics
  – Class loaders are complicated to use and
    error prone
• Support for dynamics is still purely
  manual
  – Must be completely managed by the
    programmer
  – Leads to many ad hoc, incompatible
    solutions
• Limited deployment support

                                               22
OSGi Technology
• Adds modularity and dynamics
  – Module concept
    • Explicit sharing (importing and exporting)
  – Automatic management of code
    dependencies
    • Enforces sophisticated consistency rules for class
      loading
  – Life-cycle management
    • Manages dynamic deployment and configuration
• Service Registry
  – Publish/find/bind

                                                    23

4 Example Application
   Apache Felix
             


                   24
OSGi Alliance
• Industry consortium
• OSGi Service Platform specification
  – Framework specification for hosting
    dynamically downloadable services
  – Standard service specifications
• Several expert groups define the
  specifications
  – Core Platform Expert Group (CPEG)
  – Mobile Expert Group (MEG)
  – Vehicle Expert Group (VEG)
  – Enterprise Expert Group (EEG)
                                          25
Apache Felix
• Top-level project (March 2007)
• Healthy and diverse community
• OSGi R4 (R4.1) implementation
  – Framework (frequent releases)
  – Services (continued development)
    • Log, Package Admin, Event Admin,
      Configuration Admin, Declarative Services,
      Meta Type, Deployment Admin (and more)
  – Moving towards upcoming R4.2
• Tools
  – Maven Plugins, Web Console, iPojo
                                                   26
Apache Felix
• Growing community
  – Several code grants and contributions
  – Various (Apache) projects use Felix / have
    expressed interest in Felix and/or OSGi
    • e.g., ServiceMix, Directory, Sling, Tuscany
• Roadmap
  – Continue toward R4 and R4.1 compliance
    • some parts consider pre R4.2 already




                                                    27

5 Example Application 1
   OSGi – Part
   Bundles     


                     28
OSGi Architectural Overview



              Bundle




                                               k
                                             or
                                           ew
                                          ma
                                        Fr
                               OSGi
                        Java
         Operating System
    Driver     Driver          Driver

             Hardware
                                                   29
OSGi Framework Layering
                 L3 – Provides a publish/find/bind service model to
 SERVICE MODEL   decouple bundles


                 L2 - Manages the life cycle of bundle in a bundle
                 repository without requiring the VM be restarted
   LIFECYCLE


                 L1 - Creates the concept of modules (aka. bundles)
                 that use classes from each other in a controlled way
    MODULE       according to system and bundle constraints




  Execution      L0 -
                 •OSGi Minimum Execution Environment
 Environment
       CDC       •CDC/Foundation
        CDC      •JavaSE




                                                                     30
OSGi Framework
• Component-oriented framework
• Module concept: Bundles
  – Separate class loader -> graph
  – Package sharing and version management
  – Life-cycle management and notification
• Dynamic!
  – Install, update, and uninstall at runtime
• Runs multiple applications and services in
  a single VM

                                                31
OSGi Modularity
• Explicit code boundaries and
  dependencies
  – Package imports and exports
• Multi-version support
  – Version ranges for dependencies
• Class space is managed by OSGi
• Managed life cycle
  – Dynamic install, update, uninstall



                                         32
OSGi Modularity - Example
• Dynamic module deployment and
  dependency resolution




                Provided package

                                   existing
                                   bundle

               OSGi framework



                                          33
OSGi Modularity - Example
• Dynamic module deployment and
  dependency resolution




                                  existing
                                  bundle
  install
bundle.jar
               OSGi framework

                                         34
OSGi Modularity - Example
• Dynamic module deployment and
  dependency resolution




                                  existing
       resolve                    bundle
       bundle


                 OSGi framework

                                         35
OSGi Modularity - Example
• Dynamic module deployment and
  dependency resolution




                   automatic package
                 dependency resolution   existing
                                         bundle


               OSGi framework

                                                36
Creating a Bundle
• Plain old JAR with additional metadata in
  the manifest
  – Bundle identifier, version, exports, imports
• Tools
  – Text editor (Manifest)
  – Eclipse (PDE)
  – Bundle packaging tools
     • BND from Peter Kriens
     • Apache Felix maven-bundle-plugin based on
       BND


                                               37
Maven is Your Friend
• Apache Felix Maven Bundle Plugin
• Creates metadata based on POM
  – Automatically: import packages
  – Manually: export and private packages
• Analyses classes for consistency
• Allows to include dependencies
• Creates final bundle JAR file



                                            38
Maven Bundle Plugin Sample
 <artifactId>org.apache.sling.engine</artifactId>
 <packaging>bundle</packaging>
 <version>2.0.3-incubator-SNAPSHOT</version>
 <build>
   <plugins>
     <plugin>
       <groupId>org.apache.felix</groupId>
       <artifactId>maven-bundle-plugin</artifactId>
       <extensions>true</extensions>
       <configuration>
         <instructions>
           <Export-Package>
              org.apache.sling.engine;version=${pom.version}
           </Export-Package>
           <Private-Package>
              org.apache.sling.engine.impl
           </Private-Package>
           <Embed-Dependency>
              commons-fileupload
           </Embed-Dependency>
         </instructions>


                                                               39
Maven Bundle Plugin Sample
 <artifactId>org.apache.sling.engine</artifactId>
 <packaging>bundle</packaging>
 <version>2.0.3-incubator-SNAPSHOT</version>
 <build>
   <plugins>
     <plugin>
       <groupId>org.apache.felix</groupId>
       <artifactId>maven-bundle-plugin</artifactId>
       <extensions>true</extensions>
       <configuration>
         <instructions>
           <Export-Package>
              org.apache.sling.engine;version=${pom.version}
           </Export-Package>
           <Private-Package>
              org.apache.sling.engine.impl
           </Private-Package>
           <Embed-Dependency>
              commons-fileupload
           </Embed-Dependency>
         </instructions>


                                                               40
Maven Bundle Plugin Sample
 <artifactId>org.apache.sling.engine</artifactId>
 <packaging>bundle</packaging>
 <version>2.0.3-incubator-SNAPSHOT</version>
 <build>
   <plugins>
     <plugin>
       <groupId>org.apache.felix</groupId>
       <artifactId>maven-bundle-plugin</artifactId>
       <extensions>true</extensions>
       <configuration>
         <instructions>
           <Export-Package>
              org.apache.sling.engine;version=${pom.version}
           </Export-Package>
           <Private-Package>
              org.apache.sling.engine.impl
           </Private-Package>
           <Embed-Dependency>
              commons-fileupload
           </Embed-Dependency>
         </instructions>


                                                               41
Maven Bundle Plugin Sample
 <artifactId>org.apache.sling.engine</artifactId>
 <packaging>bundle</packaging>
 <version>2.0.3-incubator-SNAPSHOT</version>
 <build>
   <plugins>
     <plugin>
       <groupId>org.apache.felix</groupId>
       <artifactId>maven-bundle-plugin</artifactId>
       <extensions>true</extensions>
       <configuration>
         <instructions>
           <Export-Package>
              org.apache.sling.engine;version=${pom.version}
           </Export-Package>
           <Private-Package>
              org.apache.sling.engine.impl
           </Private-Package>
           <Embed-Dependency>
              commons-fileupload
           </Embed-Dependency>
         </instructions>


                                                               42
Be Modular!
• Create clean package spaces
  – public vs private
• Provide Bundles
  – Add manifest information
• Think about dependencies
  – Additional bundle vs include
  – Optional
  – Version ranges
• Benefits even without OSGi

                                   43

6 Example Application 2
   OSGi – Part
   Services    


                     44
OSGi Services (1/3)
• Service-oriented architecture
  – Publish/find/bind
  – Possible to use modules without services
                   Service
                   Registry
                                   Find
       Publish
                     Service
                    Description

                                   Service
     Service
                                  Requester
     Provider        Interact



                                               45
OSGi Services (2/3)
• An OSGi application is...
  – A collection of bundles that interact via
    service interfaces
  – Bundles may be independently developed
    and deployed
  – Bundles and their associated services may
    appear or disappear at any time

• Resulting application follows a Service-
  Oriented Component Model approach

                                            46
OSGi Services (3/3)
• Dynamic service lookup



                   Provided service


                 Provided package

                                       existing
                                        bundle
                                      component

                OSGi framework

                                             47
OSGi Services (3/3)
• Dynamic service lookup




                                     existing
                                      bundle
  install                           component
bundle.jar
                   OSGi framework

                                           48
OSGi Services (3/3)
• Dynamic service lookup




                                     existing
        activate                      bundle
        bundle                      component

                   OSGi framework

                                           49
OSGi Services (3/3)
• Dynamic service lookup




                    automatic package
                  dependency resolution    existing
                                            bundle
                                          component

                OSGi framework

                                                 50
OSGi Services (3/3)
• Dynamic service lookup




                     manual service
                  dependency resolution


                                           existing
                                            bundle
                                          component

                OSGi framework

                                                 51
OSGi Services Advantages
• Lightweight services
   – Lookup is based on interface name
  – Direct method invocation
• Good design practice
  – Separates interface from implementation
  – Enables reuse, substitutability, loose coupling,
    and late binding




                                                   52
OSGi Services Advantages
• Dynamic
   – Loose coupling and late binding
• Application's configuration is simply the set of
  deployed bundles
   – Deploy only the bundles that you need




                                                 53
OSGi Services Issues
• More sophisticated, but more complicated
  – Requires a different way of thinking
     • Things might appear/disappear at any moment
  – Must manually resolve and track services
• There is help
  – Service Tracker
     • Still somewhat of a manual approach
  – Declarative Services, Spring DM, iPOJO
     • Sophisticated service-oriented component
       frameworks
     • Automated dependency injection and more
     • More modern, POJO-oriented approaches
                                                  54

7 Example Application 3
   OSGi – Part
   Dynamics    


                     55
Everything is a Bundle
• How to structure bundles?
  – API vs implementation bundle
  – Fine-grained vs coarse-grained
  – No “One Size Fits All”
• Simple Rules
  – Stable code vs changing code
  – Optional parts




                                     56
Third Party Libraries
• Use as bundles
  – Project delivers already a bundle
     • Apache Commons, Apache Sling etc.
  – Use special bundle repositories
     • Felix Commons, Spring etc.
     • But check included metadata!
  – Create your own wrapper
     • Easy with the Felix maven bundle plugin
• Include in your bundle
  – Again: easy with the Felix maven bundle
    plugin
                                                 57
Everything is Dynamic
• Bundles can come and go!
  – Packages
  – Services
• Services can come and go!
• Be prepaired!
  – Application code must handle dynamics!




                                             58
Dynamic Services
• OSGi Declarative Services Specification
  – XML Configuration
    • Contained in bundle
    • Manifest entry pointing to config(s)
  – Publishing services
  – Consuming services
    • Policy (static,dynamic), cardinality (0..1, 1..1, 0..n)
  – Default configuration
  – Service Lifecycle management
• Various Implementations
  – Apache Felix SCR
                                                        59
Dynamic Services Configuration
<scr:component enabled=quot;truequot;
         name=quot;org.apache.sling.event.impl.DistributingEventHandlerquot;>

  <implementation
       class=quot;org.apache.sling.event.impl.DistributingEventHandlerquot;/>

  <service servicefactory=quot;falsequot;>
    <provide interface=quot;org.osgi.service.event.EventHandlerquot;/>
  </service>

  <property name=quot;repository.pathquot; value=quot;/var/eventing/distributionquot;/>
  <property name=quot;cleanup.periodquot; type=quot;Integerquot; value=quot;15quot;/>

  <reference name=quot;threadPoolquot;
             interface=quot;org.apache.sling.event.ThreadPoolquot;
             cardinality=quot;1..1quot; policy=quot;staticquot;
             bind=quot;bindThreadPoolquot; unbind=quot;unbindThreadPoolquot;/>




                                                                    60
Dynamic Services Configuration
<scr:component enabled=quot;truequot;
         name=quot;org.apache.sling.event.impl.DistributingEventHandlerquot;>

  <implementation
       class=quot;org.apache.sling.event.impl.DistributingEventHandlerquot;/>

  <service servicefactory=quot;falsequot;>
    <provide interface=quot;org.osgi.service.event.EventHandlerquot;/>
  </service>

  <property name=quot;repository.pathquot; value=quot;/var/eventing/distributionquot;/>
  <property name=quot;cleanup.periodquot; type=quot;Integerquot; value=quot;15quot;/>

  <reference name=quot;threadPoolquot;
             interface=quot;org.apache.sling.event.ThreadPoolquot;
             cardinality=quot;1..1quot; policy=quot;staticquot;
             bind=quot;bindThreadPoolquot; unbind=quot;unbindThreadPoolquot;/>




                                                                    61
Dynamic Services Configuration
<scr:component enabled=quot;truequot;
         name=quot;org.apache.sling.event.impl.DistributingEventHandlerquot;>

  <implementation
       class=quot;org.apache.sling.event.impl.DistributingEventHandlerquot;/>

  <service servicefactory=quot;falsequot;>
    <provide interface=quot;org.osgi.service.event.EventHandlerquot;/>
  </service>

  <property name=quot;repository.pathquot; value=quot;/var/eventing/distributionquot;/>
  <property name=quot;cleanup.periodquot; type=quot;Integerquot; value=quot;15quot;/>

  <reference name=quot;threadPoolquot;
             interface=quot;org.apache.sling.event.ThreadPoolquot;
             cardinality=quot;1..1quot; policy=quot;staticquot;
             bind=quot;bindThreadPoolquot; unbind=quot;unbindThreadPoolquot;/>




                                                                    62
Dynamic Services Configuration
<scr:component enabled=quot;truequot;
         name=quot;org.apache.sling.event.impl.DistributingEventHandlerquot;>

  <implementation
       class=quot;org.apache.sling.event.impl.DistributingEventHandlerquot;/>

  <service servicefactory=quot;falsequot;>
    <provide interface=quot;org.osgi.service.event.EventHandlerquot;/>
  </service>

  <property name=quot;repository.pathquot; value=quot;/var/eventing/distributionquot;/>
  <property name=quot;cleanup.periodquot; type=quot;Integerquot; value=quot;15quot;/>

  <reference name=quot;threadPoolquot;
             interface=quot;org.apache.sling.event.ThreadPoolquot;
             cardinality=quot;1..1quot; policy=quot;staticquot;
             bind=quot;bindThreadPoolquot; unbind=quot;unbindThreadPoolquot;/>




                                                                    63
Declarative Services
• Reads XML configs on bundle start
• Registers services
• Keeps track of dependencies
  – Starts/stops services
• Invokes optional activation and
  deactivation method
  – Provides access to configuration
• Caution: A service is by default only
  started if someone else uses it!
  – Immediate flag forces a service start
                                            64
Example Service
protected ThreadPool threadPool;

protected void activate(ComponentContext context)
throws Exception {
    @SuppressWarnings(quot;uncheckedquot;)
    final Dictionary<String, Object> props = context.getProperties();
    this.cleanupPeriod = (Integer)props.get(quot;cleanup.periodquot;);
    super.activate(context);
}

protected void bindThreadPool(ThreadPool p) {
    this.threadPool = p;
}

protected void unbindThreadPool(ThreadPool p) {
    if ( this.threadPool == p ) {
        this.threadPool = null;
    }
}




                                                                   65
Config Admin and Metatype
• OSGi Config Admin
  –   Configuration Manager
  –   Persistence storage
      API to retrieve/update/remove configs
  –
  –   Works with Declarative Services
• OSGi Metatype Service
  – Description of bundle metadata
  – Description of service configurations
• Various Implementations
  – Apache Felix

                                              66
Maven SCR Plugin
• Combines everything (DS, ConfigAdmin,
  Metatype, Maven)
• Annotation-based (works for 1.4+)
• Annotate components
  – Properties with default values
  – Service providers
  – Services references (policy and cardinality)
• Generates DS XML
• Generates Metatype config
• Generates Java code
                                              67
SCR Plugin Sample
/**
 * @scr.component
 * @scr.property name=quot;repository.pathquot;
                  value=quot;/var/eventing/distributionquot; private=quot;truequot;
 * @scr.service interface=quot;EventHandlerquot;
 */
public class DistributingEventHandler
    implements EventHandler {

    protected static final int DEFAULT_CLEANUP_PERIOD = 15;

    /** @scr.property valueRef=quot;DEFAULT_CLEANUP_PERIODquot; type=quot;Integerquot; */
    protected static final String PROP_CLEANUP_PERIOD = quot;cleanup.periodquot;;

    /** @scr.reference */
    protected ThreadPool threadPool;

    protected void activate(ComponentContext context)
    throws Exception {
        final Dictionary<String, Object> props = context.getProperties();
        this.cleanupPeriod = (Integer)props.get(PROP_CLEANUP_PERIOD);
    }


                                                                      68
Alternatives
• Manually through bundle activator
• Apache Felix iPojo
• Spring Dynamic Modules




                                      69
Handling extensibility
• Two basic implementation strategies
  – Service-based approach
  – Extender model




                                        70
Service Whiteboard Pattern
• Clients register a service interface
• Service tracker for registered services
• Simple, more robust, leverages the OSGi
  service model
• Service whiteboard pattern
  – It is an Inversion of Control pattern




                                            71
Externder Model
• Bundles contain manifest entries
  – Like available service classes
• Custom bundle tracker
  – Keeps track of bundles
  – Specifically, STARTED and STOPPED events
  – Checks bundles manifest data
     • Creates/removes services




                                               72

8 Example Application
   Famous
   Final Words 


                    73
Conclusion
• Modulary and dynamics are required by
  todays applications
• OSGi technology addresses Java's
  limitations in these areas
  – Available today and growing in importance
• Development is straightforward and
  provides immediate benefits
• Apache Felix is ready when you are!



                                            74
Suggestions for Development
• Think about modularity!
    – Clean package space
•   Think about dynamics!
•   Consider OSGi
•   Check out the spec and other projects
•   Minimize dependencies to OSGi
    – but only if it makes sense




                                            75
Suggestions for Using OSGi
• Think about dynamics
  – Optional bundles
  – Optional services
  – Handle these cases
• Use your preferred logging library
  – LogManager takes care
• Use available tooling
• Be part of the community!


                                       76
Check It Out
• Read the OSGi spec
  – Framework
  – Config Admin, Metatype, Declarative
    Services
  – Deployment Admin, OBR
• Download Apache Felix
  – Try tutorials and samples
• Download Apache Sling :)
• Explore the web – embrace OSGi

                                          77
OSGi
Embrace   Change

Questions?

Más contenido relacionado

Similar a Embrace OSGi Apache Con Europe2009

Embrace Change - Embrace OSGi
Embrace Change - Embrace OSGiEmbrace Change - Embrace OSGi
Embrace Change - Embrace OSGiCarsten Ziegeler
 
Browser Object Model and Animations in qooxdoo
Browser Object Model and Animations in qooxdooBrowser Object Model and Animations in qooxdoo
Browser Object Model and Animations in qooxdooSebastian Werner
 
Cgp lecture2 graphics_standard, opengl
Cgp lecture2 graphics_standard, openglCgp lecture2 graphics_standard, opengl
Cgp lecture2 graphics_standard, openglJavkhlan Rentsendorj
 
Domino X Pages 8.5
Domino X Pages 8.5Domino X Pages 8.5
Domino X Pages 8.5John Head
 
E-GEN/iCAN
E-GEN/iCANE-GEN/iCAN
E-GEN/iCANteddi22
 
Flex4 component lifecycle
Flex4 component lifecycleFlex4 component lifecycle
Flex4 component lifecycleRJ Owen
 
MarvinSketch and MarvinView: Tips And Tricks: US UGM 2008
MarvinSketch and MarvinView: Tips And Tricks: US UGM 2008MarvinSketch and MarvinView: Tips And Tricks: US UGM 2008
MarvinSketch and MarvinView: Tips And Tricks: US UGM 2008ChemAxon
 
CG simple openGL point & line-course 2
CG simple openGL point & line-course 2CG simple openGL point & line-course 2
CG simple openGL point & line-course 2fungfung Chen
 
RMI and CORBA Why both are valuable tools
RMI and CORBA Why both are valuable toolsRMI and CORBA Why both are valuable tools
RMI and CORBA Why both are valuable toolselliando dias
 
Flex4 Component Lifecycle
Flex4 Component LifecycleFlex4 Component Lifecycle
Flex4 Component LifecycleEffectiveUI
 
Flex4 Component Lifecycle
Flex4 Component LifecycleFlex4 Component Lifecycle
Flex4 Component LifecycleEffective
 
GMF : Create your graphical DSL - EclipseCon 11
GMF : Create your graphical DSL - EclipseCon 11GMF : Create your graphical DSL - EclipseCon 11
GMF : Create your graphical DSL - EclipseCon 11Chauvin Mariot
 
【Unite 2017 Tokyo】Unity5.6での2D新機能解説
【Unite 2017 Tokyo】Unity5.6での2D新機能解説【Unite 2017 Tokyo】Unity5.6での2D新機能解説
【Unite 2017 Tokyo】Unity5.6での2D新機能解説Unity Technologies Japan K.K.
 
Using Composite Feature Models to Support Agile Software Product Line Evoluti...
Using Composite Feature Models to Support Agile Software Product Line Evoluti...Using Composite Feature Models to Support Agile Software Product Line Evoluti...
Using Composite Feature Models to Support Agile Software Product Line Evoluti...Simon Urli
 
UI5con 2018: UI5 Evolution - The Core Changes
UI5con 2018: UI5 Evolution - The Core ChangesUI5con 2018: UI5 Evolution - The Core Changes
UI5con 2018: UI5 Evolution - The Core ChangesAndreas_Ecker
 
Workshop OSGI PPT
Workshop OSGI PPTWorkshop OSGI PPT
Workshop OSGI PPTSummer Lu
 
Das Universal Theme in APEX 19
Das Universal Theme in APEX 19Das Universal Theme in APEX 19
Das Universal Theme in APEX 19Oliver Lemm
 

Similar a Embrace OSGi Apache Con Europe2009 (20)

Embrace Change - Embrace OSGi
Embrace Change - Embrace OSGiEmbrace Change - Embrace OSGi
Embrace Change - Embrace OSGi
 
Browser Object Model and Animations in qooxdoo
Browser Object Model and Animations in qooxdooBrowser Object Model and Animations in qooxdoo
Browser Object Model and Animations in qooxdoo
 
Cgp lecture2 graphics_standard, opengl
Cgp lecture2 graphics_standard, openglCgp lecture2 graphics_standard, opengl
Cgp lecture2 graphics_standard, opengl
 
Domino X Pages 8.5
Domino X Pages 8.5Domino X Pages 8.5
Domino X Pages 8.5
 
E-GEN/iCAN
E-GEN/iCANE-GEN/iCAN
E-GEN/iCAN
 
Flex4 component lifecycle
Flex4 component lifecycleFlex4 component lifecycle
Flex4 component lifecycle
 
MarvinSketch and MarvinView: Tips And Tricks: US UGM 2008
MarvinSketch and MarvinView: Tips And Tricks: US UGM 2008MarvinSketch and MarvinView: Tips And Tricks: US UGM 2008
MarvinSketch and MarvinView: Tips And Tricks: US UGM 2008
 
Maemo 6 UI Framework
Maemo 6 UI FrameworkMaemo 6 UI Framework
Maemo 6 UI Framework
 
CG simple openGL point & line-course 2
CG simple openGL point & line-course 2CG simple openGL point & line-course 2
CG simple openGL point & line-course 2
 
RMI and CORBA Why both are valuable tools
RMI and CORBA Why both are valuable toolsRMI and CORBA Why both are valuable tools
RMI and CORBA Why both are valuable tools
 
Flex4 Component Lifecycle
Flex4 Component LifecycleFlex4 Component Lifecycle
Flex4 Component Lifecycle
 
Flex4 Component Lifecycle
Flex4 Component LifecycleFlex4 Component Lifecycle
Flex4 Component Lifecycle
 
2D graphics
2D graphics2D graphics
2D graphics
 
GMF : Create your graphical DSL - EclipseCon 11
GMF : Create your graphical DSL - EclipseCon 11GMF : Create your graphical DSL - EclipseCon 11
GMF : Create your graphical DSL - EclipseCon 11
 
【Unite 2017 Tokyo】Unity5.6での2D新機能解説
【Unite 2017 Tokyo】Unity5.6での2D新機能解説【Unite 2017 Tokyo】Unity5.6での2D新機能解説
【Unite 2017 Tokyo】Unity5.6での2D新機能解説
 
Using Composite Feature Models to Support Agile Software Product Line Evoluti...
Using Composite Feature Models to Support Agile Software Product Line Evoluti...Using Composite Feature Models to Support Agile Software Product Line Evoluti...
Using Composite Feature Models to Support Agile Software Product Line Evoluti...
 
UI5con 2018: UI5 Evolution - The Core Changes
UI5con 2018: UI5 Evolution - The Core ChangesUI5con 2018: UI5 Evolution - The Core Changes
UI5con 2018: UI5 Evolution - The Core Changes
 
Workshop OSGI PPT
Workshop OSGI PPTWorkshop OSGI PPT
Workshop OSGI PPT
 
Pc54
Pc54Pc54
Pc54
 
Das Universal Theme in APEX 19
Das Universal Theme in APEX 19Das Universal Theme in APEX 19
Das Universal Theme in APEX 19
 

Más de day

Performance Pack
Performance PackPerformance Pack
Performance Packday
 
Scala for scripting
Scala for scriptingScala for scripting
Scala for scriptingday
 
Scala4sling
Scala4slingScala4sling
Scala4slingday
 
Testing Zen
Testing ZenTesting Zen
Testing Zenday
 
Tech Summit 08 Support Initiative
Tech Summit 08 Support InitiativeTech Summit 08 Support Initiative
Tech Summit 08 Support Initiativeday
 
Non Cms For Web Apps
Non Cms For Web AppsNon Cms For Web Apps
Non Cms For Web Appsday
 
Getting Into The Flow With Cq Dam
Getting Into The Flow With Cq DamGetting Into The Flow With Cq Dam
Getting Into The Flow With Cq Damday
 
Dispatcher Oom
Dispatcher OomDispatcher Oom
Dispatcher Oomday
 
Advanced Collaboration And Beyond
Advanced Collaboration And BeyondAdvanced Collaboration And Beyond
Advanced Collaboration And Beyondday
 
Wc Mand Connectors2
Wc Mand Connectors2Wc Mand Connectors2
Wc Mand Connectors2day
 
Jackrabbit Roadmap
Jackrabbit RoadmapJackrabbit Roadmap
Jackrabbit Roadmapday
 
Doc Book Vs Dita
Doc Book Vs DitaDoc Book Vs Dita
Doc Book Vs Ditaday
 
Doc Book Vs Dita Teresa
Doc Book Vs Dita TeresaDoc Book Vs Dita Teresa
Doc Book Vs Dita Teresaday
 
862
862862
862day
 
Apache Con Us2007 Sanselan
Apache Con Us2007 SanselanApache Con Us2007 Sanselan
Apache Con Us2007 Sanselanday
 
Apache Con Us2007 Jcr In Action
Apache Con Us2007 Jcr In ActionApache Con Us2007 Jcr In Action
Apache Con Us2007 Jcr In Actionday
 
Apache Con Us2007 Apachei Batis
Apache Con Us2007 Apachei BatisApache Con Us2007 Apachei Batis
Apache Con Us2007 Apachei Batisday
 
Apache Con U S07 F F T Sling
Apache Con U S07  F F T  SlingApache Con U S07  F F T  Sling
Apache Con U S07 F F T Slingday
 
200711 R E S T Apache Con
200711  R E S T  Apache Con200711  R E S T  Apache Con
200711 R E S T Apache Conday
 

Más de day (19)

Performance Pack
Performance PackPerformance Pack
Performance Pack
 
Scala for scripting
Scala for scriptingScala for scripting
Scala for scripting
 
Scala4sling
Scala4slingScala4sling
Scala4sling
 
Testing Zen
Testing ZenTesting Zen
Testing Zen
 
Tech Summit 08 Support Initiative
Tech Summit 08 Support InitiativeTech Summit 08 Support Initiative
Tech Summit 08 Support Initiative
 
Non Cms For Web Apps
Non Cms For Web AppsNon Cms For Web Apps
Non Cms For Web Apps
 
Getting Into The Flow With Cq Dam
Getting Into The Flow With Cq DamGetting Into The Flow With Cq Dam
Getting Into The Flow With Cq Dam
 
Dispatcher Oom
Dispatcher OomDispatcher Oom
Dispatcher Oom
 
Advanced Collaboration And Beyond
Advanced Collaboration And BeyondAdvanced Collaboration And Beyond
Advanced Collaboration And Beyond
 
Wc Mand Connectors2
Wc Mand Connectors2Wc Mand Connectors2
Wc Mand Connectors2
 
Jackrabbit Roadmap
Jackrabbit RoadmapJackrabbit Roadmap
Jackrabbit Roadmap
 
Doc Book Vs Dita
Doc Book Vs DitaDoc Book Vs Dita
Doc Book Vs Dita
 
Doc Book Vs Dita Teresa
Doc Book Vs Dita TeresaDoc Book Vs Dita Teresa
Doc Book Vs Dita Teresa
 
862
862862
862
 
Apache Con Us2007 Sanselan
Apache Con Us2007 SanselanApache Con Us2007 Sanselan
Apache Con Us2007 Sanselan
 
Apache Con Us2007 Jcr In Action
Apache Con Us2007 Jcr In ActionApache Con Us2007 Jcr In Action
Apache Con Us2007 Jcr In Action
 
Apache Con Us2007 Apachei Batis
Apache Con Us2007 Apachei BatisApache Con Us2007 Apachei Batis
Apache Con Us2007 Apachei Batis
 
Apache Con U S07 F F T Sling
Apache Con U S07  F F T  SlingApache Con U S07  F F T  Sling
Apache Con U S07 F F T Sling
 
200711 R E S T Apache Con
200711  R E S T  Apache Con200711  R E S T  Apache Con
200711 R E S T Apache Con
 

Último

Building AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptxBuilding AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptxUdaiappa Ramachandran
 
COMPUTER 10 Lesson 8 - Building a Website
COMPUTER 10 Lesson 8 - Building a WebsiteCOMPUTER 10 Lesson 8 - Building a Website
COMPUTER 10 Lesson 8 - Building a Websitedgelyza
 
UiPath Community: AI for UiPath Automation Developers
UiPath Community: AI for UiPath Automation DevelopersUiPath Community: AI for UiPath Automation Developers
UiPath Community: AI for UiPath Automation DevelopersUiPathCommunity
 
Empowering Africa's Next Generation: The AI Leadership Blueprint
Empowering Africa's Next Generation: The AI Leadership BlueprintEmpowering Africa's Next Generation: The AI Leadership Blueprint
Empowering Africa's Next Generation: The AI Leadership BlueprintMahmoud Rabie
 
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...Will Schroeder
 
UiPath Studio Web workshop series - Day 7
UiPath Studio Web workshop series - Day 7UiPath Studio Web workshop series - Day 7
UiPath Studio Web workshop series - Day 7DianaGray10
 
How Accurate are Carbon Emissions Projections?
How Accurate are Carbon Emissions Projections?How Accurate are Carbon Emissions Projections?
How Accurate are Carbon Emissions Projections?IES VE
 
Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024D Cloud Solutions
 
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve DecarbonizationUsing IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve DecarbonizationIES VE
 
UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6DianaGray10
 
COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online CollaborationCOMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online Collaborationbruanjhuli
 
Secure your environment with UiPath and CyberArk technologies - Session 1
Secure your environment with UiPath and CyberArk technologies - Session 1Secure your environment with UiPath and CyberArk technologies - Session 1
Secure your environment with UiPath and CyberArk technologies - Session 1DianaGray10
 
UiPath Platform: The Backend Engine Powering Your Automation - Session 1
UiPath Platform: The Backend Engine Powering Your Automation - Session 1UiPath Platform: The Backend Engine Powering Your Automation - Session 1
UiPath Platform: The Backend Engine Powering Your Automation - Session 1DianaGray10
 
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...DianaGray10
 
Bird eye's view on Camunda open source ecosystem
Bird eye's view on Camunda open source ecosystemBird eye's view on Camunda open source ecosystem
Bird eye's view on Camunda open source ecosystemAsko Soukka
 
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfJamie (Taka) Wang
 
Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024SkyPlanner
 
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDEADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDELiveplex
 
Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration WorkflowsIgniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration WorkflowsSafe Software
 

Último (20)

201610817 - edge part1
201610817 - edge part1201610817 - edge part1
201610817 - edge part1
 
Building AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptxBuilding AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptx
 
COMPUTER 10 Lesson 8 - Building a Website
COMPUTER 10 Lesson 8 - Building a WebsiteCOMPUTER 10 Lesson 8 - Building a Website
COMPUTER 10 Lesson 8 - Building a Website
 
UiPath Community: AI for UiPath Automation Developers
UiPath Community: AI for UiPath Automation DevelopersUiPath Community: AI for UiPath Automation Developers
UiPath Community: AI for UiPath Automation Developers
 
Empowering Africa's Next Generation: The AI Leadership Blueprint
Empowering Africa's Next Generation: The AI Leadership BlueprintEmpowering Africa's Next Generation: The AI Leadership Blueprint
Empowering Africa's Next Generation: The AI Leadership Blueprint
 
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
 
UiPath Studio Web workshop series - Day 7
UiPath Studio Web workshop series - Day 7UiPath Studio Web workshop series - Day 7
UiPath Studio Web workshop series - Day 7
 
How Accurate are Carbon Emissions Projections?
How Accurate are Carbon Emissions Projections?How Accurate are Carbon Emissions Projections?
How Accurate are Carbon Emissions Projections?
 
Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024
 
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve DecarbonizationUsing IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
 
UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6
 
COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online CollaborationCOMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
 
Secure your environment with UiPath and CyberArk technologies - Session 1
Secure your environment with UiPath and CyberArk technologies - Session 1Secure your environment with UiPath and CyberArk technologies - Session 1
Secure your environment with UiPath and CyberArk technologies - Session 1
 
UiPath Platform: The Backend Engine Powering Your Automation - Session 1
UiPath Platform: The Backend Engine Powering Your Automation - Session 1UiPath Platform: The Backend Engine Powering Your Automation - Session 1
UiPath Platform: The Backend Engine Powering Your Automation - Session 1
 
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
 
Bird eye's view on Camunda open source ecosystem
Bird eye's view on Camunda open source ecosystemBird eye's view on Camunda open source ecosystem
Bird eye's view on Camunda open source ecosystem
 
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
 
Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024
 
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDEADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
 
Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration WorkflowsIgniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration Workflows
 

Embrace OSGi Apache Con Europe2009

  • 1. OSGi Embrace Change A Developer's Quickstart Carsten Ziegeler cziegeler@apache.org
  • 2. About • Member of the ASF – Sling, Felix, Cocoon, Portals, Sanselan, Excalibur, Incubator – PMC: Felix, Portals, Cocoon, Incubator, Excalibur (Chair) • RnD Team at Day Software • Article/Book Author, Technical Reviewer • JSR 286 Spec Group (Portlet API 2.0) 2
  • 3. Agenda 1 Motivation 2 And Action... 3 Why OSGi? 4 Apache Felix 5-7 Bundles, Services, Dynamics 8 Famous Final Words 3
  • 4.  1 Example Application Motivation  4
  • 5. Motivation • Modularity is key – Manage growing complexity – Support dynamic extensibility • No solution in standard Java – OSGi: tried and trusted • Embrace change – Embrace OSGi – Only a few concepts – easy to get started 5
  • 6.  2 Example Action... And Application  6
  • 7. Paint Program • Swing-based paint program • Interface SimpleShape for drawing – Different implementations – Each shape has name and icon properties – Available shapes are displayed in tool bar • Select shape and then select location – Shapes can be dragged, but not resized • Support dynamic deployment of shapes 7
  • 8. Shape Abstraction • Conceptual SimpleShape interface public interface SimpleShape { /** * Method to draw the shape of the service. * @param g2 The graphics object used for * painting. * @param p The position to paint the shape. **/ public void draw(Graphics2D g2, Point p); } 8
  • 10. High-Level Architecture 1 1 1 * Shape Drawing Default Tracker Frame Shape 1 1 1 1 * 1 Shape Simple Component Shape 10
  • 11. High-Level Architecture Best practice – Try to centralize interaction with OSGi API * that so 1 1 1 Shape Drawing componentsDefault other Tracker Frame POJOs...only Shape remain Shape Tracker will 1 1 1 interact with OSGi API. 1 * 1 Shape Simple Component Shape 11
  • 12. High-Level Architecture 1 1 1 * Shape Drawing Default Tracker Frame Shape 1 1 1 1 * 1 Main application window – gets Shape Simple dynamically injected Component Shape with available shapes from the Shape Tracker. 12
  • 13. High-Level Architecture 1 1 1 * Shape Drawing Default Tracker Frame Shape 1 1 1 1 * 1 Shape Simple Actual shape Component Shape implementation. 13
  • 14. High-Level Architecture Injected “proxied” shape 1 1 1 * implementation to hide Shape Drawing Default aspects of dynamism Tracker Frame Shape and provide a default implementation. 1 1 1 1 * 1 Shape Simple Actual shape Component Shape implementation. 14
  • 15. High-Level Architecture Component that draws the shape in parent frame; looks up shape via Drawing 1 1 1 * Shape Drawing Frame Default Tracker Frame Shape rather than having a direct reference. 1 1 1 1 * 1 Shape Simple Component Shape 15
  • 16. LIVE DEMO Example Application  16
  • 17.  3 Example Application Why OSGi?  17
  • 18. Class Path Hell • Can you spot some potential problems? 18
  • 19. Class Path Hell • What libs are used? Versions? • Which jar is used? Version? • No difference between private and public classes 19
  • 20. Java's Shortcomings • Simplistic version handling – “First” class from class path – JAR files assume backwards compatibility at best • Implicit dependencies – Dependencies are implicit in class path ordering – JAR files add improvements for extensions, but cannot control visibility 20
  • 21. Java's Shortcomings • Split packages by default – Class path approach searches until it finds, which leads to shadowing or version mixing • Limited scoping mechanisms – No module access modifier – Impossible to declare all private stuff as private • Missing module concept – Classes are too fine grained, packages are too simplistic, class loaders are too low level • No deployment/lifecycle support 21
  • 22. Java Dynamism Limitations • Low-level support for dynamics – Class loaders are complicated to use and error prone • Support for dynamics is still purely manual – Must be completely managed by the programmer – Leads to many ad hoc, incompatible solutions • Limited deployment support 22
  • 23. OSGi Technology • Adds modularity and dynamics – Module concept • Explicit sharing (importing and exporting) – Automatic management of code dependencies • Enforces sophisticated consistency rules for class loading – Life-cycle management • Manages dynamic deployment and configuration • Service Registry – Publish/find/bind 23
  • 24.  4 Example Application Apache Felix  24
  • 25. OSGi Alliance • Industry consortium • OSGi Service Platform specification – Framework specification for hosting dynamically downloadable services – Standard service specifications • Several expert groups define the specifications – Core Platform Expert Group (CPEG) – Mobile Expert Group (MEG) – Vehicle Expert Group (VEG) – Enterprise Expert Group (EEG) 25
  • 26. Apache Felix • Top-level project (March 2007) • Healthy and diverse community • OSGi R4 (R4.1) implementation – Framework (frequent releases) – Services (continued development) • Log, Package Admin, Event Admin, Configuration Admin, Declarative Services, Meta Type, Deployment Admin (and more) – Moving towards upcoming R4.2 • Tools – Maven Plugins, Web Console, iPojo 26
  • 27. Apache Felix • Growing community – Several code grants and contributions – Various (Apache) projects use Felix / have expressed interest in Felix and/or OSGi • e.g., ServiceMix, Directory, Sling, Tuscany • Roadmap – Continue toward R4 and R4.1 compliance • some parts consider pre R4.2 already 27
  • 28.  5 Example Application 1 OSGi – Part Bundles  28
  • 29. OSGi Architectural Overview Bundle k or ew ma Fr OSGi Java Operating System Driver Driver Driver Hardware 29
  • 30. OSGi Framework Layering L3 – Provides a publish/find/bind service model to SERVICE MODEL decouple bundles L2 - Manages the life cycle of bundle in a bundle repository without requiring the VM be restarted LIFECYCLE L1 - Creates the concept of modules (aka. bundles) that use classes from each other in a controlled way MODULE according to system and bundle constraints Execution L0 - •OSGi Minimum Execution Environment Environment CDC •CDC/Foundation CDC •JavaSE 30
  • 31. OSGi Framework • Component-oriented framework • Module concept: Bundles – Separate class loader -> graph – Package sharing and version management – Life-cycle management and notification • Dynamic! – Install, update, and uninstall at runtime • Runs multiple applications and services in a single VM 31
  • 32. OSGi Modularity • Explicit code boundaries and dependencies – Package imports and exports • Multi-version support – Version ranges for dependencies • Class space is managed by OSGi • Managed life cycle – Dynamic install, update, uninstall 32
  • 33. OSGi Modularity - Example • Dynamic module deployment and dependency resolution Provided package existing bundle OSGi framework 33
  • 34. OSGi Modularity - Example • Dynamic module deployment and dependency resolution existing bundle install bundle.jar OSGi framework 34
  • 35. OSGi Modularity - Example • Dynamic module deployment and dependency resolution existing resolve bundle bundle OSGi framework 35
  • 36. OSGi Modularity - Example • Dynamic module deployment and dependency resolution automatic package dependency resolution existing bundle OSGi framework 36
  • 37. Creating a Bundle • Plain old JAR with additional metadata in the manifest – Bundle identifier, version, exports, imports • Tools – Text editor (Manifest) – Eclipse (PDE) – Bundle packaging tools • BND from Peter Kriens • Apache Felix maven-bundle-plugin based on BND 37
  • 38. Maven is Your Friend • Apache Felix Maven Bundle Plugin • Creates metadata based on POM – Automatically: import packages – Manually: export and private packages • Analyses classes for consistency • Allows to include dependencies • Creates final bundle JAR file 38
  • 39. Maven Bundle Plugin Sample <artifactId>org.apache.sling.engine</artifactId> <packaging>bundle</packaging> <version>2.0.3-incubator-SNAPSHOT</version> <build> <plugins> <plugin> <groupId>org.apache.felix</groupId> <artifactId>maven-bundle-plugin</artifactId> <extensions>true</extensions> <configuration> <instructions> <Export-Package> org.apache.sling.engine;version=${pom.version} </Export-Package> <Private-Package> org.apache.sling.engine.impl </Private-Package> <Embed-Dependency> commons-fileupload </Embed-Dependency> </instructions> 39
  • 40. Maven Bundle Plugin Sample <artifactId>org.apache.sling.engine</artifactId> <packaging>bundle</packaging> <version>2.0.3-incubator-SNAPSHOT</version> <build> <plugins> <plugin> <groupId>org.apache.felix</groupId> <artifactId>maven-bundle-plugin</artifactId> <extensions>true</extensions> <configuration> <instructions> <Export-Package> org.apache.sling.engine;version=${pom.version} </Export-Package> <Private-Package> org.apache.sling.engine.impl </Private-Package> <Embed-Dependency> commons-fileupload </Embed-Dependency> </instructions> 40
  • 41. Maven Bundle Plugin Sample <artifactId>org.apache.sling.engine</artifactId> <packaging>bundle</packaging> <version>2.0.3-incubator-SNAPSHOT</version> <build> <plugins> <plugin> <groupId>org.apache.felix</groupId> <artifactId>maven-bundle-plugin</artifactId> <extensions>true</extensions> <configuration> <instructions> <Export-Package> org.apache.sling.engine;version=${pom.version} </Export-Package> <Private-Package> org.apache.sling.engine.impl </Private-Package> <Embed-Dependency> commons-fileupload </Embed-Dependency> </instructions> 41
  • 42. Maven Bundle Plugin Sample <artifactId>org.apache.sling.engine</artifactId> <packaging>bundle</packaging> <version>2.0.3-incubator-SNAPSHOT</version> <build> <plugins> <plugin> <groupId>org.apache.felix</groupId> <artifactId>maven-bundle-plugin</artifactId> <extensions>true</extensions> <configuration> <instructions> <Export-Package> org.apache.sling.engine;version=${pom.version} </Export-Package> <Private-Package> org.apache.sling.engine.impl </Private-Package> <Embed-Dependency> commons-fileupload </Embed-Dependency> </instructions> 42
  • 43. Be Modular! • Create clean package spaces – public vs private • Provide Bundles – Add manifest information • Think about dependencies – Additional bundle vs include – Optional – Version ranges • Benefits even without OSGi 43
  • 44.  6 Example Application 2 OSGi – Part Services  44
  • 45. OSGi Services (1/3) • Service-oriented architecture – Publish/find/bind – Possible to use modules without services Service Registry Find Publish Service Description Service Service Requester Provider Interact 45
  • 46. OSGi Services (2/3) • An OSGi application is... – A collection of bundles that interact via service interfaces – Bundles may be independently developed and deployed – Bundles and their associated services may appear or disappear at any time • Resulting application follows a Service- Oriented Component Model approach 46
  • 47. OSGi Services (3/3) • Dynamic service lookup Provided service Provided package existing bundle component OSGi framework 47
  • 48. OSGi Services (3/3) • Dynamic service lookup existing bundle install component bundle.jar OSGi framework 48
  • 49. OSGi Services (3/3) • Dynamic service lookup existing activate bundle bundle component OSGi framework 49
  • 50. OSGi Services (3/3) • Dynamic service lookup automatic package dependency resolution existing bundle component OSGi framework 50
  • 51. OSGi Services (3/3) • Dynamic service lookup manual service dependency resolution existing bundle component OSGi framework 51
  • 52. OSGi Services Advantages • Lightweight services – Lookup is based on interface name – Direct method invocation • Good design practice – Separates interface from implementation – Enables reuse, substitutability, loose coupling, and late binding 52
  • 53. OSGi Services Advantages • Dynamic – Loose coupling and late binding • Application's configuration is simply the set of deployed bundles – Deploy only the bundles that you need 53
  • 54. OSGi Services Issues • More sophisticated, but more complicated – Requires a different way of thinking • Things might appear/disappear at any moment – Must manually resolve and track services • There is help – Service Tracker • Still somewhat of a manual approach – Declarative Services, Spring DM, iPOJO • Sophisticated service-oriented component frameworks • Automated dependency injection and more • More modern, POJO-oriented approaches 54
  • 55.  7 Example Application 3 OSGi – Part Dynamics  55
  • 56. Everything is a Bundle • How to structure bundles? – API vs implementation bundle – Fine-grained vs coarse-grained – No “One Size Fits All” • Simple Rules – Stable code vs changing code – Optional parts 56
  • 57. Third Party Libraries • Use as bundles – Project delivers already a bundle • Apache Commons, Apache Sling etc. – Use special bundle repositories • Felix Commons, Spring etc. • But check included metadata! – Create your own wrapper • Easy with the Felix maven bundle plugin • Include in your bundle – Again: easy with the Felix maven bundle plugin 57
  • 58. Everything is Dynamic • Bundles can come and go! – Packages – Services • Services can come and go! • Be prepaired! – Application code must handle dynamics! 58
  • 59. Dynamic Services • OSGi Declarative Services Specification – XML Configuration • Contained in bundle • Manifest entry pointing to config(s) – Publishing services – Consuming services • Policy (static,dynamic), cardinality (0..1, 1..1, 0..n) – Default configuration – Service Lifecycle management • Various Implementations – Apache Felix SCR 59
  • 60. Dynamic Services Configuration <scr:component enabled=quot;truequot; name=quot;org.apache.sling.event.impl.DistributingEventHandlerquot;> <implementation class=quot;org.apache.sling.event.impl.DistributingEventHandlerquot;/> <service servicefactory=quot;falsequot;> <provide interface=quot;org.osgi.service.event.EventHandlerquot;/> </service> <property name=quot;repository.pathquot; value=quot;/var/eventing/distributionquot;/> <property name=quot;cleanup.periodquot; type=quot;Integerquot; value=quot;15quot;/> <reference name=quot;threadPoolquot; interface=quot;org.apache.sling.event.ThreadPoolquot; cardinality=quot;1..1quot; policy=quot;staticquot; bind=quot;bindThreadPoolquot; unbind=quot;unbindThreadPoolquot;/> 60
  • 61. Dynamic Services Configuration <scr:component enabled=quot;truequot; name=quot;org.apache.sling.event.impl.DistributingEventHandlerquot;> <implementation class=quot;org.apache.sling.event.impl.DistributingEventHandlerquot;/> <service servicefactory=quot;falsequot;> <provide interface=quot;org.osgi.service.event.EventHandlerquot;/> </service> <property name=quot;repository.pathquot; value=quot;/var/eventing/distributionquot;/> <property name=quot;cleanup.periodquot; type=quot;Integerquot; value=quot;15quot;/> <reference name=quot;threadPoolquot; interface=quot;org.apache.sling.event.ThreadPoolquot; cardinality=quot;1..1quot; policy=quot;staticquot; bind=quot;bindThreadPoolquot; unbind=quot;unbindThreadPoolquot;/> 61
  • 62. Dynamic Services Configuration <scr:component enabled=quot;truequot; name=quot;org.apache.sling.event.impl.DistributingEventHandlerquot;> <implementation class=quot;org.apache.sling.event.impl.DistributingEventHandlerquot;/> <service servicefactory=quot;falsequot;> <provide interface=quot;org.osgi.service.event.EventHandlerquot;/> </service> <property name=quot;repository.pathquot; value=quot;/var/eventing/distributionquot;/> <property name=quot;cleanup.periodquot; type=quot;Integerquot; value=quot;15quot;/> <reference name=quot;threadPoolquot; interface=quot;org.apache.sling.event.ThreadPoolquot; cardinality=quot;1..1quot; policy=quot;staticquot; bind=quot;bindThreadPoolquot; unbind=quot;unbindThreadPoolquot;/> 62
  • 63. Dynamic Services Configuration <scr:component enabled=quot;truequot; name=quot;org.apache.sling.event.impl.DistributingEventHandlerquot;> <implementation class=quot;org.apache.sling.event.impl.DistributingEventHandlerquot;/> <service servicefactory=quot;falsequot;> <provide interface=quot;org.osgi.service.event.EventHandlerquot;/> </service> <property name=quot;repository.pathquot; value=quot;/var/eventing/distributionquot;/> <property name=quot;cleanup.periodquot; type=quot;Integerquot; value=quot;15quot;/> <reference name=quot;threadPoolquot; interface=quot;org.apache.sling.event.ThreadPoolquot; cardinality=quot;1..1quot; policy=quot;staticquot; bind=quot;bindThreadPoolquot; unbind=quot;unbindThreadPoolquot;/> 63
  • 64. Declarative Services • Reads XML configs on bundle start • Registers services • Keeps track of dependencies – Starts/stops services • Invokes optional activation and deactivation method – Provides access to configuration • Caution: A service is by default only started if someone else uses it! – Immediate flag forces a service start 64
  • 65. Example Service protected ThreadPool threadPool; protected void activate(ComponentContext context) throws Exception { @SuppressWarnings(quot;uncheckedquot;) final Dictionary<String, Object> props = context.getProperties(); this.cleanupPeriod = (Integer)props.get(quot;cleanup.periodquot;); super.activate(context); } protected void bindThreadPool(ThreadPool p) { this.threadPool = p; } protected void unbindThreadPool(ThreadPool p) { if ( this.threadPool == p ) { this.threadPool = null; } } 65
  • 66. Config Admin and Metatype • OSGi Config Admin – Configuration Manager – Persistence storage API to retrieve/update/remove configs – – Works with Declarative Services • OSGi Metatype Service – Description of bundle metadata – Description of service configurations • Various Implementations – Apache Felix 66
  • 67. Maven SCR Plugin • Combines everything (DS, ConfigAdmin, Metatype, Maven) • Annotation-based (works for 1.4+) • Annotate components – Properties with default values – Service providers – Services references (policy and cardinality) • Generates DS XML • Generates Metatype config • Generates Java code 67
  • 68. SCR Plugin Sample /** * @scr.component * @scr.property name=quot;repository.pathquot; value=quot;/var/eventing/distributionquot; private=quot;truequot; * @scr.service interface=quot;EventHandlerquot; */ public class DistributingEventHandler implements EventHandler { protected static final int DEFAULT_CLEANUP_PERIOD = 15; /** @scr.property valueRef=quot;DEFAULT_CLEANUP_PERIODquot; type=quot;Integerquot; */ protected static final String PROP_CLEANUP_PERIOD = quot;cleanup.periodquot;; /** @scr.reference */ protected ThreadPool threadPool; protected void activate(ComponentContext context) throws Exception { final Dictionary<String, Object> props = context.getProperties(); this.cleanupPeriod = (Integer)props.get(PROP_CLEANUP_PERIOD); } 68
  • 69. Alternatives • Manually through bundle activator • Apache Felix iPojo • Spring Dynamic Modules 69
  • 70. Handling extensibility • Two basic implementation strategies – Service-based approach – Extender model 70
  • 71. Service Whiteboard Pattern • Clients register a service interface • Service tracker for registered services • Simple, more robust, leverages the OSGi service model • Service whiteboard pattern – It is an Inversion of Control pattern 71
  • 72. Externder Model • Bundles contain manifest entries – Like available service classes • Custom bundle tracker – Keeps track of bundles – Specifically, STARTED and STOPPED events – Checks bundles manifest data • Creates/removes services 72
  • 73.  8 Example Application Famous Final Words  73
  • 74. Conclusion • Modulary and dynamics are required by todays applications • OSGi technology addresses Java's limitations in these areas – Available today and growing in importance • Development is straightforward and provides immediate benefits • Apache Felix is ready when you are! 74
  • 75. Suggestions for Development • Think about modularity! – Clean package space • Think about dynamics! • Consider OSGi • Check out the spec and other projects • Minimize dependencies to OSGi – but only if it makes sense 75
  • 76. Suggestions for Using OSGi • Think about dynamics – Optional bundles – Optional services – Handle these cases • Use your preferred logging library – LogManager takes care • Use available tooling • Be part of the community! 76
  • 77. Check It Out • Read the OSGi spec – Framework – Config Admin, Metatype, Declarative Services – Deployment Admin, OBR • Download Apache Felix – Try tutorials and samples • Download Apache Sling :) • Explore the web – embrace OSGi 77
  • 78. OSGi Embrace Change Questions?