felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ccust...@apache.org
Subject svn commit: r904602 - /felix/trunk/karaf/features/core/src/main/java/org/apache/felix/karaf/features/internal/FeaturesServiceImpl.java
Date Fri, 29 Jan 2010 19:25:21 GMT
Author: ccustine
Date: Fri Jan 29 19:25:20 2010
New Revision: 904602

URL: http://svn.apache.org/viewvc?rev=904602&view=rev
Log:
FELIX-2001 - Add more info to log and console when feature bundles fail to resolve

Modified:
    felix/trunk/karaf/features/core/src/main/java/org/apache/felix/karaf/features/internal/FeaturesServiceImpl.java

Modified: felix/trunk/karaf/features/core/src/main/java/org/apache/felix/karaf/features/internal/FeaturesServiceImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/features/core/src/main/java/org/apache/felix/karaf/features/internal/FeaturesServiceImpl.java?rev=904602&r1=904601&r2=904602&view=diff
==============================================================================
--- felix/trunk/karaf/features/core/src/main/java/org/apache/felix/karaf/features/internal/FeaturesServiceImpl.java
(original)
+++ felix/trunk/karaf/features/core/src/main/java/org/apache/felix/karaf/features/internal/FeaturesServiceImpl.java
Fri Jan 29 19:25:20 2010
@@ -61,6 +61,7 @@
 import org.osgi.service.startlevel.StartLevel;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.slf4j.helpers.MessageFormatter;
 
 import static java.lang.String.format;
 
@@ -289,7 +290,17 @@
                     if (state.installed.contains(b)
                             || (b.getState() != Bundle.STARTING && b.getState() !=
Bundle.ACTIVE
                                     && getStartLevel().isBundlePersistentlyStarted(b)))
{
-                        b.start();
+                        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);
+                        }
                     }
                 }
             }
@@ -883,4 +894,29 @@
         }
     }
 
+    public Set<Feature> getFeaturesContainingBundle (Bundle bundle) {
+        Set<Feature> features = new HashSet<Feature>();
+        for (Map<String, Feature> featureMap : this.features.values()) {
+            for (Feature f : featureMap.values()) {
+                if (f.getBundles().contains(bundle.getLocation())) {
+                    features.add(f);
+                }
+            }
+        }
+        return features;
+    }
+
+    private String getFeaturesContainingBundleList(Bundle bundle) {
+        Set<Feature> features = getFeaturesContainingBundle(bundle);
+        StringBuilder buffer = new StringBuilder();
+        Iterator<Feature> iter = features.iterator();
+        while (iter.hasNext()) {
+            Feature feature= iter.next();
+            buffer.append(feature.getId());
+            if (iter.hasNext()) {
+                buffer.append(", ");
+            }
+        }
+        return buffer.toString();
+    }
 }



Mime
View raw message