SlideShare una empresa de Scribd logo
1 de 15
Pet
                                     er K
                                            rien
                                                s, a
                                                       Qu
                                                         te
                  grav   e, IBM
        B   J Har




                           OSGi Puzzlers
Tuesday, March 22, 2011
1. Attachment

   H1                                                  H2
         Bundle-SymbolicName: foo.host                      Bundle-SymbolicName: foo.host
         Bundle-Version: 1.0                                Bundle-Version: 2.0


                          F
                              Bundle-SymbolicName: foo.fragment
                              Fragment-Host: foo.host; version=”[1.0,2.0)”




Tuesday, March 22, 2011
To what host(s) does fragment F attach when
    resolved?

   H1                                                  H2
         Bundle-SymbolicName: foo.host                      Bundle-SymbolicName: foo.host
         Bundle-Version: 1.0                                Bundle-Version: 2.0


                          F
                              Bundle-SymbolicName: foo.fragment
                              Fragment-Host: foo.host; version=”[1.0,2.0)”




        (a) F attaches to only H1
        (b) F attaches to only H2
        (c) F attaches to both H1 and H2
        (d) F does not attach to either H1 or H2


Tuesday, March 22, 2011
To what host(s) does fragment F attach when
    resolved?

       (a) F attaches to only H1
       (b) F attaches to only H2
       (c) F attaches to both H1 and H2
       (d) F does not attach to either H1 or H2

       bundle-version is the proper attribute! Note: in
       4.3 attribute matching is now supported, so the
       answer will be (d)!




Tuesday, March 22, 2011
Solution

   H1                                                  H2
         Bundle-SymbolicName: foo.host                      Bundle-SymbolicName: foo.host
         Bundle-Version: 1.0                                Bundle-Version: 2.0


                          F
                              Bundle-SymbolicName: foo.fragment
                              Fragment-Host: foo.host; bundle-version=”[1.0,2.0)”




Tuesday, March 22, 2011
2. Waiting For Service

     Thread 1
    // a service in which the tracker is interested is registered

    ...

    Waiter waiter;
    public T addingService(ServiceReference<S> reference) {
        synchronized (waiter) {
            waiter.notify(); // tell waiter about the service
        }
        return super.addingService(reference);
    }



     Thread 2
    // waiter object
    ServiceTracker tracker;
    void waitingForService {
        synchronized (this) {
            wait(); // waiting here for a service
        }
        T service = tracker.getService();
        System.out.println(service);
    }



Tuesday, March 22, 2011
What is printed by Thread 2?

     Thread 1
    // a service in which the tracker is interested is registered

    ...

    Waiter waiter;
                                                                    (a) nothing; thread
    public T addingService(ServiceReference<S> reference) {
        synchronized (waiter) {                                     2 does not reach
            waiter.notify(); // tell waiter about the service
        }
        return super.addingService(reference);
                                                                    println
    }
                                                                    (b) the service
     Thread 2                                                       object
    // waiter object
    ServiceTracker tracker;                                         (c) null
                                                                    (d) none of the
    void waitingForService {
        synchronized (this) {
            wait(); // waiting here for a service
        }
        T service = tracker.getService();
                                                                    above
        System.out.println(service);
    }



Tuesday, March 22, 2011
What is printed by Thread 2?




    (a) nothing; thread 2 does not reach println
    (b) the service object
    (c) null
    (d) none of the above: race condition

    The answer can be (b) or (c) depending on how the
    race works out.


Tuesday, March 22, 2011
Another Look

     Thread 1
    Waiter waiter;
    public T addingService(ServiceReference<S> reference) {
        synchronized (waiter) {
            waiter.notify(); // tell waiter about the service
        }
        return super.addingService(reference);
        // until this method returns, the tracker is not actually tracking the service!
    }



     Thread 2
    // waiter object
    ServiceTracker tracker;
    void waitingForService {
        synchronized (this) {
            wait(); // waiting here for a service
        }
        T service = tracker.getService();
        System.out.println(service);
    }




Tuesday, March 22, 2011
3. Activator

     Component Description
    <component name="example.activator">
      <implementation class="com.acme.Activator"/>
    </component>




    Component Implementation
    public class Activator {
        private String data = null;
        public Activator() {
            data = “initialized”;
        }
        private void activate(ComponentContext context) {
            System.out.println(data);
        }
    }




