Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "COSMOS SDD Tooling Examples"

(Creating SDDs)
Line 20: Line 20:
  
 
<code><pre>Artifact install = artifactFactory.createInstallArtifact();
 
<code><pre>Artifact install = artifactFactory.createInstallArtifact();
install.setContentReference("installArtifact");
+
install.setContentReference("installArtifact");</pre></code>
install.setResourceReference("artifact_Resource_Ref");</pre></code>
+
 
 +
This sets up our install artifact and sets the content reference to "installArtifact" which will map to one of the contents in the package descriptor. Next we'll add some additional content:
 +
 
 +
<code><pre>Collection<AdditionalContent> additionalContents = new ArrayList<AdditionalContent>();
 +
additionalContents.add(artifactFactory.createAdditionalContent("bom"));
 +
AdditionalContent additionalContent = artifactFactory.createAdditionalContent("readme");
 +
additionalContent.setType("readme");
 +
additionalContents.add(additionalContent);
 +
install.setAdditionalContents(additionalContents);</pre></code>
 +
 
 +
A Collection of AdditionalContent types was created and two AdditionalContent objects were created through the artifact factory. The createAdditionalContent method requires the content reference to be defined, which also must match an entry in the package descriptor. All required elements and attributes of the SDD types will be required for the factory methods as well in order to create that type. The final step was to call the appropriate setter method on the install artifact for the additional content.
 +
 
 +
Now that we have an artifact, we can create our installable unit. Remember that installable units require artifacts.
 +
 
 +
<code><pre>InstallableUnit iu = cuFactory.createInstallableUnit("IU_ID", "IU_TARGET_REF", install, ContentUnitFactory.INSTALL_ARTIFACT);</pre></code>
 +
 
 +
InstallableUnit iu = cuFactory.createInstallableUnit("IU_ID", "IU_TARGET_REF", install, ContentUnitFactory.INSTALL_ARTIFACT);</pre></code>

Revision as of 21:34, 5 October 2008

This page contains examples of how to use various functions of the SDD tooling. Please use these examples as references as you create your own applications.

SDD Programmatic Interface

The SPI is used to read and write SDDs with a Java interface. These examples will take the reader through reading, writing, and creating SDDs.

Creating SDDs

The SPI is controlled through one instance of a session. In order to use any methods in the SPI, a session must first be created.

SPISession session = SPISession.DEFAULT_INSTANCE;

The SPI objects for the most part correspond to the SDD types. These objects are created from factory objects, so let's create these first.

BaseFactory baseFactory = session.createBaseFactory();
ContentUnitFactory cuFactory = session.createContentUnitFactory();
ArtifactFactory artifactFactory = session.createArtifactFactory();

Each package of the SPI APIs have a factory class. To create an SPI object, all required elements and attributes of the SPI object must be passed into the factory method. This means we'll be creating our deployment descriptor close to the end. Let's create our install artifact first.

Artifact install = artifactFactory.createInstallArtifact();
install.setContentReference("installArtifact");

This sets up our install artifact and sets the content reference to "installArtifact" which will map to one of the contents in the package descriptor. Next we'll add some additional content:

Collection<AdditionalContent> additionalContents = new ArrayList<AdditionalContent>();
additionalContents.add(artifactFactory.createAdditionalContent("bom"));
AdditionalContent additionalContent = artifactFactory.createAdditionalContent("readme");
additionalContent.setType("readme");
additionalContents.add(additionalContent);
install.setAdditionalContents(additionalContents);

A Collection of AdditionalContent types was created and two AdditionalContent objects were created through the artifact factory. The createAdditionalContent method requires the content reference to be defined, which also must match an entry in the package descriptor. All required elements and attributes of the SDD types will be required for the factory methods as well in order to create that type. The final step was to call the appropriate setter method on the install artifact for the additional content.

Now that we have an artifact, we can create our installable unit. Remember that installable units require artifacts.

InstallableUnit iu = cuFactory.createInstallableUnit("IU_ID", "IU_TARGET_REF", install, ContentUnitFactory.INSTALL_ARTIFACT);

InstallableUnit iu = cuFactory.createInstallableUnit("IU_ID", "IU_TARGET_REF", install, ContentUnitFactory.INSTALL_ARTIFACT);</pre></code>

Back to the top