[jboss-osgi-commits] JBoss-OSGI SVN: r99448 - projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal.
jboss-osgi-commits at lists.jboss.org
jboss-osgi-commits at lists.jboss.org
Fri Jan 15 03:14:13 EST 2010
Author: thomas.diesler at jboss.com
Date: 2010-01-15 03:14:12 -0500 (Fri, 15 Jan 2010)
New Revision: 99448
Modified:
projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteBundle.java
Log:
Use dummy URLStreamHandler for 'bundle' protocol
Modified: projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteBundle.java
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteBundle.java 2010-01-15 06:11:51 UTC (rev 99447)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteBundle.java 2010-01-15 08:14:12 UTC (rev 99448)
@@ -23,8 +23,11 @@
// $Id$
+import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
+import java.net.URLConnection;
+import java.net.URLStreamHandler;
import java.util.Dictionary;
import javax.management.ObjectName;
@@ -51,34 +54,34 @@
{
// Provide logging
private final Logger log = LoggerFactory.getLogger(RemoteBundle.class);
-
+
private ManagedBundleMBean bundle;
private String location;
-
+
private long bundleId;
private String symbolicName;
private Dictionary<String, String> headers;
private Version version;
-
+
public RemoteBundle(OSGiRuntimeImpl runtime, ManagedBundleMBean bundle, BundleInfo info)
{
this(runtime, bundle);
this.location = info.getLocation();
}
-
+
public RemoteBundle(OSGiRuntimeImpl runtime, ManagedBundleMBean bundle)
{
super(runtime);
this.bundle = bundle;
-
+
// The getHeaders methods must continue to provide the manifest header
// information after the bundle enters the UNINSTALLED state.
-
+
bundleId = bundle.getBundleId();
symbolicName = bundle.getSymbolicName();
location = bundle.getLocation();
headers = bundle.getHeaders();
-
+
String versionStr = headers.get(Constants.BUNDLE_VERSION);
version = Version.parseVersion(versionStr);
}
@@ -131,14 +134,14 @@
public URL getEntry(String path)
{
assertNotUninstalled();
- return toURL(bundle.getEntry(path));
+ return toURL(bundle.getEntry(path), null);
}
@Override
public URL getResource(String name)
{
assertNotUninstalled();
- return toURL(bundle.getResource(name));
+ return toURL(bundle.getResource(name), null);
}
@Override
@@ -149,6 +152,7 @@
String bundleId = providerBundle.getKeyProperty(ManagedBundle.PROPERTY_ID);
return getRuntime().getBundle(new Long(bundleId));
}
+
@Override
public void start() throws BundleException
{
@@ -183,15 +187,32 @@
log.error("Cannot uninstall: " + getLocation(), ex);
}
}
-
- private URL toURL(String urlstr)
+
+ private URL toURL(String urlstr, URLStreamHandler sh)
{
+ if (urlstr == null)
+ return null;
+
try
{
- return urlstr != null ? new URL(urlstr) : null;
+ return sh == null ? new URL(urlstr) : new URL (null, urlstr, sh);
}
catch (MalformedURLException ex)
{
+ // In case of the 'bundle' protocol, use a dummy URLStreamHandler
+ // Access to remote content via the bundle URL is invalid anyway
+ if (sh == null && urlstr.startsWith("bundle:"))
+ {
+ sh = new URLStreamHandler()
+ {
+ @Override
+ protected URLConnection openConnection(URL url) throws IOException
+ {
+ return null;
+ }
+ };
+ return toURL(urlstr, sh);
+ }
throw new IllegalArgumentException("Invalid URL: " + urlstr);
}
}
More information about the jboss-osgi-commits
mailing list