SlideShare ist ein Scribd-Unternehmen logo
1 von 37
Downloaden Sie, um offline zu lesen
OSGi Service
                           Component Models
                                   Heiko Seeberger (WeigleWilczek)
                              Kai Tödter (Siemens Corporate Technology)




© 2009 Seeberger, Tödter. Released under the Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License.   JAX 2009
OSGi Service Component Models




                                                                      Agenda

          •      Why? What?

          •      OSGi Declarative Services

          •      Spring Dynamic Modules

          •      Apache iPOJO

          •      Guice Peaberry

          •      Comparison

          •      Demo


© 2009 Seeberger, Tödter. Released under the Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License.   2
OSGi Service Component Models




                                                   Why Components?
© 2009 Seeberger, Tödter. Released under the Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License.   3
OSGi Service Component Models




                                                        The OO Dream



             quot;Object Oriented technology was going to change the
           world . . . we would have all these objects in our library and
          building a new system would be a snap. Just get a few classes,
                         bunch them together . . . and voila!quot;
      Peter Kriens, http://www.aqute.biz/Blog/2006-04-29




© 2009 Seeberger, Tödter. Released under the Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License.   4
OSGi Service Component Models




                                                         The OO Reality
© 2009 Seeberger, Tödter. Released under the Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License.   5
OSGi Service Component Models




                                                                   Coupling!




          •      Classes can almost never be used in isolation

          •      They depend on other classes

          •      Those classes depend on other packages,
                 which depend on other JARs . . .




© 2009 Seeberger, Tödter. Released under the Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License.   6
OSGi Service Component Models




                                     How can Components help?
© 2009 Seeberger, Tödter. Released under the Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License.   7
OSGi Service Component Models




                                                          Components ...




          •      are self-contained and declare their dependencies

          •      declare their interface and hide their internals

          •      interact with the container and obey to a life cycle




© 2009 Seeberger, Tödter. Released under the Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License.   8
OSGi Service Component Models




                                       OSGi enables Components



          •      OSGi Framework is the container

          •      Managed dependencies

          •      Life cycle and interactions with the container

          •      Loose coupling through service model




© 2009 Seeberger, Tödter. Released under the Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License.   9
OSGi Service Component Models




                            Why Service Component Models?
© 2009 Seeberger, Tödter. Released under the Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License.   10
OSGi Service Component Models




                                  Why not use plain OSGi APIs?


          •      We want to avoid OSGi glue code
                •      POJOs enhance testability

                •      Repetitive glue code reduces productivity

          •      Service Component Models ease service handling
                •      OSGi APIs lead to involved code

                •      SCMs offer advanced features




© 2009 Seeberger, Tödter. Released under the Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License.   11
OSGi Service Component Models




                                                                      Agenda

          •      Why? What?

          •      OSGi Declarative Services

          •      Spring Dynamic Modules

          •      Apache iPOJO

          •      Guice Peaberry

          •      Comparison

          •      Demo


© 2009 Seeberger, Tödter. Released under the Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License.   12
OSGi Service Component Models




                                                                    OSGi Framework
                        Active Bundle                                                                                Active Bundle

                         Component                                                                                     Component
                                                                            Service
                         Component                                                                                     Component
                                                         reference
                          Instance                                                                                     Description
                                                                                           provide
                         Component                                                                                     Component
                         Description                                                                                    Instance




                                        OSGi Declarative Services
© 2009 Seeberger, Tödter. Released under the Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License.     13
OSGi Service Component Models




                                                                                             OSGi Framework
                       DS-powered Bundle


                                                                                                    Service Component
                                                                                                          Runtime

                                   Component                                               create




                                    Service Component Runtime
© 2009 Seeberger, Tödter. Released under the Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License.   14
OSGi Service Component Models




                                            Declaring a Component




          •      Specify component description(s) via
                 Service-Component manifest header
                                                Service-Component: OSGI-INF/treeView.xml



          •      Specify the implementation class
                                  <component xmlns=quot;http://www.osgi.org/xmlns/scr/v1.1.0quot;>
                                      <implementation class=quot;...TreeViewquot;/>
                                  </component>