Tuesday, March 22, 2011
What is printed by the activate method?

     Component Description
    <component name="example.activator">

                                                            (a) null
      <implementation class="com.acme.Activator"/>
    </component>


                                                            (b) initialized
    Component Implementation                                (c) throws
    public class Activator {                                exception
        private String data = null;
        public Activator() {
            data = “initialized”;
                                                            (d) none of the
        }
        private void activate(ComponentContext context) {
                                                            above
            System.out.println(data);
        }
    }




Tuesday, March 22, 2011
What is printed by the activate method?

     (a) null
     (b) initialized
     (c) throws exception
     (d) none of the above: activate method is not
     called

     The component description does not specify a
     namespace and thus is the DS 1.0 namespace. DS
     1.0 required the activate method to be at least
     protected!

Tuesday, March 22, 2011
One Solution: Change accessibility

     Component Description
    <component name="example.activator">
      <implementation class="com.acme.Activator"/>
    </component>




    Component Implementation
    public class Activator {
        private String data = null;
        public Activator() {
            data = “initialized”;
        }
        protected void activate(ComponentContext context) {
            System.out.println(data);
        }
    }




Tuesday, March 22, 2011
Better Solution: Specify the DS 1.1 namespace

     Component Description
    <scr:component name="example.activator"
        xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0">
      <implementation class="com.acme.Activator"/>
    </scr:component>




    Component Implementation
    public class Activator {
        private String data = null;
        public Activator() {
            data = “initialized”;
        }
        private void activate(ComponentContext context) {
            System.out.println(data);
        }
    }




Tuesday, March 22, 2011
Tuesday, March 22, 2011

Más contenido relacionado

La actualidad más candente

Baocao Web Tech Java Mail
Baocao Web Tech Java MailBaocao Web Tech Java Mail
Baocao Web Tech Java Mailxicot
 
C# Application program UNIT III
C# Application program UNIT IIIC# Application program UNIT III
C# Application program UNIT IIIMinu Rajasekaran
 
Advanced Java Practical File
Advanced Java Practical FileAdvanced Java Practical File
Advanced Java Practical FileSoumya Behera
 
Java Concurrency Gotchas
Java Concurrency GotchasJava Concurrency Gotchas
Java Concurrency GotchasAlex Miller
 
Akka cluster overview at 010dev
Akka cluster overview at 010devAkka cluster overview at 010dev
Akka cluster overview at 010devRoland Kuhn
 
Overview of Android Infrastructure
Overview of Android InfrastructureOverview of Android Infrastructure
Overview of Android InfrastructureAlexey Buzdin
 
The Ring programming language version 1.7 book - Part 52 of 196
The Ring programming language version 1.7 book - Part 52 of 196The Ring programming language version 1.7 book - Part 52 of 196
The Ring programming language version 1.7 book - Part 52 of 196Mahmoud Samir Fayed
 
Python concurrency: libraries overview
Python concurrency: libraries overviewPython concurrency: libraries overview
Python concurrency: libraries overviewAndrii Mishkovskyi
 
Python Evolution
Python EvolutionPython Evolution
Python EvolutionQuintagroup
 
Concurrent Programming in Java
Concurrent Programming in JavaConcurrent Programming in Java
Concurrent Programming in JavaRuben Inoto Soto
 
NIO.2, the I/O API for the future
NIO.2, the I/O API for the futureNIO.2, the I/O API for the future
NIO.2, the I/O API for the futureMasoud Kalali
 
The Ring programming language version 1.3 book - Part 7 of 88
The Ring programming language version 1.3 book - Part 7 of 88The Ring programming language version 1.3 book - Part 7 of 88
The Ring programming language version 1.3 book - Part 7 of 88Mahmoud Samir Fayed
 
Active Software Documentation using Soul and IntensiVE
Active Software Documentation using Soul and IntensiVEActive Software Documentation using Soul and IntensiVE
Active Software Documentation using Soul and IntensiVEkim.mens
 
Java9 Beyond Modularity - Java 9 más allá de la modularidad
Java9 Beyond Modularity - Java 9 más allá de la modularidadJava9 Beyond Modularity - Java 9 más allá de la modularidad
Java9 Beyond Modularity - Java 9 más allá de la modularidadDavid Gómez García
 

