You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by cs...@apache.org on 2012/10/02 13:38:44 UTC
svn commit: r1392853 - in /karaf/trunk/features/core/src:
main/java/org/apache/karaf/features/
main/java/org/apache/karaf/features/internal/
main/resources/OSGI-INF/blueprint/
test/java/org/apache/karaf/features/internal/
Author: cschneider
Date: Tue Oct 2 11:38:43 2012
New Revision: 1392853
URL: http://svn.apache.org/viewvc?rev=1392853&view=rev
Log:
KARAF-1887 Add BootFinished service to publish when boot is done
Added:
karaf/trunk/features/core/src/main/java/org/apache/karaf/features/BootFinished.java (with props)
Modified:
karaf/trunk/features/core/src/main/java/org/apache/karaf/features/internal/BootFeaturesInstaller.java
karaf/trunk/features/core/src/main/resources/OSGI-INF/blueprint/blueprint.xml
karaf/trunk/features/core/src/test/java/org/apache/karaf/features/internal/BootFeaturesInstallerTest.java
Added: karaf/trunk/features/core/src/main/java/org/apache/karaf/features/BootFinished.java
URL: http://svn.apache.org/viewvc/karaf/trunk/features/core/src/main/java/org/apache/karaf/features/BootFinished.java?rev=1392853&view=auto
==============================================================================
--- karaf/trunk/features/core/src/main/java/org/apache/karaf/features/BootFinished.java (added)
+++ karaf/trunk/features/core/src/main/java/org/apache/karaf/features/BootFinished.java Tue Oct 2 11:38:43 2012
@@ -0,0 +1,8 @@
+package org.apache.karaf.features;
+
+/**
+ * Marker interface for a service that announces when the karaf boot is finished
+ */
+public interface BootFinished {
+
+}
Propchange: karaf/trunk/features/core/src/main/java/org/apache/karaf/features/BootFinished.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: karaf/trunk/features/core/src/main/java/org/apache/karaf/features/internal/BootFeaturesInstaller.java
URL: http://svn.apache.org/viewvc/karaf/trunk/features/core/src/main/java/org/apache/karaf/features/internal/BootFeaturesInstaller.java?rev=1392853&r1=1392852&r2=1392853&view=diff
==============================================================================
--- karaf/trunk/features/core/src/main/java/org/apache/karaf/features/internal/BootFeaturesInstaller.java (original)
+++ karaf/trunk/features/core/src/main/java/org/apache/karaf/features/internal/BootFeaturesInstaller.java Tue Oct 2 11:38:43 2012
@@ -20,14 +20,17 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.EnumSet;
import java.util.HashSet;
+import java.util.Hashtable;
import java.util.List;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import org.apache.karaf.features.BootFinished;
import org.apache.karaf.features.Feature;
import org.apache.karaf.features.FeaturesService;
import org.apache.karaf.features.FeaturesService.Option;
+import org.osgi.framework.BundleContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -39,6 +42,7 @@ public class BootFeaturesInstaller {
public static String VERSION_PREFIX = "version=";
+ private final BundleContext bundleContext;
private final FeaturesService featuresService;
private final String boot;
@@ -47,8 +51,9 @@ public class BootFeaturesInstaller {
* @param featuresService
* @param boot list of boot features separated by comma. Optionally contains ;version=x.x.x to specify a specific feature version
*/
- public BootFeaturesInstaller(FeaturesService featuresService, String boot) {
- this.featuresService = featuresService;
+ public BootFeaturesInstaller(BundleContext bundleContext, FeaturesService featuresService, String boot) {
+ this.bundleContext = bundleContext;
+ this.featuresService = featuresService;
this.boot = boot;
}
@@ -61,8 +66,11 @@ public class BootFeaturesInstaller {
new Thread() {
public void run() {
installBootFeatures();
+ publishBootFinished();
}
}.start();
+ } else {
+ publishBootFinished();
}
}
@@ -141,4 +149,11 @@ public class BootFeaturesInstaller {
return features;
}
+ private void publishBootFinished() {
+ if (bundleContext != null) {
+ BootFinished bootFinished = new BootFinished() {};
+ bundleContext.registerService(BootFinished.class, bootFinished, new Hashtable<String, String>());
+ }
+ }
+
}
Modified: karaf/trunk/features/core/src/main/resources/OSGI-INF/blueprint/blueprint.xml
URL: http://svn.apache.org/viewvc/karaf/trunk/features/core/src/main/resources/OSGI-INF/blueprint/blueprint.xml?rev=1392853&r1=1392852&r2=1392853&view=diff
==============================================================================
--- karaf/trunk/features/core/src/main/resources/OSGI-INF/blueprint/blueprint.xml (original)
+++ karaf/trunk/features/core/src/main/resources/OSGI-INF/blueprint/blueprint.xml Tue Oct 2 11:38:43 2012
@@ -52,6 +52,7 @@ http://www.osgi.org/xmlns/blueprint-ext/
</bean>
<bean id="bootFeaturesInstaller" class="org.apache.karaf.features.internal.BootFeaturesInstaller" init-method="start">
+ <argument ref="blueprintBundleContext" />
<argument ref="featuresService" />
<argument value="$[featuresBoot]" />
</bean>
Modified: karaf/trunk/features/core/src/test/java/org/apache/karaf/features/internal/BootFeaturesInstallerTest.java
URL: http://svn.apache.org/viewvc/karaf/trunk/features/core/src/test/java/org/apache/karaf/features/internal/BootFeaturesInstallerTest.java?rev=1392853&r1=1392852&r2=1392853&view=diff
==============================================================================
--- karaf/trunk/features/core/src/test/java/org/apache/karaf/features/internal/BootFeaturesInstallerTest.java (original)
+++ karaf/trunk/features/core/src/test/java/org/apache/karaf/features/internal/BootFeaturesInstallerTest.java Tue Oct 2 11:38:43 2012
@@ -33,7 +33,7 @@ public class BootFeaturesInstallerTest e
@Test
@SuppressWarnings("unchecked")
public void testParser() {
- BootFeaturesInstaller installer = new BootFeaturesInstaller(null, "");
+ BootFeaturesInstaller installer = new BootFeaturesInstaller(null, null, "");
Assert.assertEquals(asList(setOf("test1", "test2"),setOf("test3")), installer.parseBootFeatures("(test1, test2), test3"));
Assert.assertEquals(asList(setOf("test1", "test2", "test3")), installer.parseBootFeatures("test1, test2, test3"));
}
@@ -53,7 +53,7 @@ public class BootFeaturesInstallerTest e
EasyMock.expectLastCall();
replay(impl);
- BootFeaturesInstaller bootFeatures = new BootFeaturesInstaller(impl , "config,standard,region");
+ BootFeaturesInstaller bootFeatures = new BootFeaturesInstaller(null, impl, "config,standard,region");
bootFeatures.installBootFeatures();
EasyMock.verify(impl);
}
@@ -76,7 +76,7 @@ public class BootFeaturesInstallerTest e
EasyMock.expectLastCall();
replay(impl);
- BootFeaturesInstaller bootFeatures = new BootFeaturesInstaller(impl , "transaction;version=1.2,ssh;version=1.0.0");
+ BootFeaturesInstaller bootFeatures = new BootFeaturesInstaller(null, impl , "transaction;version=1.2,ssh;version=1.0.0");
bootFeatures.installBootFeatures();
EasyMock.verify(impl);
}
@@ -96,7 +96,7 @@ public class BootFeaturesInstallerTest e
EasyMock.expectLastCall();
replay(impl);
- BootFeaturesInstaller bootFeatures = new BootFeaturesInstaller(impl , "(transaction), ssh");
+ BootFeaturesInstaller bootFeatures = new BootFeaturesInstaller(null, impl , "(transaction), ssh");
bootFeatures.installBootFeatures();
EasyMock.verify(impl);
}