© 2009 Seeberger, Tödter. Released under the Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License.   15
OSGi Service Component Models




                                                    Providing a Service




          •      Specify each service interface

          •      By default components providing a service are delayed
                                         <service>
                                             <provide interface=quot;...IViewContributionquot;/>
                                             <provide interface=quot;...IPersonListenerquot;/>
                                         </service>




© 2009 Seeberger, Tödter. Released under the Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License.   16
OSGi Service Component Models




                                                 Referencing Services




          •      Specify the service interface

          •      Specify bind and unbind methods

          •      Specify the cardinality
                                               <reference interface=quot;...IPersonManagerquot;
                                                          bind=quot;setPersonManagerquot;
                                                          unbind=quot;removePersonManagerquot;
                                                          cardinality=quot;1..1quot;/>




© 2009 Seeberger, Tödter. Released under the Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License.   17
OSGi Service Component Models




               Concurrency for static and dynamic Policy




          •      No concurrency issues for static policy
                •      On (un)binding of references the component is deactivated and activated again

          •      Pay attention to concurrency for dynamic policy
                •      The component must be thread-safe regarding references

                                                        <reference ...
                                                                   policy=quot;dynamicquot;/>




© 2009 Seeberger, Tödter. Released under the Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License.   18
OSGi Service Component Models




                                                                      Agenda

          •      Why? What?

          •      OSGi Declarative Services

          •      Spring Dynamic Modules

          •      Apache iPOJO

          •      Guice Peaberry

          •      Comparison

          •      Demo


© 2009 Seeberger, Tödter. Released under the Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License.   19
OSGi Service Component Models




                                                                    OSGi Framework
                           Active Bundle                                                                          Active Bundle

                      Application Context                                                                    Application Context
                                                                               Service

                                     Bean                       import                                                             Bean

                                                                                        export
                                           Bean
                                                                                                                      Bean
                         Bean




                                           Spring Dynamic Modules
© 2009 Seeberger, Tödter. Released under the Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License.          20
OSGi Service Component Models




                                                                                             OSGi Framework
                    Spring-powered Bundle


                                                                                                    Spring DM Extender


                       Application Context                                                  create




                                                  Spring DM Extender
© 2009 Seeberger, Tödter. Released under the Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License.   21
OSGi Service Component Models




                   Declaring a Bundle Application Context




          •      By default configurations are looked up under
                 META-INF/spring/

          •      Multiple configurations are merged into a
                 single Application Context




© 2009 Seeberger, Tödter. Released under the Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License.   22
OSGi Service Component Models




                                                    Providing a Service




          •      Specify each service interface or use auto-export

          •      Beans exported as service cannot be lazy
                                              <osgi:service ref=quot;treeViewquot;
                                                            auto-export=quot;interfacesquot; />




© 2009 Seeberger, Tödter. Released under the Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License.   23
OSGi Service Component Models




                                                 Referencing Services




          •      A local bean is created with given ID

          •      Specify the service interface

          •      Specify the cardinality
                                          <osgi:reference id=quot;personManagerOSGiquot;
                                                          interface=quot;...IPersonManagerquot;
                                                          cardinality=quot;1..1quot;>




© 2009 Seeberger, Tödter. Released under the Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License.   24
OSGi Service Component Models




                                       Concurrency in Spring DM



          •      References are only injected once
                •      Proxies for unary references

                •      Managed collections for multiple references with “Iterator guarantee”

          •      Concurrency issue is swapped for uncertainty
                •      ServiceUnavilableException




© 2009 Seeberger, Tödter. Released under the Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License.   25
OSGi Service Component Models




                                                                      Agenda

          •      Why? What?

          •      OSGi Declarative Services

          •      Spring Dynamic Modules

          •      Apache iPOJO

          •      Guice Peaberry

          •      Comparison

          •      Demo


