Everyone will know the concept of WCBs by now, which was introduced in WebManager 9. WCBs are sofware components which can be deployed onto running WebManager installations without the need for a server restart. That makes a WCB sound pretty much like an “extension” to the WebManager platform. And it is.
However, WCBs should not be mistaken with WebManager 9 “extensions”. Extensions are really something else, and it is time that we pay a little bit more attention to them. They really do deserve it...
What is an extension?
Well, basically an extension is a small software component that cannot run on its own but modifies or enhances the application it extends. Examples are the spelling checker add-ons for OpenOffice, the Lightning calendar add-on for the e-mail program Thunderbird and the FireFox theme add-ons.
From those examples, WCBs seem to be “extensions”, and they are. WCBs are extensions to the WebManager application. However, a WebManager extension extends a WCB instead. So in case a WCB is extensible (like the WebManager platform itself) one could speak of an “extensible extension”. Isn't that neat?
But back to the question. A WebManager extension basically consists of three parts:
In fact an OSGi service does exactly that; it consists of an interface and a class that implements that interface. Susequently, everyone is free to use the service, depending only on the interface. In many cases these OSGi services are implemented one-on-one; one interface and one implementation. But there is nothing that stops you from implementing the same service interface many times. And if you do, that is what an extension is basically about.
Examples
So you might wonder if the concept of exentions is used in the WebManager platform. Well, here are some examples:
The Online Help WCB is implemented using extensions. You can add Online Help to that WCB by providing a service that implements OnlineHelpProvider. The OnlineHelpProvider is the extension interface (or extension point) and your WCB containing the Online Help is the extension provider; it provides one piece of the Online Help.
The concept of extensions facilitates the complete decoupling of the eShop and Books example. The only thing that connects the two is again an extension interface, so you could easily implement your own product database and use it together with the eShop.
As of WebManager 9.5 the new “Performance Dashboard” is available. This dashboard provides all kind of measurements to indicate the health of the WebManager application. But now it comes; these indicators are implemented as extensions! So what stops you from providing your own indicators and extend this panel?
System health indicators
So lets go into more detail on that
last example; the performance dashboard. Adding your own indicators
to this dashboard is fairly simple; just provide a service in your
WCB that implements the extension point “SystemHealthIndicator”
(see http://www.gxdeveloperweb.com/documentation/javadoc/nl/gx/webmanager/services/systemhealth/SystemHealthIndicator.html ).
If you do not exactly know how; just copy the code you already
implemented for the Online help provider component. The following
implementation of a system health indicator indicates if the GX
WebManager search engine is up and running or not.
public class SearchEngineRunningIndicator implements SystemHealthIndicator {
public String getId() {return "searchengine_running";};
public String getCategory() {return "GX WebManager Search Engine";}
public String getType() {return SystemHealthIndicator.TYPE_CUSTOM;};
public String getMessage(Locale locale) {return "Indicates if ...";}
public String getName(Locale locale) {return "Search Engine status";}
public void reset() {}
public Object getValue() {
if (GeorgeLibrary.georgeIsAvailable()) {
return new String("up and running");
}
else return new String("down");
}
public ValueStatus getValueState() {
if (GeorgeLibrary.georgeIsAvailable()) {
return ValueStatus.GREEN;
}
else return ValueStatus.RED;
}
}
The result is immediatel visible in the Performance dashboard when you deploy a WCB containing the extension. An additional tab called “Custom system performance indicators” is added, as displayed below:
As you can see, the WebManager Search Engine is apparently not running on my WebManager installation.
Detecting extensible WCBs
So how do you know that a WCB is extensible and what extension interface it provides? The WCB management console indicates if a WCB is extensible and if so, what extension points it exposes. Take a look at the Books example which is extensible:
The little '+' icon overlay in the puzzle piece icon indicates that the WCB is extensible. In the “Extension points” part the extension points are summarized.
Conclusion
In my opinion, the WebManager extension mechanism is a very powerfull concept and should be used much much more. I doubt that it is very 'known' feature though. Hopefull this blog contributes to its awareness. Spread the word!
Ivo Ladage is product architect and is part of one of the SCRUM-teams. Ivo has special interests in Workflow and Authorization processes and Spring MVC.
Other blog entries: