Apply patch to implement Bundle.getDataFile() and Bundle.compareTo(). (FELIX-3156)
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1183703 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 e89f727..12a1b63 100644
--- a/framework/src/main/java/org/apache/felix/framework/BundleImpl.java
+++ b/framework/src/main/java/org/apache/felix/framework/BundleImpl.java
@@ -1069,12 +1069,14 @@
public File getDataFile(String filename)
{
- throw new UnsupportedOperationException("Not supported yet.");
+ return getFramework().getDataFile(this, filename);
}
public int compareTo(Bundle t)
{
- throw new UnsupportedOperationException("Not supported yet.");
+ long thisBundleId = this.getBundleId();
+ long thatBundleId = t.getBundleId();
+ return (thisBundleId < thatBundleId ? -1 : (thisBundleId == thatBundleId ? 0 : 1));
}
public String toString()
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 3847b51..d4272ac 100644
--- a/framework/src/main/java/org/apache/felix/framework/Felix.java
+++ b/framework/src/main/java/org/apache/felix/framework/Felix.java
@@ -3434,6 +3434,14 @@
File getDataFile(BundleImpl bundle, String s)
{
+ if (bundle.getState() == Bundle.UNINSTALLED)
+ {
+ throw new IllegalStateException("Bundle has been uninstalled");
+ }
+ else if (Util.isFragment(adapt(BundleRevision.class)))
+ {
+ return null;
+ }
try
{
if (bundle == this)