SlideShare ist ein Scribd-Unternehmen logo
1 von 30
Downloaden Sie, um offline zu lesen
OSGi
for mere mortals

                                                Simple and robus t sof t ware is go o d f or yo ur wor k-life b alance .

Bertrand Delacrétaz
Senior Developer, Adobe Digital Enterprise Systems, www.day.com
Apache So ware Foundation Member and (current) Director
h p://grep.codeconsult.ch - twi er: @bdelacretaz - bdelacretaz@apache.org
ApacheCon North America 2011, Vancouver, November 2011
slides revision: 2011-11-05 (on a plane)


OSGi for                                                                                            1
Mere Mortals
                                                                                                                           1
what?
        a simple RESTful server
       built from scratch on OSGi
               to show that it’s not rocket science,
                   even starting from scratch...


OSGi for
Mere Mortals
                                                       2
RESTfulcontent:
POST to store
              server?

$ date | curl -T - -X POST -D - http://localhost:8080/store/example

HTTP/1.1 201 Created
Location: /store/example
Content-Type: text/plain; charset=utf-8
Content-Length: 178
Server: Jetty(6.1.x)

Stored at /store/example
StoredBy:ch.x42.osgi.samples.osgi101.app.servlets.StorageServlet
StoredAt:Fri Nov 04 10:41:30 CET 2011
Path:/store/example

Fri Nov   4 10:41:30 CET 2011




OSGi for
Mere Mortals
                                                                      3
RESTful server!
GET to retrieve content:




$ curl http://localhost:8080/store/example
StoredBy:ch.x42.osgi.samples.osgi101.app.servlets.StorageServlet
StoredAt:Fri Nov 04 10:41:30 CET 2011
Path:/store/example

Fri Nov   4 10:41:30 CET 2011



                                  In terms of functionality, that’s it!



OSGi for
Mere Mortals
                                                                          4
It’s not big...
      107   ./app/pom.xml
       35   ./app/.../InMemoryStorage.java
       34   ./app/.../PathsStorage.java
      147   ./app/.../StorageServlet.java
      101   ./core/pom.xml
        6   ./core/...CoreConstants.java
       32   ./core/...DefaultGetServlet.java
       32   ./core/...DefaultPostServlet.java
      116   ./core/...DispatcherServlet.java
        8   ./core/...Storage.java
      208   ./launcher/pom.xml
       84   ./launcher/...OsgiBootstrap.java
       52   ./pom.xml



               962 lines in total, including 468 lines in pom.xml files...
OSGi for
Mere Mortals
                                                                             5
Components
                                                       Dynamic Services
    Server        OSGi framework          Application core        Application services
 Bootstrapping    and standard services

          HTTP         HttpService           Dispatcher
                                                                      InMemoryStorage
                                              Servlet
                  Services Components
                                            Default POST
                     Runtime (SCR)                                     StorageServlet
                                               Servlet

                      Configuration          Default GET
                                                                        PathsStorage
                                              Servlet
                         Logging

          HTTP     Felix Web Console

          shell         Felix Shell
                                                    indicates SCR ser vices
                                                    also:
                                                    maven-bundle plugin
                                                    maven-scr-plugin
OSGi for                                            maven-dependency-plugin
Mere Mortals
                                                                                         6
Bootstrapping
               and loading bundles




OSGi for                             7
Mere Mortals
                                         7
Framework start and stop
Called from a plain main() method




OSGi for
Mere Mortals
                                    8
Get bundles from Maven repo
Copy to a folder using maven-dependency-plugin in launcher




OSGi for
Mere Mortals
                                                             9
Install bundles from lesystem
BundleContext.installBundle(URL)
Install all bundles rst, then start all




OSGi for
Mere Mortals
                                          10
Live bundles list
From the Felix console at /system/console




                                            We’re good to go!

OSGi for
Mere Mortals
                                                                11
Our OSGi bundles
        HttpService        org.apache.felix.h p.je y

          Logging          org.apache.sling.commons.log
    Services Components
       Runtime (SCR)       org.apache.felix.scr

       Configuration
                           org.apache.felix.metatype
                           org.apache.felix.con gadmin
         Felix Shell
                           org.apache.felix.shell
                           org.apache.felix.shell.tui
     Felix Web Console     org.apache.felix.webconsole

      Application Core     osgi-for-mere-mortals-core
    Application Services   osgi-for-mere-mortals-app
OSGi for
Mere Mortals
                                                          12
Dispatcher
                 Servlet

OSGi for                    13
Mere Mortals
                                 13
DispatcherServletforComponent
Register with H pService and watch Servlet services
                                           Dispatcher
                                            Servlet




OSGi for
Mere Mortals
                                                        14
DispatcherServletServlets
Dispatch to OSGi services which are
                                               Dispatcher
                                                Servlet




                                 Default GET
                                   Servlet


OSGi for
Mere Mortals
                                                            15
Default GET
                 Servlet

OSGi for                     16
Mere Mortals
                                  16
Default GETSCR annotations
Just a servlet, with some
                          servlet
                                    Default GET
                                      Servlet




OSGi for
Mere Mortals
                                                  17
Storage
               Services

OSGi for                  18
Mere Mortals
                               18
Storage service interface
De ned in the core bundle, package is exported




OSGi for
Mere Mortals
                                                 19
Storage service#1: in memory
Active by default




OSGi for
Mere Mortals
                               20
Storage service#2: can be activated in console
Alternate service, inactive by default,
                                        just paths




OSGi for
Mere Mortals
                                                     21
Storage
               Servlet

OSGi for                 22
Mere Mortals
                              22
StorageServlet service
Uses @Reference to get a Storage




                                           Properties used by DispatcherSer vlet




               The Component will only start once a Storage service is available




OSGi for
Mere Mortals
                                                                                   23
Alternate Storage
               demo


OSGi for              24
Mere Mortals
                           24
Replaceone and enabling another ComponentStorage
By disabling
             In-memory with paths


      1) disable inMemoryStorage -> StorageServlet stops




      2) enable PathsStorage -> StorageServlet is back




OSGi for
Mere Mortals
                                                           25
Con guration
               demo



OSGi for                 26
Mere Mortals
                              26
Configuring the StorageServlet
Con gurationAdmin service, console and annotations




1) User provides con guration data in web console (or Felix shell, Sling Installer, ...)

  Felix Web Console

2) Console (con guration agent) changes values

 ConfigurationAdmin                                   StorageServlet

3) Con gurationAdmin deactivates and
reactivates Component with new Con g

                                                0) Component has metatype=true and some
OSGi for                                        non-private @Property annotations
Mere Mortals
                                                                                           27
StorageServlet Configuration code
Annotations + read values in activate()
                   Parameter names + descriptions in metatype.properties




OSGi for
Mere Mortals
                                                                           28
Conclusions


              29
Conclusions
Powerful out of the box
infrastructure, not much
code to write.
Modular component-based
architecture.
Dynamic (re)con guration,
both in terms of components
and parameters.
OSGi materializes the component-based programming
vision in Java, and using it is not rocket science!
 Code at github.com/bdelacretaz/OSGi-for-mere-mortals
 Your host today: @bdelacretaz, grep.codeconsult.ch
OSGi for
Mere Mortals
                                                        30

Weitere ähnliche Inhalte

Was ist angesagt?

What's cool in the new and updated OSGi Specs (EclipseCon 2014)
What's cool in the new and updated OSGi Specs (EclipseCon 2014)What's cool in the new and updated OSGi Specs (EclipseCon 2014)
What's cool in the new and updated OSGi Specs (EclipseCon 2014)David Bosschaert
 
Steve Singer - Managing PostgreSQL with Puppet @ Postgres Open
Steve Singer - Managing PostgreSQL with Puppet @ Postgres OpenSteve Singer - Managing PostgreSQL with Puppet @ Postgres Open
Steve Singer - Managing PostgreSQL with Puppet @ Postgres OpenPostgresOpen
 
OSGi Cloud Ecosystems (EclipseCon 2013)
OSGi Cloud Ecosystems (EclipseCon 2013)OSGi Cloud Ecosystems (EclipseCon 2013)
OSGi Cloud Ecosystems (EclipseCon 2013)David Bosschaert
 
Writing Plugged-in Java EE Apps: Jason Lee
Writing Plugged-in Java EE Apps: Jason LeeWriting Plugged-in Java EE Apps: Jason Lee
Writing Plugged-in Java EE Apps: Jason Leejaxconf
 
What you need to remember when you upload to CPAN
What you need to remember when you upload to CPANWhat you need to remember when you upload to CPAN
What you need to remember when you upload to CPANcharsbar
 
Making Exceptions on Exception Handling (WEH 2012 Keynote Speech)
Making Exceptions on  Exception Handling (WEH 2012 Keynote Speech)Making Exceptions on  Exception Handling (WEH 2012 Keynote Speech)
Making Exceptions on Exception Handling (WEH 2012 Keynote Speech)Tao Xie
 
Continuous Integration: SaaS vs Jenkins in Cloud
Continuous Integration: SaaS vs Jenkins in CloudContinuous Integration: SaaS vs Jenkins in Cloud
Continuous Integration: SaaS vs Jenkins in CloudIdeato
 
How to Make Ruby CGI Script Faster - CGIを高速化する小手先テクニック -
How to Make Ruby CGI Script Faster - CGIを高速化する小手先テクニック -How to Make Ruby CGI Script Faster - CGIを高速化する小手先テクニック -
How to Make Ruby CGI Script Faster - CGIを高速化する小手先テクニック -kwatch
 
