You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by cm...@apache.org on 2010/07/16 15:16:51 UTC

svn commit: r964793 - /karaf/trunk/features/core/src/main/java/org/apache/karaf/features/internal/FeaturesServiceImpl.java

Author: cmoulliard
Date: Fri Jul 16 13:16:51 2010
New Revision: 964793

URL: http://svn.apache.org/viewvc?rev=964793&view=rev
Log:
Adapt the code to allow to stop or start a bundle when this one is deployed through feature mechanism --> <bundle start='false'>

Modified:
    karaf/trunk/features/core/src/main/java/org/apache/karaf/features/internal/FeaturesServiceImpl.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=964793&r1=964792&r2=964793&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 Jul 16 13:16:51 2010
@@ -244,6 +244,7 @@ public class FeaturesServiceImpl impleme
                 InstallationState s = new InstallationState();
             	try {
                     doInstallFeature(s, f);
+                    state.bundleInfos.putAll(s.bundleInfos);
                     state.bundles.addAll(s.bundles);
                     state.features.putAll(s.features);
                     state.installed.addAll(s.installed);
@@ -295,18 +296,26 @@ public class FeaturesServiceImpl impleme
                     if (state.installed.contains(b)
                             || (b.getState() != Bundle.STARTING && b.getState() != Bundle.ACTIVE
                                     && getStartLevel().isBundlePersistentlyStarted(b))) {
-                    	// do no start bundles when user request it 
-                        try {
-                            b.start();
-                        } catch (BundleException be) {
-                            String[] msgdata = new String[]{
-                                b.getLocation(),
-                                getFeaturesContainingBundleList(b),
-                                be.getMessage()
-                            };
-                            String msg = MessageFormatter.arrayFormat("Could not start bundle {} in feature(s) {}: {}", msgdata);
-                            throw new Exception(msg, be);
-                        }
+                    	// do no start bundles when user request it
+                    	Long bundleId = b.getBundleId();
+                    	BundleInfo bundleInfo = state.bundleInfos.get(bundleId);
+                    	boolean status = true;
+                    	if (bundleInfo != null) {
+                    		status = bundleInfo.isStart();
+                    	}
+                     	if(status) {
+	                        try {
+	                            b.start();
+	                        } catch (BundleException be) {
+	                            String[] msgdata = new String[]{
+	                                b.getLocation(),
+	                                getFeaturesContainingBundleList(b),
+	                                be.getMessage()
+	                            };
+	                            String msg = MessageFormatter.arrayFormat("Could not start bundle {} in feature(s) {}: {}", msgdata);
+	                            throw new Exception(msg, be);
+	                        }
+                    	}
                     }
                 }
             }
@@ -364,6 +373,7 @@ public class FeaturesServiceImpl impleme
     protected static class InstallationState {
         final Set<Bundle> installed = new HashSet<Bundle>();
         final List<Bundle> bundles = new ArrayList<Bundle>();
+        final Map<Long, BundleInfo> bundleInfos = new HashMap<Long, BundleInfo>();
         final Map<Feature, Set<Long>> features = new HashMap<Feature, Set<Long>>();
     }
 
@@ -394,6 +404,7 @@ public class FeaturesServiceImpl impleme
         for (BundleInfo bInfo : resolve(feature)) {
             Bundle b = installBundleIfNeeded(state, bInfo);
             bundles.add(b.getBundleId());
+            state.bundleInfos.put(b.getBundleId(), bInfo);
         }
         state.features.put(feature, bundles);
     }