© 2009 Seeberger, Tödter. Released under the Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License.   26
OSGi Service Component Models




                                                                    OSGi Framework
                        Active Bundle                                                                                Active Bundle

                         Component                                                                                     Component
                                                                            Service
                         Component                                                                                     Component
                                                         reference
                          Instance                                                                                      Metadata
                                                                                           provide
                         Component                                                                                     Component
                          Metadata                                                                                      Instance




                                                           Apache iPOJO
© 2009 Seeberger, Tödter. Released under the Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License.     27
OSGi Service Component Models




                                            Declaring a Component




          •      Component metadata will be used to
                 instrument the bytecode at build-time

          •      Specify component and instance
                                              <ipojo>
                                                  <component classname=quot;...TreeViewquot; />
                                                  <instance component=quot;...TreeViewquot; />
                                              </ipojo>




© 2009 Seeberger, Tödter. Released under the Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License.   28
OSGi Service Component Models




                                                    Providing a Service




          •      Service interfaces are computed by iPOJO

          •      iPOJO services are created lazily
                                                                    <component ...>
                                                                        <provides />
                                                                    </component>




© 2009 Seeberger, Tödter. Released under the Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License.   29
OSGi Service Component Models




                                                 Referencing Services




          •      iPOJO offers field and method injection
                              <requires field=quot;logServicequot; />
                              <requires>
                                  <callback type=quot;bindquot; method=quot;setPersonManagerquot; />
                                  <callback type=quot;unbindquot; method=quot;removePersonManagerquot; />
                              </requires>




© 2009 Seeberger, Tödter. Released under the Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License.   30
OSGi Service Component Models




                                              Concurrency in iPOJO




          •      iPOJO manages concurrency for references
                •      We can write our code without regard for thread-safety

                •      Bytecode instrumentation weaves in all necessary synchronization




© 2009 Seeberger, Tödter. Released under the Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License.   31
OSGi Service Component Models




                                                                      Agenda

          •      Why? What?

          •      OSGi Declarative Services

          •      Spring Dynamic Modules

          •      Apache iPOJO

          •      Guice Peaberry

          •      Comparison

          •      Demo


© 2009 Seeberger, Tödter. Released under the Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License.   32
OSGi Service Component Models




                                                              Comparison


                                                                                            DS                      DM             iPOJO
                                                                                             +                         +            +
       POJO-ness
                                                                                              o                        +            o
       DI power
                                                                                              o                        o            +
       Ease of programming model
                                                                                             +                         +             -
       Ease of build
                                                                                             +                         -            +
       Size and dependencies
                                                                                             +                         -            +
       Support for laziness


© 2009 Seeberger, Tödter. Released under the Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License.           33
OSGi Service Component Models




                                                                      Agenda

          •      Why? What?

          •      OSGi Declarative Services

          •      Spring Dynamic Modules

          •      Apache iPOJO

          •      Guice Peaberry

          •      Comparison

          •      Demo


© 2009 Seeberger, Tödter. Released under the Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License.   34
OSGi Service Component Models




                                     Dynamic Swing OSGi Demo
© 2009 Seeberger, Tödter. Released under the Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License.   35
OSGi Service Component Models




                                             How to get the Demo?

          •      http://max-server.myftp.org/trac/pm
                •      Wiki with some documentation

                •      Anonymous Subversion access

                •      Trac issue tracking


          •      Licenses
                •      All PM project sources are licensed under EPL

                •      Swing Application Framework (JSR 296) implementation is licensed under LGPL

                •      Swing Worker is licensed under LGPL

                •      The nice icons from FamFamFam are licensed under the Creative Commons
                       Attribution 2.5 License.



© 2009 Seeberger, Tödter. Released under the Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License.   36
Thank you!
               Slides at www.slideshare.net/heiko.seeberger/jax-09-osgi-service-components-models
                                      Demo at max-server.myftp.org/trac/pm