Fiber in the 10th year
Fiber in the 10th yearFiber in the 10th year
Fiber in the 10th yearKoichi Sasada
 
Mac ruby deployment
Mac ruby deploymentMac ruby deployment
Mac ruby deploymentThilo Utke
 
Using puppet
Using puppetUsing puppet
Using puppetAlex Su
 
"Highlights from Java 10&11 and Future of Java" at Java User Group Bonn 2018 ...
"Highlights from Java 10&11 and Future of Java" at Java User Group Bonn 2018 ..."Highlights from Java 10&11 and Future of Java" at Java User Group Bonn 2018 ...
"Highlights from Java 10&11 and Future of Java" at Java User Group Bonn 2018 ...Vadym Kazulkin
 
Stackless Python In Eve
Stackless Python In EveStackless Python In Eve
Stackless Python In Evel xf
 
Performance evaluation of cloudera impala 0.6 beta with comparison to Hive
Performance evaluation of cloudera impala 0.6 beta with comparison to HivePerformance evaluation of cloudera impala 0.6 beta with comparison to Hive
Performance evaluation of cloudera impala 0.6 beta with comparison to HiveYukinori Suda
 
Scaling Django with gevent
Scaling Django with geventScaling Django with gevent
Scaling Django with geventMahendra M
 

Was ist angesagt? (20)

Kayobe_desc
Kayobe_descKayobe_desc
Kayobe_desc
 
What's cool in the new and updated OSGi Specs (EclipseCon 2014)
What's cool in the new and updated OSGi Specs (EclipseCon 2014)What's cool in the new and updated OSGi Specs (EclipseCon 2014)
What's cool in the new and updated OSGi Specs (EclipseCon 2014)
 
Steve Singer - Managing PostgreSQL with Puppet @ Postgres Open
Steve Singer - Managing PostgreSQL with Puppet @ Postgres OpenSteve Singer - Managing PostgreSQL with Puppet @ Postgres Open
Steve Singer - Managing PostgreSQL with Puppet @ Postgres Open
 
OSGi Cloud Ecosystems (EclipseCon 2013)
OSGi Cloud Ecosystems (EclipseCon 2013)OSGi Cloud Ecosystems (EclipseCon 2013)
OSGi Cloud Ecosystems (EclipseCon 2013)
 
Puppet evolutions
Puppet evolutionsPuppet evolutions
Puppet evolutions
 
Php version 5
Php version 5Php version 5
Php version 5
 
kubernetes practice
kubernetes practicekubernetes practice
kubernetes practice
 
Writing Plugged-in Java EE Apps: Jason Lee
Writing Plugged-in Java EE Apps: Jason LeeWriting Plugged-in Java EE Apps: Jason Lee
Writing Plugged-in Java EE Apps: Jason Lee
 
What you need to remember when you upload to CPAN
What you need to remember when you upload to CPANWhat you need to remember when you upload to CPAN
What you need to remember when you upload to CPAN
 
Making Exceptions on Exception Handling (WEH 2012 Keynote Speech)
Making Exceptions on  Exception Handling (WEH 2012 Keynote Speech)Making Exceptions on  Exception Handling (WEH 2012 Keynote Speech)
Making Exceptions on Exception Handling (WEH 2012 Keynote Speech)
 
Continuous Integration: SaaS vs Jenkins in Cloud
Continuous Integration: SaaS vs Jenkins in CloudContinuous Integration: SaaS vs Jenkins in Cloud
Continuous Integration: SaaS vs Jenkins in Cloud
 
How to Make Ruby CGI Script Faster - CGIを高速化する小手先テクニック -
How to Make Ruby CGI Script Faster - CGIを高速化する小手先テクニック -How to Make Ruby CGI Script Faster - CGIを高速化する小手先テクニック -
How to Make Ruby CGI Script Faster - CGIを高速化する小手先テクニック -
 
Fiber in the 10th year
Fiber in the 10th yearFiber in the 10th year
Fiber in the 10th year
 
Mac ruby deployment
Mac ruby deploymentMac ruby deployment
Mac ruby deployment
 
Using puppet
Using puppetUsing puppet
Using puppet
 
"Highlights from Java 10&11 and Future of Java" at Java User Group Bonn 2018 ...
"Highlights from Java 10&11 and Future of Java" at Java User Group Bonn 2018 ..."Highlights from Java 10&11 and Future of Java" at Java User Group Bonn 2018 ...
"Highlights from Java 10&11 and Future of Java" at Java User Group Bonn 2018 ...
 
Stackless Python In Eve
Stackless Python In EveStackless Python In Eve
Stackless Python In Eve
 
