The Spotfire Community is moving to TIBCOmmunity and this forum location has closed. During the transition, you can still search the old forums but posting has been disabled. We encourage you to pick up the discussion at the new Spotfire community on TIBCOmmunity.
Extending Extensions: Revisited - Knowledge Base

TIBCO Spotfire Community

Welcome to TIBCO Spotfire Community Sign in | Join | Help

Extending Extensions: Revisited

This article targets: TIBCO Spotfire 2.2 and forward

 

In a previous article I described how to create an extendible framework in Spotfire. A problem with the approach described in that article was the fact that the Spotfire add-in framework did not provide any mechanism for getting a callback when global services from all registered add-ins had been registered. This forced the developer to use an ApplicationEventHandler to achieve the same result.

As of Spotfire 2.2, the AddIn base class provided three virtual (í.e. overridable) methods that you can use to get callbacks when all services of a particular level (global, user, analysis) have been registered. The following snippet shows how to solve the problem in the aforementioned article using this new mechanism:

public abstract class ExtendableAddIn : AddIn
{
    /// <summary>
    /// When the application instance is created we can be sure that the global services
    /// all have been registered, including our own registry. So it is safe to call
    /// all sub classes of ExtendableAddIn and allow them to register their extensions.
    /// </summary>
    protected override void OnGlobalServicesRegistered(ServiceProvider provider)
    {
        ExtensionRegistry registry = (ExtensionRegistry) provider.GetService(typeof(ExtensionRegistry));
        this.RegisterExtension(new ExtensionRegistrar(registry);
    }
    …
}

 

This approach not only saves you a few lines of code, it also provides a much cleaner way of solving the problem at hand.

Published Nov 30 2008, 05:45 PM by Ehsan Yazdani
Filed under: , ,
Rating:
Comments

About Ehsan Yazdani

Ehsan Yazdani is a developer with the TIBCO Spotfire and the TIBCO Spotfire Analytics Server Framework teams. His fields of expertise are network communication, web services, and framework extensibility.