You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by ma...@apache.org on 2009/08/11 16:03:52 UTC
svn commit: r803131 -
/felix/trunk/deploymentadmin/service/src/main/java/org/apache/felix/deploymentadmin/spi/DeploymentSessionImpl.java
Author: marrs
Date: Tue Aug 11 14:03:51 2009
New Revision: 803131
URL: http://svn.apache.org/viewvc?rev=803131&view=rev
Log:
FELIX-1306 implemented the patch
Modified:
felix/trunk/deploymentadmin/service/src/main/java/org/apache/felix/deploymentadmin/spi/DeploymentSessionImpl.java
Modified: felix/trunk/deploymentadmin/service/src/main/java/org/apache/felix/deploymentadmin/spi/DeploymentSessionImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/deploymentadmin/service/src/main/java/org/apache/felix/deploymentadmin/spi/DeploymentSessionImpl.java?rev=803131&r1=803130&r2=803131&view=diff
==============================================================================
--- felix/trunk/deploymentadmin/service/src/main/java/org/apache/felix/deploymentadmin/spi/DeploymentSessionImpl.java (original)
+++ felix/trunk/deploymentadmin/service/src/main/java/org/apache/felix/deploymentadmin/spi/DeploymentSessionImpl.java Tue Aug 11 14:03:51 2009
@@ -35,6 +35,9 @@
import org.osgi.service.log.LogService;
import org.osgi.service.packageadmin.PackageAdmin;
+/**
+ * Represents a running deployment session.
+ */
public class DeploymentSessionImpl implements DeploymentSession {
private final AbstractDeploymentPackage m_target;
@@ -102,23 +105,45 @@
return false;
}
+ /**
+ * Retrieve the base directory of the persistent storage area according to
+ * OSGi Core R4 6.1.6.10 for the given <code>BundleContext</code>.
+ *
+ * @param bundle of which the storage area will be returned
+ * @return a <code>File</code> that represents the base directory of the
+ * persistent storage area for the bundle
+ */
public File getDataFile(Bundle bundle) {
BundleContext context = null;
try {
+ // try to find the method in the current class
Method getBundleContext = bundle.getClass().getDeclaredMethod("getBundleContext", null);
getBundleContext.setAccessible(true);
context = (BundleContext) getBundleContext.invoke(bundle, null);
}
- catch (Exception ex) {
- // TODO: log this
+ catch (Exception e) {
+ // if we cannot find the method at first, we try again below
+ }
+ if (context == null) {
+ try {
+ // try to find the method in superclasses
+ Method getBundleContext = bundle.getClass().getMethod("getBundleContext", null);
+ getBundleContext.setAccessible(true);
+ context = (BundleContext) getBundleContext.invoke(bundle, null);
+ }
+ catch (Exception e) {
+ // we still can't find the method, we will throw an exception indicating that below
+ }
}
File result = null;
if (context != null) {
result = context.getDataFile("");
}
+ else {
+ throw new IllegalStateException("Could not retrieve valid bundle context from bundle " + bundle.getSymbolicName());
+ }
if (result == null) {
- // TODO: log this
- throw new IllegalStateException("");
+ throw new IllegalStateException("Could not retrieve base directory for bundle " + bundle.getSymbolicName());
}
return result;
}