Performance evaluation of cloudera impala 0.6 beta with comparison to Hive
Performance evaluation of cloudera impala 0.6 beta with comparison to HivePerformance evaluation of cloudera impala 0.6 beta with comparison to Hive
Performance evaluation of cloudera impala 0.6 beta with comparison to Hive
 
ZODB Tips and Tricks
ZODB Tips and TricksZODB Tips and Tricks
ZODB Tips and Tricks
 
Scaling Django with gevent
Scaling Django with geventScaling Django with gevent
Scaling Django with gevent
 

Ähnlich wie OSGi for mere mortals

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 DAMLars Trieloff
 
OSGi-enabled Java EE applications in GlassFish
OSGi-enabled Java EE applications in GlassFishOSGi-enabled Java EE applications in GlassFish
OSGi-enabled Java EE applications in GlassFishArun Gupta
 
OSGi-enabled Java EE Applications using GlassFish
OSGi-enabled Java EE Applications using GlassFishOSGi-enabled Java EE Applications using GlassFish
OSGi-enabled Java EE Applications using GlassFishArun Gupta
 
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
 
Enterprise OSGi at eBay
Enterprise OSGi at eBayEnterprise OSGi at eBay
Enterprise OSGi at eBayTony Ng
 
OSGi and Java EE in GlassFish - Tech Days 2010 India
OSGi and Java EE in GlassFish - Tech Days 2010 IndiaOSGi and Java EE in GlassFish - Tech Days 2010 India
OSGi and Java EE in GlassFish - Tech Days 2010 IndiaArun Gupta
 
OSGi & Java EE in GlassFish - Best of both worlds
OSGi & Java EE in GlassFish - Best of both worldsOSGi & Java EE in GlassFish - Best of both worlds
OSGi & Java EE in GlassFish - Best of both worldsArun Gupta
 
Managing large and distributed Eclipse server applications.
Managing large and distributed Eclipse server applications.Managing large and distributed Eclipse server applications.
Managing large and distributed Eclipse server applications.Gunnar Wagenknecht
 
OSGi & Java EE in GlassFish @ Silicon Valley Code Camp 2010
OSGi & Java EE in GlassFish @ Silicon Valley Code Camp 2010OSGi & Java EE in GlassFish @ Silicon Valley Code Camp 2010
OSGi & Java EE in GlassFish @ Silicon Valley Code Camp 2010Arun Gupta
 
Using OSGi for script deployment in Apache Sling
Using OSGi for script deployment in Apache SlingUsing OSGi for script deployment in Apache Sling
Using OSGi for script deployment in Apache SlingRadu Cotescu
 
OSGi Service Platform 4.2
OSGi Service Platform 4.2OSGi Service Platform 4.2
OSGi Service Platform 4.2Ilya Katsov
 
TDC 2011: OSGi-enabled Java EE Application
TDC 2011: OSGi-enabled Java EE ApplicationTDC 2011: OSGi-enabled Java EE Application
TDC 2011: OSGi-enabled Java EE ApplicationArun Gupta
 
OSGi-enabled Java EE Applications using GlassFish at JCertif 2011
OSGi-enabled Java EE Applications using GlassFish at JCertif 2011OSGi-enabled Java EE Applications using GlassFish at JCertif 2011
OSGi-enabled Java EE Applications using GlassFish at JCertif 2011Arun Gupta
 
Distributed OSGi Demo Eclipsecon 2009
Distributed OSGi Demo Eclipsecon 2009Distributed OSGi Demo Eclipsecon 2009
Distributed OSGi Demo Eclipsecon 2009David Bosschaert
 
Escape the defaults - Configure Sling like AEM as a Cloud Service
Escape the defaults - Configure Sling like AEM as a Cloud ServiceEscape the defaults - Configure Sling like AEM as a Cloud Service
Escape the defaults - Configure Sling like AEM as a Cloud ServiceRobert Munteanu
 
A Tale of a Server Architecture (Frozen Rails 2012)
A Tale of a Server Architecture (Frozen Rails 2012)A Tale of a Server Architecture (Frozen Rails 2012)
A Tale of a Server Architecture (Frozen Rails 2012)Flowdock
 

Ähnlich wie OSGi for mere mortals (20)

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
 
OSGi-enabled Java EE applications in GlassFish
OSGi-enabled Java EE applications in GlassFishOSGi-enabled Java EE applications in GlassFish
OSGi-enabled Java EE applications in GlassFish
 
Polyglot OSGi
Polyglot OSGiPolyglot OSGi
Polyglot OSGi
 
OSGi-enabled Java EE Applications using GlassFish
OSGi-enabled Java EE Applications using GlassFishOSGi-enabled Java EE Applications using GlassFish
OSGi-enabled Java EE Applications using GlassFish
 
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
 
