From bcef9830deda748451fe06ec41c2896268f5c359 Mon Sep 17 00:00:00 2001 From: Musachy Barroso Date: Thu, 23 Apr 2009 20:48:57 +0000 Subject: [PATCH] fix runlevels loading git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/trunk@768048 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/struts2/osgi/FelixOsgiHost.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/plugins/osgi/src/main/java/org/apache/struts2/osgi/FelixOsgiHost.java b/plugins/osgi/src/main/java/org/apache/struts2/osgi/FelixOsgiHost.java index 42bff11de..6de0f0068 100644 --- a/plugins/osgi/src/main/java/org/apache/struts2/osgi/FelixOsgiHost.java +++ b/plugins/osgi/src/main/java/org/apache/struts2/osgi/FelixOsgiHost.java @@ -152,17 +152,17 @@ public class FelixOsgiHost implements OsgiHost { configProps.put(AutoActivator.AUTO_START_PROP + ".1", StringUtils.join(bundleJarsLevel1, " ")); //get a list of directories under /bundles with numeric names (the runlevel) - List runLevels = getRunLevelDirs("bundles"); + Map runLevels = getRunLevelDirs("bundles"); if (runLevels.isEmpty()) { //there are no run level dirs, search for bundles in that dir List bundles = getBundlesInDir("bundles"); if (!bundles.isEmpty()) configProps.put(AutoActivator.AUTO_START_PROP + ".2", StringUtils.join(bundles, " ")); } else { - for (String runLevel : runLevels) { + for (String runLevel : runLevels.keySet()) { if ("1".endsWith(runLevel)) throw new StrutsException("Run level dirs must be greater than 1. Run level 1 is reserved for the Felix bundles"); - List bundles = getBundlesInDir(runLevel); + List bundles = getBundlesInDir(runLevels.get(runLevel)); configProps.put(AutoActivator.AUTO_START_PROP + "." + runLevel, StringUtils.join(bundles, " ")); } } @@ -171,8 +171,8 @@ public class FelixOsgiHost implements OsgiHost { /** * Return a list of directories under a directory whose name is a number */ - protected List getRunLevelDirs(String dir) { - List dirs = new ArrayList(); + protected Map getRunLevelDirs(String dir) { + Map dirs = new HashMap(); try { ResourceFinder finder = new ResourceFinder(); URL url = finder.find("bundles"); @@ -193,7 +193,7 @@ public class FelixOsgiHost implements OsgiHost { if (runLevelDirs != null && runLevelDirs.length > 0) { //add all the dirs to the list for (String runLevel : runLevelDirs) - dirs.add(StringUtils.chomp(dir, "/") + "/" + runLevel); + dirs.put(runLevel, StringUtils.chomp(dir, "/") + "/" + runLevel); } else if (LOG.isDebugEnabled()) { LOG.debug("No bundles found under the [#0] directory", dir);