karaf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbono...@apache.org
Subject svn commit: r1499268 - in /karaf/branches/karaf-2.3.x: assemblies/apache-karaf/src/main/filtered-resources/etc/ assemblies/apache-karaf/src/main/filtered-resources/minimal/ features/core/src/main/java/org/apache/karaf/features/internal/ features/core/s...
Date Wed, 03 Jul 2013 08:51:01 GMT
Author: jbonofre
Date: Wed Jul  3 08:51:00 2013
New Revision: 1499268

URL: http://svn.apache.org/r1499268
Log:
[KARAF-2372] Introduce bootFeaturesAsynchronous property in etc/org.apache.karaf.features.cfg
file

Modified:
    karaf/branches/karaf-2.3.x/assemblies/apache-karaf/src/main/filtered-resources/etc/org.apache.karaf.features.cfg
    karaf/branches/karaf-2.3.x/assemblies/apache-karaf/src/main/filtered-resources/minimal/org.apache.karaf.features.cfg
    karaf/branches/karaf-2.3.x/features/core/src/main/java/org/apache/karaf/features/internal/FeaturesServiceImpl.java
    karaf/branches/karaf-2.3.x/features/core/src/main/resources/OSGI-INF/blueprint/gshell-features.xml

Modified: karaf/branches/karaf-2.3.x/assemblies/apache-karaf/src/main/filtered-resources/etc/org.apache.karaf.features.cfg
URL: http://svn.apache.org/viewvc/karaf/branches/karaf-2.3.x/assemblies/apache-karaf/src/main/filtered-resources/etc/org.apache.karaf.features.cfg?rev=1499268&r1=1499267&r2=1499268&view=diff
==============================================================================
--- karaf/branches/karaf-2.3.x/assemblies/apache-karaf/src/main/filtered-resources/etc/org.apache.karaf.features.cfg
(original)
+++ karaf/branches/karaf-2.3.x/assemblies/apache-karaf/src/main/filtered-resources/etc/org.apache.karaf.features.cfg
Wed Jul  3 08:51:00 2013
@@ -28,3 +28,8 @@ featuresRepositories=mvn:org.apache.kara
 # Comma separated list of features to install at startup
 #
 featuresBoot=config,ssh,management,kar
+
+#
+# Defines if the boot features are started in asynchronous mode (in a dedicated thread)
+#
+featuresBootAsynchronous=false

Modified: karaf/branches/karaf-2.3.x/assemblies/apache-karaf/src/main/filtered-resources/minimal/org.apache.karaf.features.cfg
URL: http://svn.apache.org/viewvc/karaf/branches/karaf-2.3.x/assemblies/apache-karaf/src/main/filtered-resources/minimal/org.apache.karaf.features.cfg?rev=1499268&r1=1499267&r2=1499268&view=diff
==============================================================================
--- karaf/branches/karaf-2.3.x/assemblies/apache-karaf/src/main/filtered-resources/minimal/org.apache.karaf.features.cfg
(original)
+++ karaf/branches/karaf-2.3.x/assemblies/apache-karaf/src/main/filtered-resources/minimal/org.apache.karaf.features.cfg
Wed Jul  3 08:51:00 2013
@@ -33,3 +33,8 @@ featuresRepositories=mvn:org.apache.kara
 # Comma separated list of features to install at startup
 #
 featuresBoot=management
+
+#
+# Defines if the boot features are started in asynchronous mode (in a dedicated thread)
+#
+featuresBootAsynchronous=false

Modified: karaf/branches/karaf-2.3.x/features/core/src/main/java/org/apache/karaf/features/internal/FeaturesServiceImpl.java
URL: http://svn.apache.org/viewvc/karaf/branches/karaf-2.3.x/features/core/src/main/java/org/apache/karaf/features/internal/FeaturesServiceImpl.java?rev=1499268&r1=1499267&r2=1499268&view=diff
==============================================================================
--- karaf/branches/karaf-2.3.x/features/core/src/main/java/org/apache/karaf/features/internal/FeaturesServiceImpl.java
(original)
+++ karaf/branches/karaf-2.3.x/features/core/src/main/java/org/apache/karaf/features/internal/FeaturesServiceImpl.java
Wed Jul  3 08:51:00 2013
@@ -110,6 +110,7 @@ public class FeaturesServiceImpl impleme
     private Map<String, Map<String, Feature>> features;
     private Map<Feature, Set<Long>> installed = new HashMap<Feature, Set<Long>>();
     private String boot;