Enterprise OSGi at eBay
Enterprise OSGi at eBayEnterprise OSGi at eBay
Enterprise OSGi at eBay
 
OSGi and Java EE in GlassFish - Tech Days 2010 India
OSGi and Java EE in GlassFish - Tech Days 2010 IndiaOSGi and Java EE in GlassFish - Tech Days 2010 India
OSGi and Java EE in GlassFish - Tech Days 2010 India
 
OSGi & Java EE in GlassFish - Best of both worlds
OSGi & Java EE in GlassFish - Best of both worldsOSGi & Java EE in GlassFish - Best of both worlds
OSGi & Java EE in GlassFish - Best of both worlds
 
Hybrid Applications
Hybrid ApplicationsHybrid Applications
Hybrid Applications
 
Managing large and distributed Eclipse server applications.
Managing large and distributed Eclipse server applications.Managing large and distributed Eclipse server applications.
Managing large and distributed Eclipse server applications.
 
OSGi & Java EE in GlassFish @ Silicon Valley Code Camp 2010
OSGi & Java EE in GlassFish @ Silicon Valley Code Camp 2010OSGi & Java EE in GlassFish @ Silicon Valley Code Camp 2010
OSGi & Java EE in GlassFish @ Silicon Valley Code Camp 2010
 
Using OSGi for script deployment in Apache Sling
Using OSGi for script deployment in Apache SlingUsing OSGi for script deployment in Apache Sling
Using OSGi for script deployment in Apache Sling
 
OSGi Service Platform 4.2
OSGi Service Platform 4.2OSGi Service Platform 4.2
OSGi Service Platform 4.2
 
TDC 2011: OSGi-enabled Java EE Application
TDC 2011: OSGi-enabled Java EE ApplicationTDC 2011: OSGi-enabled Java EE Application
TDC 2011: OSGi-enabled Java EE Application
 
OSGi-enabled Java EE Applications using GlassFish at JCertif 2011
OSGi-enabled Java EE Applications using GlassFish at JCertif 2011OSGi-enabled Java EE Applications using GlassFish at JCertif 2011
OSGi-enabled Java EE Applications using GlassFish at JCertif 2011
 
Distributed OSGi Demo Eclipsecon 2009
Distributed OSGi Demo Eclipsecon 2009Distributed OSGi Demo Eclipsecon 2009
Distributed OSGi Demo Eclipsecon 2009
 
Tales from the OSGi trenches
Tales from the OSGi trenchesTales from the OSGi trenches
Tales from the OSGi trenches
 
Escape the defaults - Configure Sling like AEM as a Cloud Service
Escape the defaults - Configure Sling like AEM as a Cloud ServiceEscape the defaults - Configure Sling like AEM as a Cloud Service
Escape the defaults - Configure Sling like AEM as a Cloud Service
 
A Tale of a Server Architecture (Frozen Rails 2012)
A Tale of a Server Architecture (Frozen Rails 2012)A Tale of a Server Architecture (Frozen Rails 2012)
A Tale of a Server Architecture (Frozen Rails 2012)
 
CQ5 and Sling overview
CQ5 and Sling overviewCQ5 and Sling overview
CQ5 and Sling overview
 

Mehr von Bertrand Delacretaz

VanillaJS & the Web Platform, a match made in heaven?
VanillaJS & the Web Platform, a match made in heaven?VanillaJS & the Web Platform, a match made in heaven?
VanillaJS & the Web Platform, a match made in heaven?Bertrand Delacretaz
 
Surviving large online communities with conciseness and clarity
Surviving large online communities with conciseness and clarity Surviving large online communities with conciseness and clarity
Surviving large online communities with conciseness and clarity Bertrand Delacretaz
 
Repoinit: a mini-language for content repository initialization
Repoinit: a mini-language for content repository initializationRepoinit: a mini-language for content repository initialization
Repoinit: a mini-language for content repository initializationBertrand Delacretaz
 
The Moving House Model, adhocracy and remote collaboration
The Moving House Model, adhocracy and remote collaborationThe Moving House Model, adhocracy and remote collaboration
The Moving House Model, adhocracy and remote collaborationBertrand Delacretaz
 
GraphQL in Apache Sling - but isn't it the opposite of REST?
GraphQL in Apache Sling - but isn't it the opposite of REST?GraphQL in Apache Sling - but isn't it the opposite of REST?
GraphQL in Apache Sling - but isn't it the opposite of REST?Bertrand Delacretaz
 
How to convince your left brain (or manager) to follow the Open Source path t...
How to convince your left brain (or manager) to follow the Open Source path t...How to convince your left brain (or manager) to follow the Open Source path t...
How to convince your left brain (or manager) to follow the Open Source path t...Bertrand Delacretaz
 
