Document A2 OSGi Boot. Add classpath provisioning source.
[lgpl/argeo-commons.git] / org.argeo.osgi.boot / src / org / argeo / osgi / boot / OsgiBootUtils.java
index 455c96198b3d76f1e8c344608db3b1f08a0a6d54..9593b0cde8bf8babdec9a79fe959aba90c0a679c 100644 (file)
@@ -20,9 +20,13 @@ import java.text.SimpleDateFormat;
 import java.util.ArrayList;\r
 import java.util.Date;\r
 import java.util.List;\r
+import java.util.Map;\r
 import java.util.StringTokenizer;\r
 \r
 import org.osgi.framework.Bundle;\r
+import org.osgi.framework.BundleException;\r
+import org.osgi.framework.launch.Framework;\r
+import org.osgi.framework.launch.FrameworkFactory;\r
 \r
 /** Utilities, mostly related to logging. */\r
 public class OsgiBootUtils {\r
@@ -126,4 +130,16 @@ public class OsgiBootUtils {
                return comp;\r
        }\r
 \r
+       /** Launch an OSGi framework. */\r
+       public static Framework launch(FrameworkFactory frameworkFactory, Map<String, String> configuration) {\r
+               // start OSGi\r
+               Framework framework = frameworkFactory.newFramework(configuration);\r
+               try {\r
+                       framework.start();\r
+               } catch (BundleException e) {\r
+                       throw new OsgiBootException("Cannot start OSGi framework", e);\r
+               }\r
+               return framework;\r
+       }\r
+\r
 }\r