From c77624a544c1aff3b821d3bd3ed11bae3c903822 Mon Sep 17 00:00:00 2001 From: Hugues Malphettes Date: Tue, 31 May 2011 02:55:46 +0000 Subject: [PATCH] fix the regressions introduced by the support for dynamically installing bundles git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@3356 7e9141cc-0065-0410-87d8-b60c137991c4 --- .../jetty/osgi/boot/OSGiAppProvider.java | 45 +++++++++++++++---- 1 file changed, 36 insertions(+), 9 deletions(-) diff --git a/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/OSGiAppProvider.java b/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/OSGiAppProvider.java index e721589fa83..0d671eaabb2 100644 --- a/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/OSGiAppProvider.java +++ b/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/OSGiAppProvider.java @@ -384,7 +384,7 @@ public class OSGiAppProvider extends ScanningAppProvider implements AppProvider */ public boolean isAutoInstallOSGiBundles() { - return getMonitoredDirResource() != null && _autoInstallOSGiBundles; + return _autoInstallOSGiBundles; } /** @@ -460,14 +460,41 @@ public class OSGiAppProvider extends ScanningAppProvider implements AppProvider { if (isAutoInstallOSGiBundles()) { - File scandir = getMonitoredDirResource().getFile(); - for (File file : scandir.listFiles()) - { - if (fileMightBeAnOSGiBundle(file)) - { - installBundle(file, false); - } - } + if (getMonitoredDirResource() == null) + { + setAutoInstallOSGiBundles(false); + Log.info("Disable autoInstallOSGiBundles as there is not contexts folder to monitor."); + } + else + { + File scandir = null; + try + { + scandir = getMonitoredDirResource().getFile(); + if (!scandir.exists() || !scandir.isDirectory()) + { + setAutoInstallOSGiBundles(false); + Log.info("Disable autoInstallOSGiBundles as the contexts folder '" + scandir.getAbsolutePath() + " does not exist."); + scandir = null; + } + } + catch (IOException ioe) + { + setAutoInstallOSGiBundles(false); + Log.info("Disable autoInstallOSGiBundles as the contexts folder '" + getMonitoredDirResource().getURI() + " does not exist."); + scandir = null; + } + if (scandir != null) + { + for (File file : scandir.listFiles()) + { + if (fileMightBeAnOSGiBundle(file)) + { + installBundle(file, false); + } + } + } + } } super.doStart(); if (isAutoInstallOSGiBundles())