OSGi Puzzlers - Neil Bartlett & Peter Kriens
Upcoming SlideShare
Loading in...5
×
 

OSGi Puzzlers - Neil Bartlett & Peter Kriens

on

  • 843 views

OSGi Community Event 2013 (http://www.osgi.org/CommunityEvent2013/Schedule) ...

OSGi Community Event 2013 (http://www.osgi.org/CommunityEvent2013/Schedule)

Lightning Talk

ABSTRACT
A fun look at some of the traps and pitfalls that people come across when working with OSGi, along with suggestions on how you should deal with these cases in point.

Statistics

Views

Total Views
843
Slideshare-icon Views on SlideShare
843
Embed Views
0

Actions

Likes
1
Downloads
20
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    OSGi Puzzlers - Neil Bartlett & Peter Kriens OSGi Puzzlers - Neil Bartlett & Peter Kriens Presentation Transcript

    • OSGi Puzzlers Neil Bartlett and Peter Kriens
    • Overlapping Concerns...
    • What Does it Print? MyService P1 P2 Example Component NOW STOP BUNDLE P1... MyService
    • CKFU! (OBVIOUSLY)
    • WTF? OSGi Compendium, section 112.5.10 Dynamic Service Replacement “SCR must first bind a replacement target service and then unbind the outgoing service” (emphasis added)
    • Beware this Pattern @Component public class ExampleComponent { private MyService svc; @Reference(dynamic = true) public void setMyService(MyService svc) { this.svc = svc; } public void unsetMyService(MyService svc) { this.svc = null; // OOOPS! } }
    • Better... @Component public class ExampleComponent { private MyService svc; @Reference(dynamic = true) public synchronized void setMyService(MyService svc) { this.svc = svc; } public synchronized void unsetMyService(MyService svc) { if (this.svc == svc) this.svc = null; } }
    • Even Better... @Component public class ExampleComponent { private final AtomicReference<MyService> svcRef = new AtomicReference<>(); @Reference(dynamic = true) public void setMyService(MyService svc) { svcRef.set(svc); } public void unsetMyService(MyService svc) { svcRef.compareAndSet(svc, null); } }
    • Stooopid Hoooman...
    • What Does It Print? A. 0,1,2,3,4,5,6,7,8,9,... B. 1, C. 1,2,3,4,5,6,7,8,9,.... D. NullPointerException
    • What Does It Print? A. 0,1,2,3,4,5,6,7,8,9,... B. 1, C. 1,2,3,4,5,6,7,8,9,.... D. NullPointerException
    • WTF?
    • Blacklisting EventHandlers have to return quickly If they don’t... BLACKLIST! No more events for you. Humans are slow and stooopid. Turn off blacklisting, OR use printf-style debugging
    • You Gotta Start Me Up...
    • What Does It Print? A. “Constructed...Started.” B. “Constructed...” C. Nothing D. IllegalAccessException E. “Started.”
    • What Does It Print? A. “Constructed...Started.” B. “Constructed...” C. Nothing D. IllegalAccessException E. “Started.”
    • WTF? DS Services are Lazy Not an error... just waiting for a consumer!
    • REMEMBER: OSGi is Your Friend!