BUG Community

Welcome! Log In

aturley's Blog

The Whiteboard Pattern

There was a time when computer programs were expected to run unattended. A program was a set of instructions and input data that was fed into the computer, and if everything went well some output data came out of the other end. f(x) = y. Oh, those halcyon days. Today's programs are expected to react to all kinds of events. Sometimes those events are a result of user interaction, like button presses and mouse clicks; other times they come from internal events, like timers.

Modern programming languages that deal with user interaction have provided varying degrees of abstraction for signalling these events to the program and specifying responses to them. In Java, this is typically done using a the listener pattern. If you use Java you are probably already aware of how this pattern works, but to summarize: An object that produces events (such as an object representing a button in a GUI) maintains a list of listener objects that are notified when certain events take place.

The listener pattern makes some assumptions. It assumes that the listener object will be able to obtain a valid reference to an event producer so that it can register itself with the producer, and that this reference will still be valid (or a new valid reference can be obtained) if it wants to unregister itself at a later point. It assumes that the event producer will always have a valid reference to the listener. A final assumption, this time more implicit, is that the event producer and the listener are part of the same process and that it won't matter if the listener fails to unregister itself from the producer if the program stops unexpectedly because the producer will also disappear.

These assumptions fall apart when you start using OSGi. An object in one bundle may wish to be notified of an event that is produced by another bundle. For example, assume that bundle P (producer) is responsible for reporting when a button has been pressed, and bundle L (listener) is interested in knowing when the button has been pressed. Using the listener pattern, one would expect bundle P to provide a service with a method by which listeners could register themselves for notification on button presses, and bundle L would create a listener object and register it with P's service. But what if bundle L starts before bundle P? It would not be able to register itself with the service, and would either have to give up, or ask to be notified when P starts. And what if bundle L registered its listener with P's service, and then crashed without unregistering the listener? P would have an invalid reference to the listener. We could write lots of code to try to make sure that these situations were handled correctly, but there's a better way.

Enter the whiteboard pattern. Instead registering a listener object with P, L creates an object that implements the interface LI (listener interface), providing a method that should be called when the event of interest occurs. When the event occurs, P requests a list of all of the services of type LI, and then calls the action method for each of those services. The burden of maintaining the relationships between producers and listeners is shifted to the OSGi framework. The advantage to doing this is that the OSGi framework is aware of bundle lifecycles and will unregister a bundle's services when the bundle stops. As a side benefit, the event producer no longer has to maintain a list of listeners, so its code becomes simpler.

