Creating an Add-on
The following Java™ and
C# examples show how to create an AddOn object.
About this task
A new instance of an AddOn object
is created by passing the Domain object and a unique
GUID that identifies the AddOn in the domain's Global
Configuration Database (GCD). The data to be imported is set on the AddOn object
as a FileInputStream. Then, the object's properties
are set, including the Prerequisites property. The prerequisite AddOn specified
by the GUID must be installed before the installation of this new AddOn object.
Lastly, the new AddOn object is saved, which registers
it in the domain's GCD. You can retrieve a list of registered add-ons
from the Domain object.
Java Example
public void createAddon(Domain domain)
{
// Create AddOn object. Use the same Id value for the AddOn instance for all domains.
AddOn addon = Factory.AddOn.createInstance(domain,
new Id("{70f5fb79-32fb-412f-930f-ce5d40fa5c9a}") );
// Create FileInputStream for data to be imported
// and set it on the AddOn object.
File importDataset = new File("C:\\temp\\Addon_v1.xml");
// non-Windows: File importDataset = new File("/tmp/Addon_v1.xml");
FileInputStream fis = null;
try
{
fis = new FileInputStream(importDataset);
}
catch (FileNotFoundException fnfe)
{
fnfe.printStackTrace();
}
addon.setImportDataStream(fis);
// Set properties of AddOn object.
IdList preRequisiteList = Factory.IdList.createList();
preRequisiteList.add(new Id("{a3b865d4-41c4-4e9d-8e97-e9eb54e5752c}") );
addon.set_Prerequisites(preRequisiteList);
addon.set_AddOnType(AddOnType.OPTIONAL);
addon.set_DisplayName("Addon_v2");
addon.set_DescriptiveText("Installs classes and properties necessary for v2 functionality");
addon.set_Creator("CEMP Integrators");
addon.save(RefreshMode.NO_REFRESH);
}
C# Example
public void createAddon(IDomain domain)
{
IAddOn addon = Factory.AddOn.CreateInstance(domain,
new Id("{70f5fb79-32fb-412f-930f-ce5d40fa5c9a}") );
// Create Stream for data to be imported
// and set it on the IAddOn object.
Stream fileStream = File.OpenRead("C:\\temp\\Addon_v1.xml");
addon.SetImportDataStream(fileStream);
// Set properties of IAddOn object.
IIdList preRequisiteList = Factory.IdList.CreateList();
preRequisiteList.Add(new Id("{a3b865d4-41c4-4e9d-8e97-e9eb54e5752c}"));
addon.Prerequisites = preRequisiteList;
addon.AddOnType = AddOnType.OPTIONAL;
addon.DisplayName = "C#Addon_v2";
addon.DescriptiveText = "Installs classes and properties necessary for v2 functionality");
addon.Creator = "CEMP Integrators";
addon.Save(RefreshMode.NO_REFRESH);
}