La actualidad más candente (20)

Baocao Web Tech Java Mail
Baocao Web Tech Java MailBaocao Web Tech Java Mail
Baocao Web Tech Java Mail
 
C# Application program UNIT III
C# Application program UNIT IIIC# Application program UNIT III
C# Application program UNIT III
 
Servlets
ServletsServlets
Servlets
 
Advanced Java Practical File
Advanced Java Practical FileAdvanced Java Practical File
Advanced Java Practical File
 
NIO and NIO2
NIO and NIO2NIO and NIO2
NIO and NIO2
 
Java Concurrency Gotchas
Java Concurrency GotchasJava Concurrency Gotchas
Java Concurrency Gotchas
 
Akka cluster overview at 010dev
Akka cluster overview at 010devAkka cluster overview at 010dev
Akka cluster overview at 010dev
 
srgoc
srgocsrgoc
srgoc
 
Overview of Android Infrastructure
Overview of Android InfrastructureOverview of Android Infrastructure
Overview of Android Infrastructure
 
JAVA NIO
JAVA NIOJAVA NIO
JAVA NIO
 
The Ring programming language version 1.7 book - Part 52 of 196
The Ring programming language version 1.7 book - Part 52 of 196The Ring programming language version 1.7 book - Part 52 of 196
The Ring programming language version 1.7 book - Part 52 of 196
 
Python concurrency: libraries overview
Python concurrency: libraries overviewPython concurrency: libraries overview
Python concurrency: libraries overview
 
Python Evolution
Python EvolutionPython Evolution
Python Evolution
 
Concurrent Programming in Java
Concurrent Programming in JavaConcurrent Programming in Java
Concurrent Programming in Java
 
Clojure: a LISP for the JVM
Clojure: a LISP for the JVMClojure: a LISP for the JVM
Clojure: a LISP for the JVM
 
Ad java prac sol set
Ad java prac sol setAd java prac sol set
Ad java prac sol set
 
NIO.2, the I/O API for the future
NIO.2, the I/O API for the futureNIO.2, the I/O API for the future
NIO.2, the I/O API for the future
 
The Ring programming language version 1.3 book - Part 7 of 88
The Ring programming language version 1.3 book - Part 7 of 88The Ring programming language version 1.3 book - Part 7 of 88
The Ring programming language version 1.3 book - Part 7 of 88
 
Active Software Documentation using Soul and IntensiVE
Active Software Documentation using Soul and IntensiVEActive Software Documentation using Soul and IntensiVE
Active Software Documentation using Soul and IntensiVE
 
Java9 Beyond Modularity - Java 9 más allá de la modularidad
Java9 Beyond Modularity - Java 9 más allá de la modularidadJava9 Beyond Modularity - Java 9 más allá de la modularidad
Java9 Beyond Modularity - Java 9 más allá de la modularidad
 

Destacado

Services-First Migration to OSGi
Services-First Migration to OSGiServices-First Migration to OSGi
Services-First Migration to OSGibjhargrave
 
OSGi 4.3 Technical Update: What's New?
OSGi 4.3 Technical Update: What's New?OSGi 4.3 Technical Update: What's New?
OSGi 4.3 Technical Update: What's New?bjhargrave
 
OSGi for Enterprises
OSGi for EnterprisesOSGi for Enterprises
OSGi for Enterprisesmfrancis
 
What's new in the OSGi Enterprise Release 5.0
What's new in the OSGi Enterprise Release 5.0What's new in the OSGi Enterprise Release 5.0
What's new in the OSGi Enterprise Release 5.0David Bosschaert
 
Field injection, type safe configuration, and more new goodies in Declarative...
Field injection, type safe configuration, and more new goodies in Declarative...Field injection, type safe configuration, and more new goodies in Declarative...
Field injection, type safe configuration, and more new goodies in Declarative...bjhargrave
 
Avoid the chaos - Handling 100+ OSGi Components - Balázs Zsoldos
Avoid the chaos - Handling 100+ OSGi Components - Balázs ZsoldosAvoid the chaos - Handling 100+ OSGi Components - Balázs Zsoldos
Avoid the chaos - Handling 100+ OSGi Components - Balázs Zsoldosmfrancis
 
