[FELIX-5204] Support using cached urls for bundle SourceCode
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1734034 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/framework/src/main/java/org/apache/felix/framework/BundleProtectionDomain.java b/framework/src/main/java/org/apache/felix/framework/BundleProtectionDomain.java
index 56fc827..ced0a47 100644
--- a/framework/src/main/java/org/apache/felix/framework/BundleProtectionDomain.java
+++ b/framework/src/main/java/org/apache/felix/framework/BundleProtectionDomain.java
@@ -46,6 +46,7 @@
import java.util.jar.JarOutputStream;
import org.apache.felix.framework.cache.Content;
import org.apache.felix.framework.cache.JarContent;
+import org.apache.felix.framework.util.FelixConstants;
import org.osgi.framework.Bundle;
import org.osgi.framework.PackagePermission;
@@ -335,6 +336,17 @@
{
RevisionAsJarURL handler = new RevisionAsJarURL(revision);
+ boolean useCachedUrlForCodeSource = Boolean.parseBoolean(
+ revision.getBundle().getFramework().getProperty(FelixConstants.USE_CACHEDURLS_PROPS));
+ if (useCachedUrlForCodeSource)
+ {
+ String location = "jar:" + revision.getEntry("/") + "!/";
+ return Felix.m_secureAction.createURL(
+ Felix.m_secureAction.createURL(null, "jar:", handler),
+ location,
+ handler
+ );
+ }
String location = revision.getBundle()._getLocation();
if (location.startsWith("reference:"))
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 83d8d95..1734b96 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
@@ -53,6 +53,7 @@
String USE_LOCALURLS_PROP = "felix.jarurls";
String NATIVE_OS_NAME_ALIAS_PREFIX = "felix.native.osname.alias";
String NATIVE_PROC_NAME_ALIAS_PREFIX = "felix.native.processor.alias";
+ String USE_CACHEDURLS_PROPS = "felix.bundlecodesource.usecachedurls";
// Missing OSGi constant for resolution directive.
String RESOLUTION_DYNAMIC = "dynamic";