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.