Additional Sample Code
@@ -333,7 +333,7 @@ Feature f = builder.build();</programlisting>
<para>
The following example shows a simple Feature describing a small application with its dependencies:
<programlisting>{
- "id": "org.acme:acmeapp:1.0.0",
+ "id": "org.acme:acmeapp:1.0.1",
"name": "The Acme Application",
"license": "https://opensource.org/licenses/Apache-2.0",
@@ -374,6 +374,42 @@ Feature f = builder.build();</programlisting>
Bundle metadata supports String keys and String values.
</para>
</section>
+
+ <section>
+ <title>Using the Feature API</title>
+ <para>
+ A Feature with Bundles can be created using the Feature API as follows:
+ </para>
+ <programlisting>BuilderFactory factory = // ... from Service Registry ...
+
+FeatureBuilder builder = factory.newFeatureBuilder(
+ new ID("org.acme", "acmeapp", "1.0.1"));
+builder.setName("The Acme Application");
+builder.setLicense("https://opensource.org/licenses/Apache-2.0");
+builder.setComplete(true);
+
+FeatureBundle b1 = factory.newBundleBuilder(
+ ID.fromMavenID("org.osgi:org.osgi.util.function:1.1.0"))
+ .build();
+
+FeatureBundle b2 = factory.newBundleBuilder(
+ ID.fromMavenID("org.osgi:org.osgi.util.promise:1.1.1"))
+ .build();
+
+FeatureBundle b3 = factory.newBundleBuilder(
+ ID.fromMavenID("org.apache.commons:commons-email:1.1.5"))
+ .addMetadata("org.acme.javadoc.link",
+ "https://commons.apache.org/proper/commons-email/javadocs/api-1.5")
+ .build();
+
+FeatureBundle b4 = factory.newBundleBuilder(
+ ID.fromMavenID("com.acme:acmelib:1.7.2"))
+ .build();
+
+builder.addBundles(b1, b2, b3, b4);
+
+Feature f = builder.build();</programlisting>
+ </section>
</section>
<section>