L'Open Source change le Monde - BlendWebMix 2019
L'Open Source change le Monde - BlendWebMix 2019L'Open Source change le Monde - BlendWebMix 2019
L'Open Source change le Monde - BlendWebMix 2019Bertrand Delacretaz
 
Shared Neurons - the Secret Sauce of Open Source communities?
Shared Neurons - the Secret Sauce of Open Source communities?Shared Neurons - the Secret Sauce of Open Source communities?
Shared Neurons - the Secret Sauce of Open Source communities?Bertrand Delacretaz
 
Sling and Serverless, Best Friends Forever?
Sling and Serverless, Best Friends Forever?Sling and Serverless, Best Friends Forever?
Sling and Serverless, Best Friends Forever?Bertrand Delacretaz
 
Serverless - introduction et perspectives concrètes
Serverless - introduction et perspectives concrètesServerless - introduction et perspectives concrètes
Serverless - introduction et perspectives concrètesBertrand Delacretaz
 
State of the Feather - ApacheCon North America 2018
State of the Feather - ApacheCon North America 2018State of the Feather - ApacheCon North America 2018
State of the Feather - ApacheCon North America 2018Bertrand Delacretaz
 
Karate, the black belt of HTTP API testing?
Karate, the black belt of HTTP API testing?Karate, the black belt of HTTP API testing?
Karate, the black belt of HTTP API testing?Bertrand Delacretaz
 
Open Source at Scale: the Apache Software Foundation (2018)
Open Source at Scale: the Apache Software Foundation (2018)Open Source at Scale: the Apache Software Foundation (2018)
Open Source at Scale: the Apache Software Foundation (2018)Bertrand Delacretaz
 
They don't understand me! Tales from the multi-cultural trenches
They don't understand me! Tales from the multi-cultural trenchesThey don't understand me! Tales from the multi-cultural trenches
They don't understand me! Tales from the multi-cultural trenchesBertrand Delacretaz
 
Prise de Décisions Asynchrone, Devoxx France 2018 (avec vidéo)
Prise de Décisions Asynchrone, Devoxx France 2018 (avec vidéo)Prise de Décisions Asynchrone, Devoxx France 2018 (avec vidéo)
Prise de Décisions Asynchrone, Devoxx France 2018 (avec vidéo)Bertrand Delacretaz
 
Project and Community Services the Apache Way
Project and Community Services the Apache WayProject and Community Services the Apache Way
Project and Community Services the Apache WayBertrand Delacretaz
 
La Fondation Apache - keynote au Paris Open Source Summit 2017
La Fondation Apache - keynote au Paris Open Source Summit 2017La Fondation Apache - keynote au Paris Open Source Summit 2017
La Fondation Apache - keynote au Paris Open Source Summit 2017Bertrand Delacretaz
 
Asynchronous Decision Making - FOSS Backstage 2017
Asynchronous Decision Making - FOSS Backstage 2017Asynchronous Decision Making - FOSS Backstage 2017
Asynchronous Decision Making - FOSS Backstage 2017Bertrand Delacretaz
 
Building an Apache Sling Rendering Farm
Building an Apache Sling Rendering FarmBuilding an Apache Sling Rendering Farm
Building an Apache Sling Rendering FarmBertrand Delacretaz
 

Mehr von Bertrand Delacretaz (20)

VanillaJS & the Web Platform, a match made in heaven?
VanillaJS & the Web Platform, a match made in heaven?VanillaJS & the Web Platform, a match made in heaven?
VanillaJS & the Web Platform, a match made in heaven?
 
Surviving large online communities with conciseness and clarity
Surviving large online communities with conciseness and clarity Surviving large online communities with conciseness and clarity
Surviving large online communities with conciseness and clarity
 
Repoinit: a mini-language for content repository initialization
Repoinit: a mini-language for content repository initializationRepoinit: a mini-language for content repository initialization
Repoinit: a mini-language for content repository initialization
 
The Moving House Model, adhocracy and remote collaboration
The Moving House Model, adhocracy and remote collaborationThe Moving House Model, adhocracy and remote collaboration
The Moving House Model, adhocracy and remote collaboration
 
GraphQL in Apache Sling - but isn't it the opposite of REST?
GraphQL in Apache Sling - but isn't it the opposite of REST?GraphQL in Apache Sling - but isn't it the opposite of REST?
GraphQL in Apache Sling - but isn't it the opposite of REST?
 
Open Source Changes the World!
Open Source Changes the World!Open Source Changes the World!
Open Source Changes the World!
 
How to convince your left brain (or manager) to follow the Open Source path t...
How to convince your left brain (or manager) to follow the Open Source path t...How to convince your left brain (or manager) to follow the Open Source path t...
How to convince your left brain (or manager) to follow the Open Source path t...
 
