Added a configuration property to determine whether installing a fragment
that uses unimplemented features throws an exception or logs a warnging.
(FELIX-725)


git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@694804 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/framework/src/main/java/org/apache/felix/framework/util/FelixConstants.java b/framework/src/main/java/org/apache/felix/framework/util/FelixConstants.java
index 3c9861a..5e86ac7 100644
--- a/framework/src/main/java/org/apache/felix/framework/util/FelixConstants.java
+++ b/framework/src/main/java/org/apache/felix/framework/util/FelixConstants.java
@@ -51,6 +51,11 @@
         = "felix.startlevel.bundle";
     public static final String SERVICE_URLHANDLERS_PROP = "felix.service.urlhandlers";
 
+    // THESE CAN BE DELETED ONCE WE HAVE COMPLETE FRAGMENT SUPPORT.
+    public static final String FRAGMENT_VALIDATION_PROP = "felix.fragment.validation";
+    public static final String FRAGMENT_VALIDATION_EXCEPTION_VALUE = "exception";
+    public static final String FRAGMENT_VALIDATION_WARNING_VALUE = "warning";
+
     // Start level-related constants.
     public static final int FRAMEWORK_INACTIVE_STARTLEVEL = 0;
     public static final int FRAMEWORK_DEFAULT_STARTLEVEL = 1;
diff --git a/framework/src/main/java/org/apache/felix/framework/util/manifestparser/ManifestParser.java b/framework/src/main/java/org/apache/felix/framework/util/manifestparser/ManifestParser.java
index 3c6425d..da4d30a 100644
--- a/framework/src/main/java/org/apache/felix/framework/util/manifestparser/ManifestParser.java
+++ b/framework/src/main/java/org/apache/felix/framework/util/manifestparser/ManifestParser.java
@@ -255,8 +255,18 @@
                 || (headerMap.get(Constants.EXPORT_PACKAGE) != null)
                 || (headerMap.get(Constants.BUNDLE_NATIVECODE) != null))
             {
-                throw new BundleException(
-                    "Fragments with exports, imports, or native code are not currently supported.");
+                String s = (String) m_configMap.get(FelixConstants.FRAGMENT_VALIDATION_PROP);
+                s = (s == null) ? FelixConstants.FRAGMENT_VALIDATION_EXCEPTION_VALUE : s;
+                if (s.equalsIgnoreCase(FelixConstants.FRAGMENT_VALIDATION_WARNING_VALUE))
+                {
+                    m_logger.log(Logger.LOG_WARNING,
+                        "Fragments with exports, imports, or native code are not currently supported.");
+                }
+                else
+                {
+                    throw new BundleException(
+                        "Fragments with exports, imports, or native code are not currently supported.");
+                }
             }
         }
     }
diff --git a/main/src/main/resources/config.properties b/main/src/main/resources/config.properties
index 6d9ba78..3958c58 100644
--- a/main/src/main/resources/config.properties
+++ b/main/src/main/resources/config.properties
@@ -34,6 +34,13 @@
 felix.log.level=4
 felix.startlevel.framework=1
 felix.startlevel.bundle=1
+
+# Invalid fragment bundles throw an 'exception' by default, but
+# uncomment the follow line to have them log a 'warning' instead.
+#felix.fragment.validation=warning
+
+# Felix installs a stream and content handler factories by default,
+# uncomment the following line to not install them.
 #felix.service.urlhandlers=false
 
 #