© 2009 Seeberger, Tödter. Released under the Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License.   JAX 2009

Weitere ähnliche Inhalte

Ähnlich wie JAX 09 - OSGi Service Components Models

Adopting Agile Tools & Methods In A Legacy Context
Adopting Agile Tools & Methods In A Legacy ContextAdopting Agile Tools & Methods In A Legacy Context
Adopting Agile Tools & Methods In A Legacy Context
Xavier Warzee
 
GeneXus en Mitsubishi Heavy Industries (MHI) – Japón
GeneXus en Mitsubishi Heavy Industries (MHI) – JapónGeneXus en Mitsubishi Heavy Industries (MHI) – Japón
GeneXus en Mitsubishi Heavy Industries (MHI) – Japón
GeneXus
 
EclipseCon Europe 2012 - Big Models
EclipseCon Europe 2012 - Big ModelsEclipseCon Europe 2012 - Big Models
EclipseCon Europe 2012 - Big Models
Christof Hammel
 
Domino OSGi Development
Domino OSGi DevelopmentDomino OSGi Development
Domino OSGi Development
Paul Fiore
 

Ähnlich wie JAX 09 - OSGi Service Components Models (20)

Enterprise Osgi
Enterprise OsgiEnterprise Osgi
Enterprise Osgi
 
OSGi DevCon 2009 Review
OSGi DevCon 2009 ReviewOSGi DevCon 2009 Review
OSGi DevCon 2009 Review
 
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
 
Adopting Agile Tools & Methods In A Legacy Context
Adopting Agile Tools & Methods In A Legacy ContextAdopting Agile Tools & Methods In A Legacy Context
Adopting Agile Tools & Methods In A Legacy Context
 
OSGi Mars World in Action
OSGi Mars World in ActionOSGi Mars World in Action
OSGi Mars World in Action
 
Smila ESE 2008
Smila ESE 2008Smila ESE 2008
Smila ESE 2008
 
OSGi
OSGiOSGi
OSGi
 
Moduarlity patterns with OSGi
Moduarlity patterns with OSGiModuarlity patterns with OSGi
Moduarlity patterns with OSGi
 
USolutions - SOA and the Cloud
USolutions - SOA and the CloudUSolutions - SOA and the Cloud
USolutions - SOA and the Cloud
 
Eclipse Con2010 Composites
Eclipse Con2010 CompositesEclipse Con2010 Composites
Eclipse Con2010 Composites
 
GeneXus en Mitsubishi Heavy Industries (MHI) – Japón
GeneXus en Mitsubishi Heavy Industries (MHI) – JapónGeneXus en Mitsubishi Heavy Industries (MHI) – Japón
GeneXus en Mitsubishi Heavy Industries (MHI) – Japón
 
EclipseCon Europe 2012 - Big Models
EclipseCon Europe 2012 - Big ModelsEclipseCon Europe 2012 - Big Models
EclipseCon Europe 2012 - Big Models
 
W-JAX 08 - Declarative Services versus Spring Dynamic Modules
W-JAX 08 - Declarative Services versus Spring Dynamic ModulesW-JAX 08 - Declarative Services versus Spring Dynamic Modules
W-JAX 08 - Declarative Services versus Spring Dynamic Modules
 
Extending SSRS Whitepaper
Extending SSRS WhitepaperExtending SSRS Whitepaper
Extending SSRS Whitepaper
 
Building a right sized, do-anything runtime using OSGi technologies: a case s...
Building a right sized, do-anything runtime using OSGi technologies: a case s...Building a right sized, do-anything runtime using OSGi technologies: a case s...
Building a right sized, do-anything runtime using OSGi technologies: a case s...
 
Whats Next for OSGi? - BJ Hargrave
Whats Next for OSGi? - BJ HargraveWhats Next for OSGi? - BJ Hargrave
Whats Next for OSGi? - BJ Hargrave
 