L'Open Source change le Monde - BlendWebMix 2019
L'Open Source change le Monde - BlendWebMix 2019L'Open Source change le Monde - BlendWebMix 2019
L'Open Source change le Monde - BlendWebMix 2019
 
Shared Neurons - the Secret Sauce of Open Source communities?
Shared Neurons - the Secret Sauce of Open Source communities?Shared Neurons - the Secret Sauce of Open Source communities?
Shared Neurons - the Secret Sauce of Open Source communities?
 
Sling and Serverless, Best Friends Forever?
Sling and Serverless, Best Friends Forever?Sling and Serverless, Best Friends Forever?
Sling and Serverless, Best Friends Forever?
 
Serverless - introduction et perspectives concrètes
Serverless - introduction et perspectives concrètesServerless - introduction et perspectives concrètes
Serverless - introduction et perspectives concrètes
 
State of the Feather - ApacheCon North America 2018
State of the Feather - ApacheCon North America 2018State of the Feather - ApacheCon North America 2018
State of the Feather - ApacheCon North America 2018
 
Karate, the black belt of HTTP API testing?
Karate, the black belt of HTTP API testing?Karate, the black belt of HTTP API testing?
Karate, the black belt of HTTP API testing?
 
Open Source at Scale: the Apache Software Foundation (2018)
Open Source at Scale: the Apache Software Foundation (2018)Open Source at Scale: the Apache Software Foundation (2018)
Open Source at Scale: the Apache Software Foundation (2018)
 
They don't understand me! Tales from the multi-cultural trenches
They don't understand me! Tales from the multi-cultural trenchesThey don't understand me! Tales from the multi-cultural trenches
They don't understand me! Tales from the multi-cultural trenches
 
Prise de Décisions Asynchrone, Devoxx France 2018 (avec vidéo)
Prise de Décisions Asynchrone, Devoxx France 2018 (avec vidéo)Prise de Décisions Asynchrone, Devoxx France 2018 (avec vidéo)
Prise de Décisions Asynchrone, Devoxx France 2018 (avec vidéo)
 
Project and Community Services the Apache Way
Project and Community Services the Apache WayProject and Community Services the Apache Way
Project and Community Services the Apache Way
 
La Fondation Apache - keynote au Paris Open Source Summit 2017
La Fondation Apache - keynote au Paris Open Source Summit 2017La Fondation Apache - keynote au Paris Open Source Summit 2017
La Fondation Apache - keynote au Paris Open Source Summit 2017
 
Asynchronous Decision Making - FOSS Backstage 2017
Asynchronous Decision Making - FOSS Backstage 2017Asynchronous Decision Making - FOSS Backstage 2017
Asynchronous Decision Making - FOSS Backstage 2017
 
Building an Apache Sling Rendering Farm
Building an Apache Sling Rendering FarmBuilding an Apache Sling Rendering Farm
Building an Apache Sling Rendering Farm
 

Kürzlich hochgeladen

Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...AliaaTarek5
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditSkynet Technologies
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 

Kürzlich hochgeladen (20)

Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance Audit
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 