Hands on with lightweight m2m and Eclipse Leshan
Hands on with lightweight m2m and Eclipse LeshanHands on with lightweight m2m and Eclipse Leshan
Hands on with lightweight m2m and Eclipse LeshanJulien Vermillard
 
How to RSS Feed in Search Engine Optimization and their Benefits.
How to RSS Feed in Search Engine Optimization and their Benefits.How to RSS Feed in Search Engine Optimization and their Benefits.
How to RSS Feed in Search Engine Optimization and their Benefits.karthikzinavo
 
Millennials in the Workplace copy
Millennials in the Workplace copyMillennials in the Workplace copy
Millennials in the Workplace copyD'Shai Hendricks
 
Holistic Approach To Saving Energy Dr Shriiwas Kashalikar
Holistic Approach To Saving Energy Dr Shriiwas KashalikarHolistic Approach To Saving Energy Dr Shriiwas Kashalikar
Holistic Approach To Saving Energy Dr Shriiwas Kashalikardrrima
 
Texas S Ta R Chart, Pp, Lamar
Texas S Ta R Chart, Pp, LamarTexas S Ta R Chart, Pp, Lamar
Texas S Ta R Chart, Pp, Lamarrandymarshall
 
1. Why is the Gospel Important?
1. Why is the Gospel Important?1. Why is the Gospel Important?
1. Why is the Gospel Important?William Anderson
 
Project communication plan v1c cmmaao pmi pmp
Project communication plan v1c cmmaao pmi pmpProject communication plan v1c cmmaao pmi pmp
Project communication plan v1c cmmaao pmi pmpvishvasyadav45
 

Destacado (18)

Services-First Migration to OSGi
Services-First Migration to OSGiServices-First Migration to OSGi
Services-First Migration to OSGi
 
OSGi 4.3 Technical Update: What's New?
OSGi 4.3 Technical Update: What's New?OSGi 4.3 Technical Update: What's New?
OSGi 4.3 Technical Update: What's New?
 
OSGi for Enterprises
OSGi for EnterprisesOSGi for Enterprises
OSGi for Enterprises
 
What's new in the OSGi Enterprise Release 5.0
What's new in the OSGi Enterprise Release 5.0What's new in the OSGi Enterprise Release 5.0
What's new in the OSGi Enterprise Release 5.0
 
Field injection, type safe configuration, and more new goodies in Declarative...
Field injection, type safe configuration, and more new goodies in Declarative...Field injection, type safe configuration, and more new goodies in Declarative...
Field injection, type safe configuration, and more new goodies in Declarative...
 
Avoid the chaos - Handling 100+ OSGi Components - Balázs Zsoldos
Avoid the chaos - Handling 100+ OSGi Components - Balázs ZsoldosAvoid the chaos - Handling 100+ OSGi Components - Balázs Zsoldos
Avoid the chaos - Handling 100+ OSGi Components - Balázs Zsoldos
 
Why OSGi?
Why OSGi?Why OSGi?
Why OSGi?
 
Hands on with lightweight m2m and Eclipse Leshan
Hands on with lightweight m2m and Eclipse LeshanHands on with lightweight m2m and Eclipse Leshan
Hands on with lightweight m2m and Eclipse Leshan
 
How to RSS Feed in Search Engine Optimization and their Benefits.
How to RSS Feed in Search Engine Optimization and their Benefits.How to RSS Feed in Search Engine Optimization and their Benefits.
How to RSS Feed in Search Engine Optimization and their Benefits.
 
Millennials in the Workplace copy
Millennials in the Workplace copyMillennials in the Workplace copy
Millennials in the Workplace copy
 
Holistic Approach To Saving Energy Dr Shriiwas Kashalikar
Holistic Approach To Saving Energy Dr Shriiwas KashalikarHolistic Approach To Saving Energy Dr Shriiwas Kashalikar
Holistic Approach To Saving Energy Dr Shriiwas Kashalikar
 
Texas S Ta R Chart, Pp, Lamar
Texas S Ta R Chart, Pp, LamarTexas S Ta R Chart, Pp, Lamar
Texas S Ta R Chart, Pp, Lamar
 
A Look at Structural Claims
A Look at Structural ClaimsA Look at Structural Claims
A Look at Structural Claims
 
vitamin c
vitamin cvitamin c
vitamin c
 
