Throw an exception when installing a fragment that uses features that we
do not support.
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@690277 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/framework/src/main/java/org/apache/felix/framework/Felix.java b/framework/src/main/java/org/apache/felix/framework/Felix.java
index ba0caf3..a6c6c25 100644
--- a/framework/src/main/java/org/apache/felix/framework/Felix.java
+++ b/framework/src/main/java/org/apache/felix/framework/Felix.java
@@ -2336,8 +2336,6 @@
verifyExecutionEnvironment(bundle);
- checkFragment(bundle);
-
addSecurity(bundle);
if (!bundle.getInfo().isExtension())
@@ -2472,21 +2470,6 @@
}
/**
- * Checks whether bundle is a fragment bundle, and if so, logs a warning as fragment bundles
- * are not yet supported by Felix.
- * @param bundle The bundle to verify
- **/
- private void checkFragment(FelixBundle bundle)
- {
- String fragmentHost = (String) bundle.getInfo().getCurrentHeader().get(Constants.FRAGMENT_HOST);
- if (fragmentHost != null)
- {
- m_logger.log(Logger.LOG_WARNING, "Bundle " + bundle.getBundleId()
- + " is a fragment bundle; fragment are only partially supported!");
- }
- }
-
- /**
* Check the required bundle execution environment against the framework provided
* exectution environment.
* @param bundleEnvironment The required execution environment string
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 cceeae4..3c6425d 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
@@ -97,6 +97,7 @@
(String) headerMap.get(Constants.FRAGMENT_HOST));
if (clauses.length > 0)
{
+ validateFragment(headerMap);
try
{
reqList.add(
@@ -239,6 +240,27 @@
}
}
+ /**
+ * Checks whether a fragment uses features that we do not currently support
+ * (e.g., Import-Package, Export-Package, and Bundle-NativeCode). If so, we
+ * throw an exception.
+ * @param headerMap the header to validate.
+ **/
+ private void validateFragment(Map headerMap) throws BundleException
+ {
+ String fragmentHost = (String) headerMap.get(Constants.FRAGMENT_HOST);
+ if (fragmentHost != null)
+ {
+ if ((headerMap.get(Constants.IMPORT_PACKAGE) != null)
+ || (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.");
+ }
+ }
+ }
+
public String getManifestVersion()
{
String manifestVersion = (String) m_headerMap.get(Constants.BUNDLE_MANIFESTVERSION);