You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by cz...@apache.org on 2017/06/07 09:26:35 UTC
svn commit: r1797901 - in /sling/whiteboard/cziegeler/feature-support:
pom.xml src/main/java/org/apache/sling/feature/support/ConfigurationUtil.java
Author: cziegeler
Date: Wed Jun 7 09:26:35 2017
New Revision: 1797901
URL: http://svn.apache.org/viewvc?rev=1797901&view=rev
Log:
Support custom manifest entries
Modified:
sling/whiteboard/cziegeler/feature-support/pom.xml
sling/whiteboard/cziegeler/feature-support/src/main/java/org/apache/sling/feature/support/ConfigurationUtil.java
Modified: sling/whiteboard/cziegeler/feature-support/pom.xml
URL: http://svn.apache.org/viewvc/sling/whiteboard/cziegeler/feature-support/pom.xml?rev=1797901&r1=1797900&r2=1797901&view=diff
==============================================================================
--- sling/whiteboard/cziegeler/feature-support/pom.xml (original)
+++ sling/whiteboard/cziegeler/feature-support/pom.xml Wed Jun 7 09:26:35 2017
@@ -40,6 +40,10 @@
<dependencies>
<dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>osgi.core</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.feature</artifactId>
<version>0.0.1-SNAPSHOT</version>
Modified: sling/whiteboard/cziegeler/feature-support/src/main/java/org/apache/sling/feature/support/ConfigurationUtil.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/cziegeler/feature-support/src/main/java/org/apache/sling/feature/support/ConfigurationUtil.java?rev=1797901&r1=1797900&r2=1797901&view=diff
==============================================================================
--- sling/whiteboard/cziegeler/feature-support/src/main/java/org/apache/sling/feature/support/ConfigurationUtil.java (original)
+++ sling/whiteboard/cziegeler/feature-support/src/main/java/org/apache/sling/feature/support/ConfigurationUtil.java Wed Jun 7 09:26:35 2017
@@ -21,16 +21,24 @@ import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.util.List;
+import java.util.Map;
import java.util.jar.JarOutputStream;
import java.util.jar.Manifest;
import java.util.zip.ZipEntry;
import org.apache.sling.feature.Configuration;
import org.apache.sling.feature.json.ConfigurationJSONWriter;
+import org.osgi.framework.Constants;
public class ConfigurationUtil {
+ public static final String REQUIRE_CONFIGURATOR_CAPABILITY =
+ "osgi.implementation;filter:=\"(&(osgi.implementation=osgi.configurator)(version>=1.0)(!(version>=2.0)))\"";
+
+ public static final String REQUIRE_REPOINIT_CAPABILITY =
+ "osgi.implementation;filter:=\"(&(osgi.implementation=org.apache.sling.jcr.repoinit)(version>=1.0)(!(version>=2.0)))\"";
+
/**
* Create a bundle containing the configurations to be processed the
* OSGi configurator
@@ -39,22 +47,34 @@ public class ConfigurationUtil {
* @param configurations The list of configurations
* @param symbolicName The symbolic name for the generated bundle
* @param version The version for the generated bundle
+ * @param additionalAttributes Optional additional attributes for the Manifest.
* @throws IOException If something goes wrong
*/
public static void createConfiguratorBundle(final OutputStream os,
final List<Configuration> configurations,
final String symbolicName,
- final String version) throws IOException {
+ final String version,
+ final Map<String, String> additionalAttributes)
+ throws IOException {
final Manifest mf = new Manifest();
mf.getMainAttributes().putValue("Manifest-Version", "1.0");
- mf.getMainAttributes().putValue("Bundle-ManifestVersion", "2");
- mf.getMainAttributes().putValue("Bundle-SymbolicName", symbolicName);
- mf.getMainAttributes().putValue("Bundle-Version", version);
- mf.getMainAttributes().putValue("Bundle-Vendor", "The Apache Software Foundation");
- // Require configurator
- mf.getMainAttributes().putValue("Require-Capability", "osgi.implementation;filter:=\"(&(osgi.implementation=osgi.configurator)(version>=1.0)(!(version>=2.0)))\"");
- // TODO additional attributes
+ mf.getMainAttributes().putValue(Constants.BUNDLE_MANIFESTVERSION, "2");
+ mf.getMainAttributes().putValue(Constants.BUNDLE_SYMBOLICNAME, symbolicName);
+ mf.getMainAttributes().putValue(Constants.BUNDLE_VERSION, version);
+ mf.getMainAttributes().putValue(Constants.BUNDLE_VENDOR, "The Apache Software Foundation");
+ mf.getMainAttributes().putValue(Constants.REQUIRE_CAPABILITY, REQUIRE_CONFIGURATOR_CAPABILITY);
+
+ if ( additionalAttributes != null ) {
+ for(final Map.Entry<String, String> entry : additionalAttributes.entrySet()) {
+ if ( Constants.REQUIRE_CAPABILITY.equals(entry.getKey())
+ && !entry.getValue().contains("osgi.implementation=osgi.configurator")) {
+ mf.getMainAttributes().putValue(entry.getKey(), entry.getValue() + "," + REQUIRE_CONFIGURATOR_CAPABILITY);
+ } else {
+ mf.getMainAttributes().putValue(entry.getKey(), entry.getValue());
+ }
+ }
+ }
final JarOutputStream jos = new JarOutputStream(os, mf);