adapt(BundleRevision) should return null for uninstalled bundles, but
we still need a way internally to get the current revision for uninstalled
bundles, so we'll use adapt(BundleRevisionImpl) for that. (FELIX-2950)
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1143440 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/framework/src/main/java/org/apache/felix/framework/BundleImpl.java b/framework/src/main/java/org/apache/felix/framework/BundleImpl.java
index 701a986..58e122f 100644
--- a/framework/src/main/java/org/apache/felix/framework/BundleImpl.java
+++ b/framework/src/main/java/org/apache/felix/framework/BundleImpl.java
@@ -164,7 +164,7 @@
else
{
// Get current revision, since we can reuse it.
- BundleRevisionImpl current = (BundleRevisionImpl) adapt(BundleRevision.class);
+ BundleRevisionImpl current = (BundleRevisionImpl) adapt(BundleRevisionImpl.class);
// Close all existing revisions.
closeRevisions();
// Clear all revisions.
@@ -299,7 +299,7 @@
}
return getFramework().findBundleEntries(
- adapt(BundleRevision.class), path, filePattern, recurse);
+ adapt(BundleRevisionImpl.class), path, filePattern, recurse);
}
public Dictionary getHeaders()
@@ -332,8 +332,7 @@
// Spec says empty local returns raw headers.
if (locale.length() == 0)
{
- result = new StringMap(
- ((BundleRevisionImpl) adapt(BundleRevision.class)).getHeaders(), false);
+ result = new StringMap(adapt(BundleRevisionImpl.class).getHeaders(), false);
}
// If we have no result, try to get it from the cached headers.
@@ -369,8 +368,7 @@
if (result == null)
{
// Get a modifiable copy of the raw headers.
- Map headers = new StringMap(
- ((BundleRevisionImpl) adapt(BundleRevision.class)).getHeaders(), false);
+ Map headers = new StringMap(adapt(BundleRevisionImpl.class).getHeaders(), false);
// Assume for now that this will be the result.
result = headers;
@@ -402,7 +400,7 @@
// Create ordered list of revisions to search for localization
// property resources.
List<BundleRevision> revisionList = createLocalizationRevisionList(
- (BundleRevisionImpl) adapt(BundleRevision.class));
+ adapt(BundleRevisionImpl.class));
// Create ordered list of files to load properties from
List<String> resourceList = createLocalizationResourceList(basename, locale);
@@ -884,12 +882,12 @@
public String getSymbolicName()
{
- return adapt(BundleRevision.class).getSymbolicName();
+ return adapt(BundleRevisionImpl.class).getSymbolicName();
}
public Version getVersion()
{
- return adapt(BundleRevision.class).getVersion();
+ return adapt(BundleRevisionImpl.class).getVersion();
}
public boolean hasPermission(Object obj)
@@ -1029,6 +1027,13 @@
}
return (A) m_revisions.get(0);
}
+ // We need some way to get the current revision even if
+ // the associated bundle is uninstalled, so we use the
+ // impl revision class for this purpose.
+ else if (type == BundleRevisionImpl.class)
+ {
+ return (A) m_revisions.get(0);
+ }
else if (type == BundleRevisions.class)
{
return (A) this;
@@ -1052,7 +1057,7 @@
public String toString()
{
- String sym = adapt(BundleRevision.class).getSymbolicName();
+ String sym = getSymbolicName();
if (sym != null)
{
return sym + " [" + getBundleId() +"]";
@@ -1191,9 +1196,11 @@
if (id != getBundleId())
{
String sym = bundles[i].getSymbolicName();
- Version ver = ((BundleRevisionImpl)
- bundles[i].adapt(BundleRevision.class)).getVersion();
- if ((symName != null) && (sym != null) && symName.equals(sym) && bundleVersion.equals(ver))
+ Version ver = bundles[i].getVersion();
+ if ((symName != null)
+ && (sym != null)
+ && symName.equals(sym)
+ && bundleVersion.equals(ver))
{
throw new BundleException(
"Bundle symbolic name and version are not unique: "