For more information on this pattern, take a look at the whitepaper Listeners Considered Harmful: The "Whiteboard" Patern (careful, it's a PDF). And for an example of the whiteboard pattern in use, take a look at the apps Whiteboard Producer Example and Whiteboard Consumer Example.

Post Comments

Add Your Comment!

Log in to leave a comment or Create an account

I got here much interesting stuff. The post is great! Thanks for sharing it!Buy Adderall online

qualitativ. "Gut, gehen wir ��ber zu Cade Calvert und haben das Abendessen . Scarlett sagte Cathleen Hause war fromCharleston . michael kors crossbody bag Vielleicht wird sie ein paar Neuigkeiten ��ber Fort Sumter , die
schnell oder deren girlsas michael kors bags h��bsch, und ich wei? verdammt gut, sie haben Michael Kors handbags outlet online store kein Whisky, Roggen Vaters ber��hren bekam . " Michael Kors clearance sale " Ashley Wilkes sagte, dass sie eine Menge michael kors handbags von Landschaft und Musik. Ashley
Unterst��tzen , discount Michael Kors purses IST Kohls Gutscheincodes 30% jetzt Kommen Markt auf michael kors bags on sale your asistance zum Geschenk SIE einen Preisvorteil von [linlei0929] 30% in ��ber Ihrem Warenkorb . Profitieren S

"Ich wei? nicht . Glauben Sie, da? wir etwas gesagt , die sie verr��ckt gemacht ? "
Christian Louboutin />" Ich bemerkte, dass , aber ich habe es nicht bezahlen keine Gedanken dann . Was glauben Sie, fehlte ihr ? Michael Kors "
Koordinator : ? This true religion jeans Rolle bei der entwicklung von true religion outlet Unterrichtsmaterialien Angebote, ?h sterben Ausbildung Michael Kors Outlet von Lehrern und Kritikern von High Heels ? Bildungsprogrammen in BEZUG Markt michael kors outlet online auf Qualit t your und Moncler Outlet Online 

new balance outlet online

h¨¹bsch, und ich wei? verdammt gut, sie haben kein Whisky,

Michael Kors Outlet Handbags

Roggen Vaters ber¨¹hren bekam . " " Ashley Wilkes sagte,

michael kors

dass sie eine Menge von Landschaft und Musik. Ashley

gucci bags

sterben Masse Kosten senken Kann unterlassen . Und VOR Allem

Michael Kors Outlet Store

Nicht KOPIEREN your TV -Star sofort nach der Show, ?h

Michael Kors Outlet

Nicht bezeichnet einen Nachahmer zu unterlassen . Kurz ges?gt, ?hm

kate spade

theslightest macht flattern und kreischen . "" Nun, man

prada outlet

kann nicht ihre Schuld . Sie haben zu schie?en Cade

Louis Vuitton Store

im Bein . "" Nun , ich wurde lickered oder

chanel outlet online

ich h?tte es nicht getan ", sagte Stuart .

Louis Vuitton Outlet

, bis wir sie aus. Alles, was sie werden wissen,




deal could be the huge backpack with kate spade outlet little lunch bag and medium pencil case set You barbour outlet store can also have different kinds of finish on either side coach bags of paper for different effects
EMT training can supply you Louis Vuitton Outlet using the capabilities you are going to should aid preserve Kate Spade Bags life, your mindset also as comprehending are just as critical michael kors outlet because your understanding also as coachingWrite for a revenue sharing coach factory store sitesThis is a kind of new concept that a lot katespade.com of sites have taken into consideration This signifies that you kate spade new york do not have to spend a lot of money in chanel bags order to experience this sort of achievement for as long Michael Kors as you use your originality and utilise your resources to Louis Vuitton Sunglasses the best of its potentials the expert's job will be barbour online into

I knewCoach Outlet Onlineall along that it would not last.Coach Factory OutletEven in April I was saying thatCoach Outletwinter would soon be here. Yet Coach Outlet Onlinesomehow it had begun to seem possibleCoach Outlet Storelately that a miracle might happen,Coach Outlet Store Onlinethat summer might drift on and onCoach Outletthrough the months -- a final Coach Factory Onlineto crown a wonderful year. TheCoach Factory Outletcelery settled that. Last nightCoach Outletwith the celery autumn came intoCoach Factory Outletits own. There is a crispness aboutCoach Outletair, the misty evenings -- but Coach Outlet Storenone of these comes home to meCoach Outlet Store Onlineso truly. There may be cool morningsCoach Outlet Onlinein July; in a year of drought the True Religion Jeansleaves may change before their time;True Religion Outletit is only with the first celeryTrue Religionthat summer celery that is of Michael Kors Outlet Onlinethe

Jimmy Choo spring/summer 2013 continued to soul-rending nature s movie idol as a creative inspiration. Jimmy Choo Heels Movie "Justine" in star Anouk Aimee, her wonderful charm and natural and not artificial image, Buy Jimmy Choo to create a blend of sports season, languid is lazy, not the wind of the craft feel of folk wind, and the traditional spring and summer series. Jimmy Choo Online Store Evening bag is to use synthetic resin and bright the cortex, transparent crystal elements, become a shining eyes focus. Christian Louboutin For Women The Jimmy Choo shoes have long been a favourite of many artists celebrities, the latest 2012 chun xia series, the designer is to add waterproof machine basic design allows you to put on it can immediately after the aura is dye-in-the-wood.

Top shoe brands Manolo Blahnik Heels for the first time to participate in the upcoming London fashion week, Manolo Blahnik Wedding Shoes 10 am local time on September 15th to a static exhibition held at 4 PM, but the address has not yet been finalized. Manolo Blahnik Swan Embellished Navy Satin Wedding Shoes Designers improve before said in an interview: "now every designer wants to be able to come to London, Christian Louboutin Outlet because here is different from milan, Paris. Now these buyers from all over the world are very value of London, London is the future. Louboutin On Sale In an interview, makes a said" was chosen to attend London fashion week, because of much more special than any milan and Paris, access to more buyers, Christian Louboutin Store believe that London is a mainstay of the fashion in the future. "

In order to show the theme of film noir, Christian Louboutin On Sale and imitate Hitchcoc female strong and full of charm of the image, the photographer Mikael Jansson will Nicole Kidman is a sexy protagonist, Shop Christian Louboutin reflected the brand has always been confident, ornate style. A new season of autumn/winter ads will be released on August the global each big media. Jimmy Choo creative director Jimmy Choo Sale Sandra Cho said: "Nicole completely caught our autumn/winter 13 series of mood and atmosphere. She describes the role of the Jimmy Choo woman various character this season, Discount Jimmy Choo strong, sexy, and there is a seductive mystery." "I am very enjoy able to deduce a strong, sexy, Jimmy Choo For Women and the role of the manipulation of the big picture. I have a good communication with the photographer, his instincts are very in place, know my thoughts and feelings, Designer Women High Heels and can be reflected through the lens it." Nicole Kidman says.

Thank you, I have recently been searching for information about this topic for ages and yours is the best I have discovered so far. dfw town limo

But, as I said earlier, we must accept that there are two sides of every aspect or a thing, one is good, and one is bad. Human being has not even spared Xanax, and used it as an intoxicating drug, rather abused it. 

car in dfw town

If you need more traffic to your website check out the website in my name. It really helped me and i think it can help your website. dfw airport car

I got here much interesting stuff. The post is great! Thanks for sharing it! online furniture store

I would like to thank you for the efforts you have made in writing this post. living room accessories

Hats off to you! The information that you have provided is very helpful. home decor accessories

As the cold wave hit, Jimmy Choo Shoes Online plenty of people have is stepping on the early autumn winter favorite ugg boots. But look around, Discount Jimmy Choo Sale almost people feet a pair of ordinary UGG is a bit boring? Don't worry, Jimmy Choo UK here recommend to you and Jimmy Choo UGG cross-border cooperation in the new tide of UGG boots, leopard tail, rivets, tassels, Jimmy Choo Women Heels qiu dong various fashion elements of disposable recommend great strength! The stars around the shoe shape rivet, add a lovely nifty in the hale and hearty. Boots mouth tasseled, match the same rivet edge, Jimmy Choo Pumps Online in the pursuit of technology at the same time increase the fashion sense of feeling, louboutin shoes sale online let a pair of ordinary UGG immediately tide Fan Er is dye-in-the-wood.

"This book is Manolo blahniks life is introduced, Manolo Blahnik Wedding Shoes Sale and The combination of a fairy tale," Morton says, "The story from a look in banana plantation in childhood until he now set up shop at Chelsea - and The Elves and The day mixed with a fairy tale. Manolo Blahnik Wedding Shoes White Fashion designers do not like too blunt, so what is better than The combination of ancient and famous fairy tale of The idea? Manolo Blahnik Hangis Jeweled Blue And in The end, also let The designer himself for his story with illustrations." Tourmaline biography with Christian Louboutin For Sale Lacroix biography pattern of fairy tales, Morton February issue of the Lacroix biography adopted fairy tale "sleeping beauty". Like Lacroix, Louboutin Shoes Online tourmaline has enjoyed during the process of illustration for his book . Jimmy Choo Pumps

Everyone should remember in "Sex and the City",Christian Louboutin Online Sale fashion actress Carrie to spike-heeled Giuseppe Zanotti heels, only to describe with crazy! Christian Louboutin Shoes Discount The famous designer brands recently released 2013 autumn and winter series, a new book or at a trend to use a lot of costly gem with bright color, Giuseppe Zanotti Pumps let the high-heeled shoes also become one of the most gorgeous phantom of the opera! Supermodel Anja Rubik to Jimmy Choo Shoes be a partner with the famous Italian fashion designer spike-heeled Giuseppe Zanotti spike-heeled Giuseppe Zanotti for Anja Rubik series shoes and handbags, a few days ago, Jimmy Choo Heels Sale two people once again to launch the series fashion advertising, photographer Paola Kudacki with a mirror . jimmy choo shop

» All comments
» Comments RSS

Powered by Community Engine