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

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Introducing the official SlideShare app

Stunning, full-screen experience for iPhone and Android

Text the download link to your phone

Standard text messaging rates apply

OSGi Puzzlers - Neil Bartlett & Peter Kriens

1,057
views

Published on

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.

Published in: Technology, Education

0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,057
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
25
Comments
0
Likes
2
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. OSGi Puzzlers Neil Bartlett and Peter Kriens
  • 2. Overlapping Concerns...
  • 3. What Does it Print? MyService P1 P2 Example Component NOW STOP BUNDLE P1... MyService
  • 4. CKFU! (OBVIOUSLY)
  • 5. 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)
  • 6. 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! } }
  • 7. 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; } }
  • 8. 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); } }
  • 9. Stooopid Hoooman...
  • 10. 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
  • 11. 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
  • 12. WTF?
  • 13. 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
  • 14. You Gotta Start Me Up...
  • 15. What Does It Print? A. “Constructed...Started.” B. “Constructed...” C. Nothing D. IllegalAccessException E. “Started.”
  • 16. What Does It Print? A. “Constructed...Started.” B. “Constructed...” C. Nothing D. IllegalAccessException E. “Started.”
  • 17. WTF? DS Services are Lazy Not an error... just waiting for a consumer!
  • 18. REMEMBER: OSGi is Your Friend!