[jboss-osgi-commits] JBoss-OSGI SVN: r97901 - in projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi: util and 1 other directory.
jboss-osgi-commits at lists.jboss.org
jboss-osgi-commits at lists.jboss.org
Wed Dec 16 12:14:56 EST 2009
Author: thomas.diesler at jboss.com
Date: 2009-12-16 12:14:55 -0500 (Wed, 16 Dec 2009)
New Revision: 97901
Modified:
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/capability/Capability.java
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/BundleInfo.java
Log:
BundleException on invalid BundleInfo ctor
Modified: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/capability/Capability.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/capability/Capability.java 2009-12-16 16:18:34 UTC (rev 97900)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/capability/Capability.java 2009-12-16 17:14:55 UTC (rev 97901)
@@ -30,6 +30,7 @@
import java.util.Map;
import org.jboss.osgi.spi.util.BundleInfo;
+import org.osgi.framework.BundleException;
/**
* An abstract OSGi capability that can be installed in an {@link OSGiRuntime}.
@@ -137,7 +138,19 @@
protected void addBundle(String location)
{
- BundleInfo info = BundleInfo.createBundleInfo(location);
+ BundleInfo info;
+ try
+ {
+ info = BundleInfo.createBundleInfo(location);
+ }
+ catch (BundleException ex)
+ {
+ Throwable cause = ex.getCause();
+ if (cause instanceof RuntimeException)
+ throw (RuntimeException)cause;
+
+ throw new IllegalArgumentException("Cannot create bundle info for: " + location, ex);
+ }
getBundlesInternal().add(info);
}
Modified: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/BundleInfo.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/BundleInfo.java 2009-12-16 16:18:34 UTC (rev 97900)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/BundleInfo.java 2009-12-16 17:14:55 UTC (rev 97901)
@@ -34,6 +34,7 @@
import org.jboss.virtual.VFS;
import org.jboss.virtual.VFSUtils;
import org.jboss.virtual.VirtualFile;
+import org.osgi.framework.BundleException;
import org.osgi.framework.Constants;
import org.osgi.framework.Version;
@@ -58,7 +59,7 @@
private transient VirtualFile rootFile;
private transient Manifest manifest;
- public static BundleInfo createBundleInfo(String location)
+ public static BundleInfo createBundleInfo(String location) throws BundleException
{
if (location == null)
throw new IllegalArgumentException("Location cannot be null");
@@ -70,7 +71,7 @@
return new BundleInfo(toVirtualFile(url), url.toExternalForm());
}
- public static BundleInfo createBundleInfo(URL url)
+ public static BundleInfo createBundleInfo(URL url) throws BundleException
{
if (url == null)
throw new IllegalArgumentException("Null root url");
@@ -78,17 +79,17 @@
return new BundleInfo(toVirtualFile(url), url.toExternalForm());
}
- public static BundleInfo createBundleInfo(VirtualFile root)
+ public static BundleInfo createBundleInfo(VirtualFile root) throws BundleException
{
return new BundleInfo(root, null);
}
- public static BundleInfo createBundleInfo(VirtualFile root, String location)
+ public static BundleInfo createBundleInfo(VirtualFile root, String location) throws BundleException
{
return new BundleInfo(root, location);
}
- private BundleInfo(VirtualFile rootFile, String location)
+ private BundleInfo(VirtualFile rootFile, String location) throws BundleException
{
if (rootFile == null)
throw new IllegalArgumentException("Root file cannot be null");
@@ -101,6 +102,16 @@
location = rootURL.toExternalForm();
this.location = location;
+
+ // Initialize the manifest
+ try
+ {
+ manifest = VFSUtils.getManifest(rootFile);
+ }
+ catch (Exception ex)
+ {
+ throw new BundleException("Cannot get manifest from: " + rootURL, ex);
+ }
symbolicName = getManifestHeader(Constants.BUNDLE_SYMBOLICNAME);
if (symbolicName == null)
@@ -163,7 +174,7 @@
return Version.parseVersion(version);
}
- private Manifest getManifest()
+ private Manifest getManifest()
{
if (manifest == null)
{
@@ -173,7 +184,7 @@
}
catch (Exception ex)
{
- throw new IllegalArgumentException("Cannot get manifest from: " + rootURL, ex);
+ throw new IllegalStateException("Cannot get manifest from: " + rootURL, ex);
}
}
return manifest;
More information about the jboss-osgi-commits
mailing list