Repository: karaf Updated Branches: refs/heads/karaf-3.0.x 42a081d34 -> 399ad55e7
don't wait for services for default url handler protocols Project: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/cfa88a01 Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/cfa88a01 Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/cfa88a01 Branch: refs/heads/karaf-3.0.x Commit: cfa88a01d09ab226704d5f7842fca28f8530fc05 Parents: c5bd09e Author: Phillip Balli <[email protected]> Authored: Thu Apr 3 17:24:14 2014 -0500 Committer: Phillip Balli <[email protected]> Committed: Thu Apr 3 17:24:14 2014 -0500 ---------------------------------------------------------------------- .../karaf/features/internal/BundleManager.java | 31 +++++++++++--------- 1 file changed, 17 insertions(+), 14 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/karaf/blob/cfa88a01/features/core/src/main/java/org/apache/karaf/features/internal/BundleManager.java ---------------------------------------------------------------------- diff --git a/features/core/src/main/java/org/apache/karaf/features/internal/BundleManager.java b/features/core/src/main/java/org/apache/karaf/features/internal/BundleManager.java index cd744f0..25a5884 100644 --- a/features/core/src/main/java/org/apache/karaf/features/internal/BundleManager.java +++ b/features/core/src/main/java/org/apache/karaf/features/internal/BundleManager.java @@ -67,6 +67,7 @@ public class BundleManager { private final BundleContext bundleContext; private final RegionsPersistence regionsPersistence; private final long refreshTimeout; + private List<String> defaultProtocols = Arrays.asList("http", "https", "ftp", "file", "jar"); public BundleManager(BundleContext bundleContext) { this(bundleContext, null); @@ -195,22 +196,24 @@ public class BundleManager { * @param protocol */ private void waitForUrlHandler(String protocol) { - try { - Filter filter = bundleContext.createFilter("(&(" + Constants.OBJECTCLASS + "=" + URLStreamHandlerService.class.getName() + ")(url.handler.protocol=" + protocol + "))"); - if (filter == null) { - return; - } - ServiceTracker<URLStreamHandlerService, URLStreamHandlerService> urlHandlerTracker = new ServiceTracker<URLStreamHandlerService, URLStreamHandlerService>(bundleContext, filter, null); + if (!defaultProtocols.contains(protocol)) { try { - urlHandlerTracker.open(); - urlHandlerTracker.waitForService(30000); - } catch (InterruptedException e) { - LOGGER.debug("Interrupted while waiting for URL handler for protocol {}.", protocol); - } finally { - urlHandlerTracker.close(); + Filter filter = bundleContext.createFilter("(&(" + Constants.OBJECTCLASS + "=" + URLStreamHandlerService.class.getName() + ")(url.handler.protocol=" + protocol + "))"); + if (filter == null) { + return; + } + ServiceTracker<URLStreamHandlerService, URLStreamHandlerService> urlHandlerTracker = new ServiceTracker<URLStreamHandlerService, URLStreamHandlerService>(bundleContext, filter, null); + try { + urlHandlerTracker.open(); + urlHandlerTracker.waitForService(30000); + } catch (InterruptedException e) { + LOGGER.debug("Interrupted while waiting for URL handler for protocol {}.", protocol); + } finally { + urlHandlerTracker.close(); + } + } catch (Exception ex) { + LOGGER.error("Error creating service tracker.", ex); } - } catch (Exception ex) { - LOGGER.error("Error creating service tracker.", ex); } }
