Whiteboard Pattern
Whiteboard Design Pattern is an OSGi service model, which influences the OSGi framework's service registry. Whiteboard pattern came into existence because of complicated and error prone nature of traditional model: The Listener Pattern (aka Observer Pattern).
OSGi service model is a collaboration model that supports service registry. The service registry allows applications or bundles to register services, which are simple Java interfaces implementing different functionalities. The dynamic nature of the service registry is useful for tracking services that can appear or leave at any time. Whiteboard Pattern is created to support such OSGi service model, which was not supported by Listener Pattern.
Introduction
The Listener pattern
Advantages and disadvantages: over Listener pattern
Advantages ===
* Adding new bundles is easy.
* Contributed and configured bundles can be consumed by any number of subsystems in any way. Thus, registry supports configuration management.
* Testing for bundles and their connection with each other is easy.
* Implementation and debugging is easy because it reuse the framework registry. Implementing the same service using Listener Pattern is tedious work and cannot be reused.
* It is secured. As event listeners have access controls over event source and for every status change event listeners get notified, whereas there is no access to event listeners in Listener Pattern.
Disadvantages Some usages are stated using following examples:
I) A TV Show is to be projected on LCD. Suppose a service named ‘Display’ service will project the contents that cycles over many bundles, which contains different contents. Suppose this content is provided by some ‘Providers’. An interface can be implemented by any bundles whose contents want to be displayed, where ‘Providers’ are catechized for getting the content. A ‘DisplayInstructor’ is responsible to cycle through all the screens in the service registry and display the final content at that particular point of time, which is managed by ‘TimeManager’ which implements ‘Providers’.<ref name=":1" />
This shows that the dependency between ‘DisplayInstructor’ and ‘TimeManager’ is handled. And both of them can work simultaneously or in any order at any time.
II) A group of friends uses a web based UI portal to store an article. Friends are working on article's sections. A section contains the contents which is added by some members of the group. Using whiteboard pattern, the dependencies for adding the content and displaying it on the web portal is handled. And both of these tasks can be done simultaneously or in any order at any moment.
An Example for Whiteboard Pattern Handler
Conclusion<ref name":1" /> ==
The Whiteboard pattern implementation is smaller and simpler, and thus less prone to programming errors. As per the code size, it is significant that listener pattern can have more deadlock possibilities than the whiteboard pattern.
The OSGi environment doesn't entirely follow basic programming rules with Java, rather it shows some features of its own over Java. The Listener Pattern puts such programming rules over OSGi environment, which can be considered first drawback. Apart from that, Listener Pattern doesn't suit for dynamic changes, which are expected in the OSGi environment.
The Listener pattern, a programmer of the event listener is full in-charge of the program. He decides event sources that are registered to the listener, and all the dependencies between them.
A Bundle is not an application running autonomously from other applications. It is a component running to bind with the other bundles in the environment. Bundles have to be configured and managed properly. Bundles should be written in such format that they do not show direct control, rather provide a service that can be connected and configured with other bundles. The Whiteboard pattern supports such functionality of bundles and show significant improvement over listener pattern.
These reasons are intimidating factors to apply whiteboard pattern, where managing the inter-bundle dependencies is required.
OSGi service model is a collaboration model that supports service registry. The service registry allows applications or bundles to register services, which are simple Java interfaces implementing different functionalities. The dynamic nature of the service registry is useful for tracking services that can appear or leave at any time. Whiteboard Pattern is created to support such OSGi service model, which was not supported by Listener Pattern.
Introduction
The Listener pattern
Advantages and disadvantages: over Listener pattern
Advantages ===
* Adding new bundles is easy.
* Contributed and configured bundles can be consumed by any number of subsystems in any way. Thus, registry supports configuration management.
* Testing for bundles and their connection with each other is easy.
* Implementation and debugging is easy because it reuse the framework registry. Implementing the same service using Listener Pattern is tedious work and cannot be reused.
* It is secured. As event listeners have access controls over event source and for every status change event listeners get notified, whereas there is no access to event listeners in Listener Pattern.
Disadvantages Some usages are stated using following examples:
I) A TV Show is to be projected on LCD. Suppose a service named ‘Display’ service will project the contents that cycles over many bundles, which contains different contents. Suppose this content is provided by some ‘Providers’. An interface can be implemented by any bundles whose contents want to be displayed, where ‘Providers’ are catechized for getting the content. A ‘DisplayInstructor’ is responsible to cycle through all the screens in the service registry and display the final content at that particular point of time, which is managed by ‘TimeManager’ which implements ‘Providers’.<ref name=":1" />
This shows that the dependency between ‘DisplayInstructor’ and ‘TimeManager’ is handled. And both of them can work simultaneously or in any order at any time.
II) A group of friends uses a web based UI portal to store an article. Friends are working on article's sections. A section contains the contents which is added by some members of the group. Using whiteboard pattern, the dependencies for adding the content and displaying it on the web portal is handled. And both of these tasks can be done simultaneously or in any order at any moment.
An Example for Whiteboard Pattern Handler
Conclusion<ref name":1" /> ==
The Whiteboard pattern implementation is smaller and simpler, and thus less prone to programming errors. As per the code size, it is significant that listener pattern can have more deadlock possibilities than the whiteboard pattern.
The OSGi environment doesn't entirely follow basic programming rules with Java, rather it shows some features of its own over Java. The Listener Pattern puts such programming rules over OSGi environment, which can be considered first drawback. Apart from that, Listener Pattern doesn't suit for dynamic changes, which are expected in the OSGi environment.
The Listener pattern, a programmer of the event listener is full in-charge of the program. He decides event sources that are registered to the listener, and all the dependencies between them.
A Bundle is not an application running autonomously from other applications. It is a component running to bind with the other bundles in the environment. Bundles have to be configured and managed properly. Bundles should be written in such format that they do not show direct control, rather provide a service that can be connected and configured with other bundles. The Whiteboard pattern supports such functionality of bundles and show significant improvement over listener pattern.
These reasons are intimidating factors to apply whiteboard pattern, where managing the inter-bundle dependencies is required.
Comments