20090410 J Spring Pragmatic Model Driven Development In Java Using Smart
20090410   J Spring Pragmatic Model Driven Development In Java Using Smart20090410   J Spring Pragmatic Model Driven Development In Java Using Smart
20090410 J Spring Pragmatic Model Driven Development In Java Using Smart
 
Domino OSGi Development
Domino OSGi DevelopmentDomino OSGi Development
Domino OSGi Development
 
Five Cool Use Cases for the Spring Component in Oracle SOA Suite
Five Cool Use Cases for the Spring Component in Oracle SOA SuiteFive Cool Use Cases for the Spring Component in Oracle SOA Suite
Five Cool Use Cases for the Spring Component in Oracle SOA Suite
 
Universal Declarative Services
Universal Declarative ServicesUniversal Declarative Services
Universal Declarative Services
 

Mehr von Heiko Seeberger

Eclipse Magazin 12 - Design by Contract
Eclipse Magazin 12 - Design by ContractEclipse Magazin 12 - Design by Contract
Eclipse Magazin 12 - Design by Contract
Heiko Seeberger
 
Eclipse Magazin 16 - Die Stärke der Drei
Eclipse Magazin 16 - Die Stärke der DreiEclipse Magazin 16 - Die Stärke der Drei
Eclipse Magazin 16 - Die Stärke der Drei
Heiko Seeberger
 
Eclipse Magazin15 - Performance Logging
Eclipse Magazin15 - Performance LoggingEclipse Magazin15 - Performance Logging
Eclipse Magazin15 - Performance Logging
Heiko Seeberger
 
Eclipse Magazin 14 - Getting hooked on Equinox
Eclipse Magazin 14 - Getting hooked on EquinoxEclipse Magazin 14 - Getting hooked on Equinox
Eclipse Magazin 14 - Getting hooked on Equinox
Heiko Seeberger
 
Eclipse Magazin 12 - Security does matter
Eclipse Magazin 12 - Security does matterEclipse Magazin 12 - Security does matter
Eclipse Magazin 12 - Security does matter
Heiko Seeberger
 

Mehr von Heiko Seeberger (20)

Scaladays 2011 - The Ease of Scalaz
Scaladays 2011 - The Ease of ScalazScaladays 2011 - The Ease of Scalaz
Scaladays 2011 - The Ease of Scalaz
 
Java Magazin - Lift
Java Magazin - LiftJava Magazin - Lift
Java Magazin - Lift
 
JavaSPEKTRUM - Scala 3
JavaSPEKTRUM - Scala 3JavaSPEKTRUM - Scala 3
JavaSPEKTRUM - Scala 3
 
JavaSPEKTRUM - Scala 2
JavaSPEKTRUM - Scala 2JavaSPEKTRUM - Scala 2
JavaSPEKTRUM - Scala 2
 
JavaSPEKTRUM - Scala 1
JavaSPEKTRUM - Scala 1JavaSPEKTRUM - Scala 1
JavaSPEKTRUM - Scala 1
 
RheinJUG 2010 - Sprechen Sie Scala?
RheinJUG 2010 - Sprechen Sie Scala?RheinJUG 2010 - Sprechen Sie Scala?
RheinJUG 2010 - Sprechen Sie Scala?
 
Objektforum 2010 - Sprechen Sie Scala?
Objektforum 2010 - Sprechen Sie Scala?Objektforum 2010 - Sprechen Sie Scala?
Objektforum 2010 - Sprechen Sie Scala?
 
W-JAX 09 - ScalaModules
W-JAX 09 - ScalaModulesW-JAX 09 - ScalaModules
W-JAX 09 - ScalaModules
 
W-JAX 09 - Lift
W-JAX 09 - LiftW-JAX 09 - Lift
W-JAX 09 - Lift
 
JM 08/09 - Beginning Scala Review
JM 08/09 - Beginning Scala ReviewJM 08/09 - Beginning Scala Review
JM 08/09 - Beginning Scala Review
 