1. Why is the Gospel Important?
1. Why is the Gospel Important?1. Why is the Gospel Important?
1. Why is the Gospel Important?
 
PSE Insights: Manufacturing
PSE Insights: ManufacturingPSE Insights: Manufacturing
PSE Insights: Manufacturing
 
Project communication plan v1c cmmaao pmi pmp
Project communication plan v1c cmmaao pmi pmpProject communication plan v1c cmmaao pmi pmp
Project communication plan v1c cmmaao pmi pmp
 
Be the Professional Realtor
Be the Professional RealtorBe the Professional Realtor
Be the Professional Realtor
 

Similar a OSGi Puzzlers

The Ring programming language version 1.6 book - Part 184 of 189
The Ring programming language version 1.6 book - Part 184 of 189The Ring programming language version 1.6 book - Part 184 of 189
The Ring programming language version 1.6 book - Part 184 of 189Mahmoud Samir Fayed
 
Migrating from Ext GWT 2.x to 3.0
Migrating from Ext GWT 2.x to 3.0Migrating from Ext GWT 2.x to 3.0
Migrating from Ext GWT 2.x to 3.0Sencha
 
Running a Scalable And Reliable Symfony2 Application in Cloud (Symfony Sweden...
Running a Scalable And Reliable Symfony2 Application in Cloud (Symfony Sweden...Running a Scalable And Reliable Symfony2 Application in Cloud (Symfony Sweden...
Running a Scalable And Reliable Symfony2 Application in Cloud (Symfony Sweden...Ville Mattila
 
Async Best Practices
Async Best PracticesAsync Best Practices
Async Best PracticesLluis Franco
 
C++aptitude questions and answers
C++aptitude questions and answersC++aptitude questions and answers
C++aptitude questions and answerssheibansari
 
Mobicents JSLEE progress and roadmap - Mobicents Summit 2011
Mobicents JSLEE progress and roadmap - Mobicents Summit 2011Mobicents JSLEE progress and roadmap - Mobicents Summit 2011
Mobicents JSLEE progress and roadmap - Mobicents Summit 2011telestax
 
Deuce STM - CMP'09
Deuce STM - CMP'09Deuce STM - CMP'09
Deuce STM - CMP'09Guy Korland
 
The Taverna 2 Platform
The Taverna 2 PlatformThe Taverna 2 Platform
The Taverna 2 PlatformTom Oinn
 
Demoiselle 2.0 no JavaOne Brasil 2010
Demoiselle 2.0 no JavaOne Brasil 2010Demoiselle 2.0 no JavaOne Brasil 2010
Demoiselle 2.0 no JavaOne Brasil 2010Cleverson Sacramento
 
Generalized Functors - Realizing Command Design Pattern in C++
Generalized Functors - Realizing Command Design Pattern in C++Generalized Functors - Realizing Command Design Pattern in C++
Generalized Functors - Realizing Command Design Pattern in C++ppd1961
 
The Ring programming language version 1.8 book - Part 95 of 202
The Ring programming language version 1.8 book - Part 95 of 202The Ring programming language version 1.8 book - Part 95 of 202
The Ring programming language version 1.8 book - Part 95 of 202Mahmoud Samir Fayed
 
Concurrency, Scalability & Fault-tolerance 2.0 with Akka Actors & STM
Concurrency, Scalability & Fault-tolerance 2.0 with Akka Actors & STMConcurrency, Scalability & Fault-tolerance 2.0 with Akka Actors & STM
Concurrency, Scalability & Fault-tolerance 2.0 with Akka Actors & STMMario Fusco
 
Netty from the trenches
Netty from the trenchesNetty from the trenches
Netty from the trenchesJordi Gerona
 
mininet-intro.pdf
mininet-intro.pdfmininet-intro.pdf
mininet-intro.pdfMarioDM3
 
Reactive programming with tracker
Reactive programming with trackerReactive programming with tracker
Reactive programming with trackerDesignveloper
 
Meteor Boulder meetup #1
Meteor Boulder meetup #1Meteor Boulder meetup #1
Meteor Boulder meetup #1Robert Dickert
 

Similar a OSGi Puzzlers (20)

The Ring programming language version 1.6 book - Part 184 of 189
The Ring programming language version 1.6 book - Part 184 of 189The Ring programming language version 1.6 book - Part 184 of 189
The Ring programming language version 1.6 book - Part 184 of 189
 
Akka
AkkaAkka
Akka
 
Multithreading in Java
Multithreading in JavaMultithreading in Java
Multithreading in Java
 
Migrating from Ext GWT 2.x to 3.0
Migrating from Ext GWT 2.x to 3.0Migrating from Ext GWT 2.x to 3.0
Migrating from Ext GWT 2.x to 3.0
 
Running a Scalable And Reliable Symfony2 Application in Cloud (Symfony Sweden...
Running a Scalable And Reliable Symfony2 Application in Cloud (Symfony Sweden...Running a Scalable And Reliable Symfony2 Application in Cloud (Symfony Sweden...
Running a Scalable And Reliable Symfony2 Application in Cloud (Symfony Sweden...
 
Async Best Practices
Async Best PracticesAsync Best Practices
Async Best Practices
 
C++aptitude questions and answers
C++aptitude questions and answersC++aptitude questions and answers
C++aptitude questions and answers
 
Mobicents JSLEE progress and roadmap - Mobicents Summit 2011
Mobicents JSLEE progress and roadmap - Mobicents Summit 2011Mobicents JSLEE progress and roadmap - Mobicents Summit 2011
Mobicents JSLEE progress and roadmap - Mobicents Summit 2011
 
Deuce STM - CMP'09
Deuce STM - CMP'09Deuce STM - CMP'09
Deuce STM - CMP'09
 
The Taverna 2 Platform
The Taverna 2 PlatformThe Taverna 2 Platform
The Taverna 2 Platform
 
Demoiselle 2.0 no JavaOne Brasil 2010
Demoiselle 2.0 no JavaOne Brasil 2010Demoiselle 2.0 no JavaOne Brasil 2010
Demoiselle 2.0 no JavaOne Brasil 2010
 
Generalized Functors - Realizing Command Design Pattern in C++
Generalized Functors - Realizing Command Design Pattern in C++Generalized Functors - Realizing Command Design Pattern in C++
Generalized Functors - Realizing Command Design Pattern in C++
 
C++ aptitude
C++ aptitudeC++ aptitude
C++ aptitude
 
The Ring programming language version 1.8 book - Part 95 of 202
The Ring programming language version 1.8 book - Part 95 of 202The Ring programming language version 1.8 book - Part 95 of 202
The Ring programming language version 1.8 book - Part 95 of 202
 
Concurrency, Scalability & Fault-tolerance 2.0 with Akka Actors & STM
Concurrency, Scalability & Fault-tolerance 2.0 with Akka Actors & STMConcurrency, Scalability & Fault-tolerance 2.0 with Akka Actors & STM
Concurrency, Scalability & Fault-tolerance 2.0 with Akka Actors & STM
 
C++ Functions
C++ FunctionsC++ Functions
C++ Functions
 
Netty from the trenches
Netty from the trenchesNetty from the trenches
Netty from the trenches
 
mininet-intro.pdf
mininet-intro.pdfmininet-intro.pdf
mininet-intro.pdf
 
Reactive programming with tracker
Reactive programming with trackerReactive programming with tracker
Reactive programming with tracker
 
Meteor Boulder meetup #1
Meteor Boulder meetup #1Meteor Boulder meetup #1
Meteor Boulder meetup #1
 

Último

Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
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 StreamsRoshan Dwivedi
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
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...Miguel Araújo
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
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 Processorsdebabhi2
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
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 WorkerThousandEyes
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
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 2024The Digital Insurer
 

Último (20)

Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
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
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
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...
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
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
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
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
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
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
 

OSGi Puzzlers

  • 1. Pet er K rien s, a Qu te grav e, IBM B J Har OSGi Puzzlers Tuesday, March 22, 2011
  • 2. 1. Attachment H1 H2 Bundle-SymbolicName: foo.host Bundle-SymbolicName: foo.host Bundle-Version: 1.0 Bundle-Version: 2.0 F Bundle-SymbolicName: foo.fragment Fragment-Host: foo.host; version=”[1.0,2.0)” Tuesday, March 22, 2011
  • 3. To what host(s) does fragment F attach when resolved? H1 H2 Bundle-SymbolicName: foo.host Bundle-SymbolicName: foo.host Bundle-Version: 1.0 Bundle-Version: 2.0 F Bundle-SymbolicName: foo.fragment Fragment-Host: foo.host; version=”[1.0,2.0)” (a) F attaches to only H1 (b) F attaches to only H2 (c) F attaches to both H1 and H2 (d) F does not attach to either H1 or H2 Tuesday, March 22, 2011
  • 4. To what host(s) does fragment F attach when resolved? (a) F attaches to only H1 (b) F attaches to only H2 (c) F attaches to both H1 and H2 (d) F does not attach to either H1 or H2 bundle-version is the proper attribute! Note: in 4.3 attribute matching is now supported, so the answer will be (d)! Tuesday, March 22, 2011
  • 5. Solution H1 H2 Bundle-SymbolicName: foo.host Bundle-SymbolicName: foo.host Bundle-Version: 1.0 Bundle-Version: 2.0 F Bundle-SymbolicName: foo.fragment Fragment-Host: foo.host; bundle-version=”[1.0,2.0)” Tuesday, March 22, 2011
  • 6. 2. Waiting For Service Thread 1 // a service in which the tracker is interested is registered ... Waiter waiter; public T addingService(ServiceReference<S> reference) { synchronized (waiter) { waiter.notify(); // tell waiter about the service } return super.addingService(reference); } Thread 2 // waiter object ServiceTracker tracker; void waitingForService { synchronized (this) { wait(); // waiting here for a service } T service = tracker.getService(); System.out.println(service); } Tuesday, March 22, 2011
  • 7. What is printed by Thread 2? Thread 1 // a service in which the tracker is interested is registered ... Waiter waiter; (a) nothing; thread public T addingService(ServiceReference<S> reference) { synchronized (waiter) { 2 does not reach waiter.notify(); // tell waiter about the service } return super.addingService(reference); println } (b) the service Thread 2 object // waiter object ServiceTracker tracker; (c) null (d) none of the void waitingForService { synchronized (this) { wait(); // waiting here for a service } T service = tracker.getService(); above System.out.println(service); } Tuesday, March 22, 2011
  • 8. What is printed by Thread 2? (a) nothing; thread 2 does not reach println (b) the service object (c) null (d) none of the above: race condition The answer can be (b) or (c) depending on how the race works out. Tuesday, March 22, 2011
  • 9. Another Look Thread 1 Waiter waiter; public T addingService(ServiceReference<S> reference) { synchronized (waiter) { waiter.notify(); // tell waiter about the service } return super.addingService(reference); // until this method returns, the tracker is not actually tracking the service! } Thread 2 // waiter object ServiceTracker tracker; void waitingForService { synchronized (this) { wait(); // waiting here for a service } T service = tracker.getService(); System.out.println(service); } Tuesday, March 22, 2011
  • 10. 3. Activator Component Description <component name="example.activator"> <implementation class="com.acme.Activator"/> </component> Component Implementation public class Activator { private String data = null; public Activator() { data = “initialized”; } private void activate(ComponentContext context) { System.out.println(data); } } Tuesday, March 22, 2011
  • 11. What is printed by the activate method? Component Description <component name="example.activator"> (a) null <implementation class="com.acme.Activator"/> </component> (b) initialized Component Implementation (c) throws public class Activator { exception private String data = null; public Activator() { data = “initialized”; (d) none of the } private void activate(ComponentContext context) { above System.out.println(data); } } Tuesday, March 22, 2011
  • 12. What is printed by the activate method? (a) null (b) initialized (c) throws exception (d) none of the above: activate method is not called The component description does not specify a namespace and thus is the DS 1.0 namespace. DS 1.0 required the activate method to be at least protected! Tuesday, March 22, 2011
  • 13. One Solution: Change accessibility Component Description <component name="example.activator"> <implementation class="com.acme.Activator"/> </component> Component Implementation public class Activator { private String data = null; public Activator() { data = “initialized”; } protected void activate(ComponentContext context) { System.out.println(data); } } Tuesday, March 22, 2011
  • 14. Better Solution: Specify the DS 1.1 namespace Component Description <scr:component name="example.activator" xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0"> <implementation class="com.acme.Activator"/> </scr:component> Component Implementation public class Activator { private String data = null; public Activator() { data = “initialized”; } private void activate(ComponentContext context) { System.out.println(data); } } Tuesday, March 22, 2011