+    private boolean bootFeaturesAsynchronous;
     private boolean bootFeaturesInstalled;
     private List<FeaturesListener> listeners = new CopyOnWriteArrayIdentityList<FeaturesListener>();
     private ThreadLocal<Repository> repo = new ThreadLocal<Repository>();
@@ -198,6 +199,10 @@ public class FeaturesServiceImpl impleme
         this.boot = boot;
     }
 
+    public void setBootFeaturesAsynchronous(boolean bootFeaturesAsynchronous) {
+        this.bootFeaturesAsynchronous = bootFeaturesAsynchronous;
+    }
+
     /**
      * Validate repository.
      *
@@ -1108,50 +1113,101 @@ public class FeaturesServiceImpl impleme
         }
         // Install boot features
         if (boot != null && !bootFeaturesInstalled) {
-            // splitting the features
-            String[] list = boot.split(",");
-            Set<Feature> features = new LinkedHashSet<Feature>();
-            for (String f : list) {
-                f = f.trim();
-                if (f.length() > 0) {
-                    String featureVersion = null;
-
-                    // first we split the parts of the feature string to gain access to the
version info
-                    // if specified
-                    String[] parts = f.split(";");
-                    String featureName = parts[0];
-                    for (String part : parts) {
-                        // if the part starts with "version=" it contains the version info
-                        if (part.startsWith(FeatureImpl.VERSION_PREFIX)) {
-                            featureVersion = part.substring(FeatureImpl.VERSION_PREFIX.length());
+            if (bootFeaturesAsynchronous) {
+                new Thread() {
+                    public void run() {
+                        // splitting the features
+                        String[] list = boot.split(",");
+                        Set<Feature> features = new LinkedHashSet<Feature>();
+                        for (String f : list) {
+                            f = f.trim();
+                            if (f.length() > 0) {
+                                String featureVersion = null;
+
+                                // first we split the parts of the feature string to gain
access to the version info
+                                // if specified
+                                String[] parts = f.split(";");
+                                String featureName = parts[0];
+                                for (String part : parts) {
+                                    // if the part starts with "version=" it contains the
version info
+                                    if (part.startsWith(FeatureImpl.VERSION_PREFIX)) {
+                                        featureVersion = part.substring(FeatureImpl.VERSION_PREFIX.length());
+                                    }
+                                }
+
+                                if (featureVersion == null) {
+                                    // no version specified - use default version
+                                    featureVersion = FeatureImpl.DEFAULT_VERSION;
+                                }
+
+                                try {
+                                    // try to grab specific feature version
+                                    Feature feature = getFeature(featureName, featureVersion);
+                                    if (feature != null) {
+                                        features.add(feature);
+                                    } else {
+                                        LOGGER.error("Error installing boot feature " + f
+ ": feature not found");
+                                    }
+                                } catch (Exception e) {
+                                    LOGGER.error("Error installing boot feature " + f, e);
+                                }
+                            }
                         }
+                        try {
+                            installFeatures(features, EnumSet.of(Option.NoCleanIfFailure,
Option.ContinueBatchOnFailure));
+                        } catch (Exception e) {
+                            LOGGER.error("Error installing boot features", e);
+                        }
+                        bootFeaturesInstalled = true;
+                        saveState();
                     }
+                }.start();
+            } else {
+                // splitting the features
+                String[] list = boot.split(",");
+                Set<Feature> features = new LinkedHashSet<Feature>();
+                for (String f : list) {
+                    f = f.trim();
+                    if (f.length() > 0) {
+                        String featureVersion = null;
+
+                        // first we split the parts of the feature string to gain access
to the version info
+                        // if specified
+                        String[] parts = f.split(";");
+                        String featureName = parts[0];
+                        for (String part : parts) {
+                            // if the part starts with "version=" it contains the version
info
+                            if (part.startsWith(FeatureImpl.VERSION_PREFIX)) {
+                                featureVersion = part.substring(FeatureImpl.VERSION_PREFIX.length());
+                            }
+                        }
 
-                    if (featureVersion == null) {
-                        // no version specified - use default version
-                        featureVersion = FeatureImpl.DEFAULT_VERSION;
-                    }
+                        if (featureVersion == null) {
+                            // no version specified - use default version
+                            featureVersion = FeatureImpl.DEFAULT_VERSION;
+                        }
 
-                    try {
-                        // try to grab specific feature version
-                        Feature feature = getFeature(featureName, featureVersion);
-                        if (feature != null) {
-                            features.add(feature);
-                        } else {
-                            LOGGER.error("Error installing boot feature " + f + ": feature
not found");
+                        try {
+                            // try to grab specific feature version
+                            Feature feature = getFeature(featureName, featureVersion);
+                            if (feature != null) {
+                                features.add(feature);
+                            } else {
+                                LOGGER.error("Error installing boot feature " + f + ": feature
not found");
+                            }
+                        } catch (Exception e) {
+                            LOGGER.error("Error installing boot feature " + f, e);
                         }
-                    } catch (Exception e) {
-                        LOGGER.error("Error installing boot feature " + f, e);
                     }
                 }
+                try {
+                    installFeatures(features, EnumSet.of(Option.NoCleanIfFailure, Option.ContinueBatchOnFailure));
+                } catch (Exception e) {
+                    LOGGER.error("Error installing boot features", e);
+                }
+                bootFeaturesInstalled = true;
+                saveState();
             }
-            try {
-                installFeatures(features, EnumSet.of(Option.NoCleanIfFailure, Option.ContinueBatchOnFailure));
-            } catch (Exception e) {
-                LOGGER.error("Error installing boot features", e);
-            }
-            bootFeaturesInstalled = true;
-            saveState();
         }
     }
 

Modified: karaf/branches/karaf-2.3.x/features/core/src/main/resources/OSGI-INF/blueprint/gshell-features.xml
URL: http://svn.apache.org/viewvc/karaf/branches/karaf-2.3.x/features/core/src/main/resources/OSGI-INF/blueprint/gshell-features.xml?rev=1499268&r1=1499267&r2=1499268&view=diff
==============================================================================
--- karaf/branches/karaf-2.3.x/features/core/src/main/resources/OSGI-INF/blueprint/gshell-features.xml
(original)
+++ karaf/branches/karaf-2.3.x/features/core/src/main/resources/OSGI-INF/blueprint/gshell-features.xml
Wed Jul  3 08:51:00 2013
@@ -26,6 +26,7 @@
         <ext:default-properties>
             <ext:property name="featuresRepositories" value=""/>
             <ext:property name="featuresBoot" value=""/>
+            <ext:property name="featuresBootAsynchronous" value="false"/>
             <ext:property name="resolverTimeout" value="5000"/>
             <ext:property name="respectStartLvlDuringFeatureStartup" value="false"/>
         </ext:default-properties>
@@ -35,6 +36,7 @@
     <bean id="featuresService" class="org.apache.karaf.features.internal.FeaturesServiceImpl"
init-method="start" destroy-method="stop">
         <property name="urls" value="$[featuresRepositories]" />
         <property name="boot" value="$[featuresBoot]" />
+        <property name="bootFeaturesAsynchronous" value="$[featuresBootAsynchronous]"/>
         <property name="respectStartLvlDuringFeatureStartup" value="$[respectStartLvlDuringFeatureStartup]"
/>
         <property name="resolverTimeout" value="$[resolverTimeout]" />
         <property name="configAdmin" ref="configAdmin" />



Mime
View raw message