You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by pi...@apache.org on 2012/11/09 11:35:02 UTC
svn commit: r1407415 - in
/karaf/trunk/features/core/src/main/java/org/apache/karaf/features/internal:
FeaturesServiceImpl.java InstallationState.java
Author: pieber
Date: Fri Nov 9 10:35:02 2012
New Revision: 1407415
URL: http://svn.apache.org/viewvc?rev=1407415&view=rev
Log:
[KARAF-2007,KARAF-2008] Fix feature/bundle start-lvl quircks. Thanks to Christoph Gritschenberger for this patch!
Signed-off-by: Andreas Pieber <an...@gmail.com>
Modified:
karaf/trunk/features/core/src/main/java/org/apache/karaf/features/internal/FeaturesServiceImpl.java
karaf/trunk/features/core/src/main/java/org/apache/karaf/features/internal/InstallationState.java
Modified: karaf/trunk/features/core/src/main/java/org/apache/karaf/features/internal/FeaturesServiceImpl.java
URL: http://svn.apache.org/viewvc/karaf/trunk/features/core/src/main/java/org/apache/karaf/features/internal/FeaturesServiceImpl.java?rev=1407415&r1=1407414&r2=1407415&view=diff
==============================================================================
--- karaf/trunk/features/core/src/main/java/org/apache/karaf/features/internal/FeaturesServiceImpl.java (original)
+++ karaf/trunk/features/core/src/main/java/org/apache/karaf/features/internal/FeaturesServiceImpl.java Fri Nov 9 10:35:02 2012
@@ -77,6 +77,9 @@ import static java.lang.String.format;
public class FeaturesServiceImpl implements FeaturesService {
private static final Logger LOGGER = LoggerFactory.getLogger(FeaturesServiceImpl.class);
+ private static final int KARAF_BUNDLE_START_LEVEL =
+ Integer.parseInt(System.getProperty("karaf.startlevel.bundle", "80"));
+
private final BundleManager bundleManager;
private final FeatureConfigInstaller configManager;
@@ -379,6 +382,7 @@ public class FeaturesServiceImpl impleme
state.bundles.addAll(s.bundles);
state.features.putAll(s.features);
state.installed.addAll(s.installed);
+ state.bundleStartLevels.putAll(s.bundleStartLevels);
//Check if current feature satisfies the conditionals of existing features
for (Feature installedFeature : listInstalledFeatures()) {
@@ -392,6 +396,7 @@ public class FeaturesServiceImpl impleme
state.bundles.addAll(s.bundles);
state.features.putAll(s.features);
state.installed.addAll(s.installed);
+ state.bundleStartLevels.putAll(s.bundleStartLevels);
} catch (Exception e) {
failure.bundles.addAll(s.bundles);
failure.features.putAll(s.features);
@@ -410,8 +415,7 @@ public class FeaturesServiceImpl impleme
Collections.sort(bundlesSortedByStartLvl, new Comparator<Bundle>() {
@Override
public int compare(Bundle bundle, Bundle bundle1) {
- return state.bundleInfos.get(bundle.getBundleId()).getStartLevel() -
- state.bundleInfos.get(bundle1.getBundleId()).getStartLevel();
+ return state.bundleStartLevels.get(bundle) - state.bundleStartLevels.get(bundle1);
}
});
}
@@ -514,6 +518,7 @@ public class FeaturesServiceImpl impleme
int startLevel = getBundleStartLevel(bInfo.getStartLevel(),feature.getStartLevel());
BundleInstallerResult result = bundleManager.installBundleIfNeeded(bInfo.getLocation(), startLevel, feature.getRegion());
state.bundles.add(result.bundle);
+ state.bundleStartLevels.put(result.bundle, getBundleStartLevelForOrdering(startLevel));
if (result.isNew) {
state.installed.add(result.bundle);
}
@@ -534,6 +539,10 @@ public class FeaturesServiceImpl impleme
return (bundleStartLevel > 0) ? bundleStartLevel : featureStartLevel;
}
+ private int getBundleStartLevelForOrdering(int startLevel){
+ return startLevel == 0 ? KARAF_BUNDLE_START_LEVEL : startLevel;
+ }
+
protected void doInstallFeatureConditionals(InstallationState state, Feature feature, boolean verbose) throws Exception {
//Check conditions of the current feature.
for (Conditional conditional : feature.getConditional()) {
@@ -545,6 +554,7 @@ public class FeaturesServiceImpl impleme
state.bundles.addAll(s.bundles);
state.features.putAll(s.features);
state.installed.addAll(s.installed);
+ state.bundleStartLevels.putAll(s.bundleStartLevels);
}
}
}
Modified: karaf/trunk/features/core/src/main/java/org/apache/karaf/features/internal/InstallationState.java
URL: http://svn.apache.org/viewvc/karaf/trunk/features/core/src/main/java/org/apache/karaf/features/internal/InstallationState.java?rev=1407415&r1=1407414&r2=1407415&view=diff
==============================================================================
--- karaf/trunk/features/core/src/main/java/org/apache/karaf/features/internal/InstallationState.java (original)
+++ karaf/trunk/features/core/src/main/java/org/apache/karaf/features/internal/InstallationState.java Fri Nov 9 10:35:02 2012
@@ -30,5 +30,6 @@ public class InstallationState {
final Set<Bundle> installed = new HashSet<Bundle>();
final Set<Bundle> bundles = new TreeSet<Bundle>();
final Map<Long, BundleInfo> bundleInfos = new HashMap<Long, BundleInfo>();
+ final Map<Bundle,Integer> bundleStartLevels = new HashMap<Bundle, Integer>();
final Map<Feature, Set<Long>> features = new HashMap<Feature, Set<Long>>();
}
\ No newline at end of file