Checking for Superseded Add-ons

An application can determine whether an add-on has been superseded by a newer version in the domain, and, if so, whether the newer version has been installed in the object store.

About this task

The Factory.AddOn.fetchSupersedingInstance method allows an application to check for a superseding add-on based on the add-on ID that is passed to the method. If a superseding add-on does not exist in the domain, then the method returns the add-on that is specified in the call. If the superseding add-on exists, then the method returns the superseding add-on (which has a different ID than the one specified in the method call).

The ObjectStore.isAddOnInstalled method tells an application if a specified add-on is installed in the object store. This method takes the ID of an add-on. To determine whether an updated version of an add-on is installed, an application passes the ID of the superseded add-on to the method. The method returns false in cases where an add-on has not been installed to the object store.

The following Java™ and C# examples use the ObjectStore.isAddOnInstalled method. If the specified add-on has not been installed to the object store, the code installs it.

Java Example


void installOn(Domain domain, AddOn addOn)
{
        if ( objectStore.isAddOnInstalled(addOn.get_Id()) == false )
        {              
            System.out.println("+++ Installing " + 
               addOn.get_DisplayName() + " into object store " + 
               objectStore.get_DisplayName() + " ...");
            objectStore.installAddOn(addOn);
            objectStore.save(RefreshMode.REFRESH);
        }
        else
        {
            System.out.println("--- " + addOn.get_DisplayName() + " already installed in object store " + 
               objectStore.get_DisplayName() + ".");
        }
}

C# Example


void installOn(IDomain domain, IAddOn addOn)
{
        if ( objectStore.IsAddOnInstalled(addOn.Id) == False )
        {              
            System.Console.WriteLine("+++ Installing " + 
               addOn.DisplayName + " into object store " + 
               objectStore.DisplayName + " ...");
            objectStore.InstallAddOn(addOn);
            objectStore.Save(RefreshMode.REFRESH);
        }
        else
        {
            System.Console.WriteLine("--- " + addOn.DisplayName + " already installed in object store " + 
               objectStore.DisplayName + ".");
        }
}