JM 08/09 - ScalaModules
JM 08/09 - ScalaModulesJM 08/09 - ScalaModules
JM 08/09 - ScalaModules
 
OSGi DevCon Europe 09 - OSGi on Scala
OSGi DevCon Europe 09 - OSGi on ScalaOSGi DevCon Europe 09 - OSGi on Scala
OSGi DevCon Europe 09 - OSGi on Scala
 
JAX 09 - OSGi on Scala
JAX 09 - OSGi on ScalaJAX 09 - OSGi on Scala
JAX 09 - OSGi on Scala
 
JAX 08 - Agile RCP
JAX 08 - Agile RCPJAX 08 - Agile RCP
JAX 08 - Agile RCP
 
Eclipse Magazin 12 - Design by Contract
Eclipse Magazin 12 - Design by ContractEclipse Magazin 12 - Design by Contract
Eclipse Magazin 12 - Design by Contract
 
JUGM 07 - AspectJ
JUGM 07 - AspectJJUGM 07 - AspectJ
JUGM 07 - AspectJ
 
Eclipse Magazin 16 - Die Stärke der Drei
Eclipse Magazin 16 - Die Stärke der DreiEclipse Magazin 16 - Die Stärke der Drei
Eclipse Magazin 16 - Die Stärke der Drei
 
Eclipse Magazin15 - Performance Logging
Eclipse Magazin15 - Performance LoggingEclipse Magazin15 - Performance Logging
Eclipse Magazin15 - Performance Logging
 
Eclipse Magazin 14 - Getting hooked on Equinox
Eclipse Magazin 14 - Getting hooked on EquinoxEclipse Magazin 14 - Getting hooked on Equinox
Eclipse Magazin 14 - Getting hooked on Equinox
 
Eclipse Magazin 12 - Security does matter
Eclipse Magazin 12 - Security does matterEclipse Magazin 12 - Security does matter
Eclipse Magazin 12 - Security does matter
 

Kürzlich hochgeladen

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Kürzlich hochgeladen (20)

Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 