OSGi for mere mortals

  • 1. OSGi for mere mortals Simple and robus t sof t ware is go o d f or yo ur wor k-life b alance . Bertrand Delacrétaz Senior Developer, Adobe Digital Enterprise Systems, www.day.com Apache So ware Foundation Member and (current) Director h p://grep.codeconsult.ch - twi er: @bdelacretaz - bdelacretaz@apache.org ApacheCon North America 2011, Vancouver, November 2011 slides revision: 2011-11-05 (on a plane) OSGi for 1 Mere Mortals 1
  • 2. what? a simple RESTful server built from scratch on OSGi to show that it’s not rocket science, even starting from scratch... OSGi for Mere Mortals 2
  • 3. RESTfulcontent: POST to store server? $ date | curl -T - -X POST -D - http://localhost:8080/store/example HTTP/1.1 201 Created Location: /store/example Content-Type: text/plain; charset=utf-8 Content-Length: 178 Server: Jetty(6.1.x) Stored at /store/example StoredBy:ch.x42.osgi.samples.osgi101.app.servlets.StorageServlet StoredAt:Fri Nov 04 10:41:30 CET 2011 Path:/store/example Fri Nov 4 10:41:30 CET 2011 OSGi for Mere Mortals 3
  • 4. RESTful server! GET to retrieve content: $ curl http://localhost:8080/store/example StoredBy:ch.x42.osgi.samples.osgi101.app.servlets.StorageServlet StoredAt:Fri Nov 04 10:41:30 CET 2011 Path:/store/example Fri Nov 4 10:41:30 CET 2011 In terms of functionality, that’s it! OSGi for Mere Mortals 4
  • 5. It’s not big... 107 ./app/pom.xml 35 ./app/.../InMemoryStorage.java 34 ./app/.../PathsStorage.java 147 ./app/.../StorageServlet.java 101 ./core/pom.xml 6 ./core/...CoreConstants.java 32 ./core/...DefaultGetServlet.java 32 ./core/...DefaultPostServlet.java 116 ./core/...DispatcherServlet.java 8 ./core/...Storage.java 208 ./launcher/pom.xml 84 ./launcher/...OsgiBootstrap.java 52 ./pom.xml 962 lines in total, including 468 lines in pom.xml files... OSGi for Mere Mortals 5
  • 6. Components Dynamic Services Server OSGi framework Application core Application services Bootstrapping and standard services HTTP HttpService Dispatcher InMemoryStorage Servlet Services Components Default POST Runtime (SCR) StorageServlet Servlet Configuration Default GET PathsStorage Servlet Logging HTTP Felix Web Console shell Felix Shell indicates SCR ser vices also: maven-bundle plugin maven-scr-plugin OSGi for maven-dependency-plugin Mere Mortals 6
  • 7. Bootstrapping and loading bundles OSGi for 7 Mere Mortals 7
  • 8. Framework start and stop Called from a plain main() method OSGi for Mere Mortals 8
  • 9. Get bundles from Maven repo Copy to a folder using maven-dependency-plugin in launcher OSGi for Mere Mortals 9
  • 10. Install bundles from lesystem BundleContext.installBundle(URL) Install all bundles rst, then start all OSGi for Mere Mortals 10
  • 11. Live bundles list From the Felix console at /system/console We’re good to go! OSGi for Mere Mortals 11
  • 12. Our OSGi bundles HttpService org.apache.felix.h p.je y Logging org.apache.sling.commons.log Services Components Runtime (SCR) org.apache.felix.scr Configuration org.apache.felix.metatype org.apache.felix.con gadmin Felix Shell org.apache.felix.shell org.apache.felix.shell.tui Felix Web Console org.apache.felix.webconsole Application Core osgi-for-mere-mortals-core Application Services osgi-for-mere-mortals-app OSGi for Mere Mortals 12
  • 13. Dispatcher Servlet OSGi for 13 Mere Mortals 13
  • 14. DispatcherServletforComponent Register with H pService and watch Servlet services Dispatcher Servlet OSGi for Mere Mortals 14
  • 15. DispatcherServletServlets Dispatch to OSGi services which are Dispatcher Servlet Default GET Servlet OSGi for Mere Mortals 15
  • 16. Default GET Servlet OSGi for 16 Mere Mortals 16
  • 17. Default GETSCR annotations Just a servlet, with some servlet Default GET Servlet OSGi for Mere Mortals 17
  • 18. Storage Services OSGi for 18 Mere Mortals 18
  • 19. Storage service interface De ned in the core bundle, package is exported OSGi for Mere Mortals 19
  • 20. Storage service#1: in memory Active by default OSGi for Mere Mortals 20
  • 21. Storage service#2: can be activated in console Alternate service, inactive by default, just paths OSGi for Mere Mortals 21
  • 22. Storage Servlet OSGi for 22 Mere Mortals 22
  • 23. StorageServlet service Uses @Reference to get a Storage Properties used by DispatcherSer vlet The Component will only start once a Storage service is available OSGi for Mere Mortals 23
  • 24. Alternate Storage demo OSGi for 24 Mere Mortals 24
  • 25. Replaceone and enabling another ComponentStorage By disabling In-memory with paths 1) disable inMemoryStorage -> StorageServlet stops 2) enable PathsStorage -> StorageServlet is back OSGi for Mere Mortals 25
  • 26. Con guration demo OSGi for 26 Mere Mortals 26
  • 27. Configuring the StorageServlet Con gurationAdmin service, console and annotations 1) User provides con guration data in web console (or Felix shell, Sling Installer, ...) Felix Web Console 2) Console (con guration agent) changes values ConfigurationAdmin StorageServlet 3) Con gurationAdmin deactivates and reactivates Component with new Con g 0) Component has metatype=true and some OSGi for non-private @Property annotations Mere Mortals 27
  • 28. StorageServlet Configuration code Annotations + read values in activate() Parameter names + descriptions in metatype.properties OSGi for Mere Mortals 28
  • 30. Conclusions Powerful out of the box infrastructure, not much code to write. Modular component-based architecture. Dynamic (re)con guration, both in terms of components and parameters. OSGi materializes the component-based programming vision in Java, and using it is not rocket science! Code at github.com/bdelacretaz/OSGi-for-mere-mortals Your host today: @bdelacretaz, grep.codeconsult.ch OSGi for Mere Mortals 30