JAX 09 - OSGi Service Components Models

  • 1. OSGi Service Component Models Heiko Seeberger (WeigleWilczek) Kai Tödter (Siemens Corporate Technology) © 2009 Seeberger, Tödter. Released under the Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License. JAX 2009
  • 2. OSGi Service Component Models Agenda • Why? What? • OSGi Declarative Services • Spring Dynamic Modules • Apache iPOJO • Guice Peaberry • Comparison • Demo © 2009 Seeberger, Tödter. Released under the Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License. 2
  • 3. OSGi Service Component Models Why Components? © 2009 Seeberger, Tödter. Released under the Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License. 3
  • 4. OSGi Service Component Models The OO Dream quot;Object Oriented technology was going to change the world . . . we would have all these objects in our library and building a new system would be a snap. Just get a few classes, bunch them together . . . and voila!quot; Peter Kriens, http://www.aqute.biz/Blog/2006-04-29 © 2009 Seeberger, Tödter. Released under the Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License. 4
  • 5. OSGi Service Component Models The OO Reality © 2009 Seeberger, Tödter. Released under the Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License. 5
  • 6. OSGi Service Component Models Coupling! • Classes can almost never be used in isolation • They depend on other classes • Those classes depend on other packages, which depend on other JARs . . . © 2009 Seeberger, Tödter. Released under the Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License. 6
  • 7. OSGi Service Component Models How can Components help? © 2009 Seeberger, Tödter. Released under the Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License. 7
  • 8. OSGi Service Component Models Components ... • are self-contained and declare their dependencies • declare their interface and hide their internals • interact with the container and obey to a life cycle © 2009 Seeberger, Tödter. Released under the Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License. 8
  • 9. OSGi Service Component Models OSGi enables Components • OSGi Framework is the container • Managed dependencies • Life cycle and interactions with the container • Loose coupling through service model © 2009 Seeberger, Tödter. Released under the Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License. 9
  • 10. OSGi Service Component Models Why Service Component Models? © 2009 Seeberger, Tödter. Released under the Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License. 10
  • 11. OSGi Service Component Models Why not use plain OSGi APIs? • We want to avoid OSGi glue code • POJOs enhance testability • Repetitive glue code reduces productivity • Service Component Models ease service handling • OSGi APIs lead to involved code • SCMs offer advanced features © 2009 Seeberger, Tödter. Released under the Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License. 11
  • 12. OSGi Service Component Models Agenda • Why? What? • OSGi Declarative Services • Spring Dynamic Modules • Apache iPOJO • Guice Peaberry • Comparison • Demo © 2009 Seeberger, Tödter. Released under the Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License. 12
  • 13. OSGi Service Component Models OSGi Framework Active Bundle Active Bundle Component Component Service Component Component reference Instance Description provide Component Component Description Instance OSGi Declarative Services © 2009 Seeberger, Tödter. Released under the Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License. 13
  • 14. OSGi Service Component Models OSGi Framework DS-powered Bundle Service Component Runtime Component create Service Component Runtime © 2009 Seeberger, Tödter. Released under the Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License. 14
  • 15. OSGi Service Component Models Declaring a Component • Specify component description(s) via Service-Component manifest header Service-Component: OSGI-INF/treeView.xml • Specify the implementation class <component xmlns=quot;http://www.osgi.org/xmlns/scr/v1.1.0quot;> <implementation class=quot;...TreeViewquot;/> </component> © 2009 Seeberger, Tödter. Released under the Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License. 15
  • 16. OSGi Service Component Models Providing a Service • Specify each service interface • By default components providing a service are delayed <service> <provide interface=quot;...IViewContributionquot;/> <provide interface=quot;...IPersonListenerquot;/> </service> © 2009 Seeberger, Tödter. Released under the Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License. 16
  • 17. OSGi Service Component Models Referencing Services • Specify the service interface • Specify bind and unbind methods • Specify the cardinality <reference interface=quot;...IPersonManagerquot; bind=quot;setPersonManagerquot; unbind=quot;removePersonManagerquot; cardinality=quot;1..1quot;/> © 2009 Seeberger, Tödter. Released under the Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License. 17
  • 18. OSGi Service Component Models Concurrency for static and dynamic Policy • No concurrency issues for static policy • On (un)binding of references the component is deactivated and activated again • Pay attention to concurrency for dynamic policy • The component must be thread-safe regarding references <reference ... policy=quot;dynamicquot;/> © 2009 Seeberger, Tödter. Released under the Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License. 18
  • 19. OSGi Service Component Models Agenda • Why? What? • OSGi Declarative Services • Spring Dynamic Modules • Apache iPOJO • Guice Peaberry • Comparison • Demo © 2009 Seeberger, Tödter. Released under the Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License. 19
  • 20. OSGi Service Component Models OSGi Framework Active Bundle Active Bundle Application Context Application Context Service Bean import Bean export Bean Bean Bean Spring Dynamic Modules © 2009 Seeberger, Tödter. Released under the Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License. 20
  • 21. OSGi Service Component Models OSGi Framework Spring-powered Bundle Spring DM Extender Application Context create Spring DM Extender © 2009 Seeberger, Tödter. Released under the Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License. 21
  • 22. OSGi Service Component Models Declaring a Bundle Application Context • By default configurations are looked up under META-INF/spring/ • Multiple configurations are merged into a single Application Context © 2009 Seeberger, Tödter. Released under the Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License. 22
  • 23. OSGi Service Component Models Providing a Service • Specify each service interface or use auto-export • Beans exported as service cannot be lazy <osgi:service ref=quot;treeViewquot; auto-export=quot;interfacesquot; /> © 2009 Seeberger, Tödter. Released under the Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License. 23
  • 24. OSGi Service Component Models Referencing Services • A local bean is created with given ID • Specify the service interface • Specify the cardinality <osgi:reference id=quot;personManagerOSGiquot; interface=quot;...IPersonManagerquot; cardinality=quot;1..1quot;> © 2009 Seeberger, Tödter. Released under the Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License. 24
  • 25. OSGi Service Component Models Concurrency in Spring DM • References are only injected once • Proxies for unary references • Managed collections for multiple references with “Iterator guarantee” • Concurrency issue is swapped for uncertainty • ServiceUnavilableException © 2009 Seeberger, Tödter. Released under the Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License. 25
  • 26. OSGi Service Component Models Agenda • Why? What? • OSGi Declarative Services • Spring Dynamic Modules • Apache iPOJO • Guice Peaberry • Comparison • Demo © 2009 Seeberger, Tödter. Released under the Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License. 26
  • 27. OSGi Service Component Models OSGi Framework Active Bundle Active Bundle Component Component Service Component Component reference Instance Metadata provide Component Component Metadata Instance Apache iPOJO © 2009 Seeberger, Tödter. Released under the Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License. 27
  • 28. OSGi Service Component Models Declaring a Component • Component metadata will be used to instrument the bytecode at build-time • Specify component and instance <ipojo> <component classname=quot;...TreeViewquot; /> <instance component=quot;...TreeViewquot; /> </ipojo> © 2009 Seeberger, Tödter. Released under the Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License. 28
  • 29. OSGi Service Component Models Providing a Service • Service interfaces are computed by iPOJO • iPOJO services are created lazily <component ...> <provides /> </component> © 2009 Seeberger, Tödter. Released under the Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License. 29
  • 30. OSGi Service Component Models Referencing Services • iPOJO offers field and method injection <requires field=quot;logServicequot; /> <requires> <callback type=quot;bindquot; method=quot;setPersonManagerquot; /> <callback type=quot;unbindquot; method=quot;removePersonManagerquot; /> </requires> © 2009 Seeberger, Tödter. Released under the Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License. 30
  • 31. OSGi Service Component Models Concurrency in iPOJO • iPOJO manages concurrency for references • We can write our code without regard for thread-safety • Bytecode instrumentation weaves in all necessary synchronization © 2009 Seeberger, Tödter. Released under the Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License. 31
  • 32. OSGi Service Component Models Agenda • Why? What? • OSGi Declarative Services • Spring Dynamic Modules • Apache iPOJO • Guice Peaberry • Comparison • Demo © 2009 Seeberger, Tödter. Released under the Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License. 32
  • 33. OSGi Service Component Models Comparison DS DM iPOJO + + + POJO-ness o + o DI power o o + Ease of programming model + + - Ease of build + - + Size and dependencies + - + Support for laziness © 2009 Seeberger, Tödter. Released under the Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License. 33
  • 34. OSGi Service Component Models Agenda • Why? What? • OSGi Declarative Services • Spring Dynamic Modules • Apache iPOJO • Guice Peaberry • Comparison • Demo © 2009 Seeberger, Tödter. Released under the Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License. 34
  • 35. OSGi Service Component Models Dynamic Swing OSGi Demo © 2009 Seeberger, Tödter. Released under the Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License. 35
  • 36. OSGi Service Component Models How to get the Demo? • http://max-server.myftp.org/trac/pm • Wiki with some documentation • Anonymous Subversion access • Trac issue tracking • Licenses • All PM project sources are licensed under EPL • Swing Application Framework (JSR 296) implementation is licensed under LGPL • Swing Worker is licensed under LGPL • The nice icons from FamFamFam are licensed under the Creative Commons Attribution 2.5 License. © 2009 Seeberger, Tödter. Released under the Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License. 36
  • 37. Thank you! Slides at www.slideshare.net/heiko.seeberger/jax-09-osgi-service-components-models Demo at max-server.myftp.org/trac/pm © 2009 Seeberger, Tödter. Released under the Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Germany License. JAX 2009