[karaf] Add the web demo back

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@805333 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/karaf/demos/pom.xml b/karaf/demos/pom.xml
index e6cd94b..f9b815c 100644
--- a/karaf/demos/pom.xml
+++ b/karaf/demos/pom.xml
@@ -27,14 +27,14 @@
         <version>1.2.0-SNAPSHOT</version>
     </parent>
 
-    <groupId>org.apache.felix.karaf</groupId>
-    <artifactId>org.apache.felix.karaf.demos</artifactId>
+    <groupId>org.apache.felix.karaf.demos</groupId>
+    <artifactId>demos</artifactId>
     <packaging>pom</packaging>
     <version>1.2.0-SNAPSHOT</version>
     <name>Apache Felix Karaf :: Demos</name>
 
     <modules>
-        <module>smx4web</module>
+        <module>web</module>
     </modules>
 
 </project>
diff --git a/karaf/demos/smx4web/pom.xml b/karaf/demos/smx4web/pom.xml
deleted file mode 100644
index b3b6789..0000000
--- a/karaf/demos/smx4web/pom.xml
+++ /dev/null
@@ -1,283 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-
-<!--
-
-    Licensed to the Apache Software Foundation (ASF) under one or more
-    contributor license agreements.  See the NOTICE file distributed with
-    this work for additional information regarding copyright ownership.
-    The ASF licenses this file to You under the Apache License, Version 2.0
-    (the "License"); you may not use this file except in compliance with
-    the License.  You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-    Unless required by applicable law or agreed to in writing, software
-    distributed under the License is distributed on an "AS IS" BASIS,
-    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-    See the License for the specific language governing permissions and
-    limitations under the License.
--->
-
-  <modelVersion>4.0.0</modelVersion>
-
-  <parent>
-    <groupId>org.apache.felix.karaf</groupId>
-    <artifactId>org.apache.felix.karaf.demos</artifactId>
-    <version>1.2.0-SNAPSHOT</version>
-  </parent>
-
-  <groupId>org.apache.felix.karaf.demos</groupId>
-  <artifactId>smx4web</artifactId>
-  <packaging>war</packaging>
-  <name>Apache Felix Karaf :: Demos :: smx4web</name>
-  
-  <properties>
-    <jetty.port>8080</jetty.port>
-    <jetty.version>6.1.12rc1</jetty.version>
-    <geronimo.servlet.version>1.1.2</geronimo.servlet.version>
-  </properties>
-
-  <dependencies>
-    <dependency>
-      <groupId>org.apache.felix.karaf</groupId>
-      <artifactId>org.apache.felix.karaf.main</artifactId>
-    </dependency>
-    <dependency>
-        <groupId>org.apache.felix.karaf</groupId>
-        <artifactId>apache-felix-karaf</artifactId>
-        <type>zip</type>
-        <exclusions>
-            <exclusion>
-                <groupId>org.apache.felix.karaf</groupId>
-                <artifactId>org.apache.felix.karaf.client</artifactId>
-            </exclusion>
-            <exclusion>
-                <groupId>org.apache.felix.karaf</groupId>
-                <artifactId>org.apache.felix.karaf.filemonitor</artifactId>
-            </exclusion>
-            <exclusion>
-                <groupId>org.apache.felix.karaf</groupId>
-                <artifactId>org.apache.felix.karaf.spring</artifactId>
-            </exclusion>
-            <exclusion>
-                <groupId>org.apache.felix.karaf.gshell</groupId>
-                <artifactId>org.apache.felix.karaf.gshell.core</artifactId>
-            </exclusion>
-            <exclusion>
-                <groupId>org.apache.felix.karaf.gshell</groupId>
-                <artifactId>org.apache.felix.karaf.gshell.admin</artifactId>
-            </exclusion>
-            <exclusion>
-                <groupId>org.apache.felix.karaf.gshell</groupId>
-                <artifactId>org.apache.felix.karaf.gshell.obr</artifactId>
-            </exclusion>
-            <exclusion>
-                <groupId>org.apache.felix.karaf.gshell</groupId>
-                <artifactId>org.apache.felix.karaf.gshell.osgi</artifactId>
-            </exclusion>
-            <exclusion>
-                <groupId>org.apache.felix.karaf.gshell</groupId>
-                <artifactId>org.apache.felix.karaf.gshell.log</artifactId>
-            </exclusion>
-            <exclusion>
-                <groupId>org.apache.felix.karaf.gshell</groupId>
-                <artifactId>org.apache.felix.karaf.gshell.features</artifactId>
-            </exclusion>
-            <exclusion>
-                <groupId>org.apache.felix.karaf.gshell</groupId>
-                <artifactId>org.apache.felix.karaf.gshell.config</artifactId>
-            </exclusion>
-            <exclusion>
-                <groupId>org.apache.felix.karaf.gshell</groupId>
-                <artifactId>org.apache.felix.karaf.gshell.packages</artifactId>
-            </exclusion>
-            <exclusion>
-                <groupId>org.apache.felix.karaf.jaas</groupId>
-                <artifactId>org.apache.felix.karaf.jaas.config</artifactId>
-            </exclusion>
-            <exclusion>
-                <groupId>org.apache.felix.karaf.jaas</groupId>
-                <artifactId>org.apache.felix.karaf.jaas.keystore</artifactId>
-            </exclusion>
-            <exclusion>
-                <groupId>org.springframework.osgi</groupId>
-                <artifactId>spring-osgi-extender</artifactId>
-            </exclusion>
-            <exclusion>
-                <groupId>org.springframework.osgi</groupId>
-                <artifactId>spring-osgi-core</artifactId>
-            </exclusion>
-            <exclusion>
-                <groupId>org.springframework.osgi</groupId>
-                <artifactId>spring-osgi-io</artifactId>
-            </exclusion>
-            <exclusion>
-                <groupId>org.springframework</groupId>
-                <artifactId>spring-context</artifactId>
-            </exclusion>
-            <exclusion>
-                <groupId>org.springframework</groupId>
-                <artifactId>spring-beans</artifactId>
-            </exclusion>
-            <exclusion>
-                <groupId>org.springframework</groupId>
-                <artifactId>spring-core</artifactId>
-            </exclusion>
-            <exclusion>
-                <groupId>org.springframework</groupId>
-                <artifactId>spring-aop</artifactId>
-            </exclusion>
-            <exclusion>
-                <groupId>org.apache.felix</groupId>
-                <artifactId>org.apache.felix.bundlerepository</artifactId>
-            </exclusion>
-            <exclusion>
-                <groupId>org.apache.felix</groupId>
-                <artifactId>org.apache.felix.configadmin</artifactId>
-            </exclusion>
-            <exclusion>
-                <groupId>org.apache.felix</groupId>
-                <artifactId>org.apache.felix.prefs</artifactId>
-            </exclusion>
-            <exclusion>
-                <groupId>org.apache.felix</groupId>
-                <artifactId>org.osgi.compendium</artifactId>
-            </exclusion>
-            <exclusion>
-                <groupId>org.apache.servicemix.bundles</groupId>
-                <artifactId>org.apache.servicemix.bundles.mina</artifactId>
-            </exclusion>
-            <exclusion>
-                <groupId>org.apache.servicemix.bundles</groupId>
-                <artifactId>org.apache.servicemix.bundles.aopalliance</artifactId>
-            </exclusion>
-            <exclusion>
-                <groupId>org.apache.servicemix.bundles</groupId>
-                <artifactId>org.apache.servicemix.bundles.asm</artifactId>
-            </exclusion>
-            <exclusion>
-                <groupId>org.apache.servicemix.bundles</groupId>
-                <artifactId>org.apache.servicemix.bundles.cglib</artifactId>
-            </exclusion>
-            <exclusion>
-                <groupId>org.apache.servicemix.bundles</groupId>
-                <artifactId>org.apache.servicemix.bundles.ant</artifactId>
-            </exclusion>
-            <exclusion>
-                <groupId>org.ops4j.pax.logging</groupId>
-                <artifactId>pax-logging-service</artifactId>
-            </exclusion>
-            <exclusion>
-                <groupId>org.ops4j.pax.logging</groupId>
-                <artifactId>pax-logging-api</artifactId>
-            </exclusion>
-            <exclusion>
-                <groupId>org.ops4j.pax.url</groupId>
-                <artifactId>pax-url-mvn</artifactId>
-            </exclusion>
-        </exclusions>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.geronimo.specs</groupId>
-      <artifactId>geronimo-servlet_2.5_spec</artifactId>
-      <scope>provided</scope>
-    </dependency>
-  </dependencies>
-
-  <build>
-    <plugins>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-compiler-plugin</artifactId>
-        <configuration>
-          <source>1.5</source>
-          <target>1.5</target>
-        </configuration>
-      </plugin>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-war-plugin</artifactId>
-        <version>2.1-beta-1</version>
-        <configuration>
-          <warSourceDirectory>src/main/webapp/</warSourceDirectory>
-          <webResources>
-            <resource>
-              <directory>target/kernel</directory>
-            </resource>
-          </webResources>
-        </configuration>
-      </plugin>
-      <plugin>
-        <groupId>org.mortbay.jetty</groupId>
-        <artifactId>maven-jetty-plugin</artifactId>
-        <version>${jetty.version}</version>
-        <configuration>
-          <connectors>
-            <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
-              <port>${jetty.port}</port>
-              <maxIdleTime>60000</maxIdleTime>
-            </connector>
-          </connectors>
-          <systemProperties>
-            <!-- enable easy connection to JConsole -->
-            <systemProperty>
-              <name>com.sun.management.jmxremote</name>
-              <value></value>
-            </systemProperty>
-          </systemProperties>
-          <scanIntervalSeconds>10</scanIntervalSeconds>
-          <webAppSourceDirectory>${project.build.directory}/${project.build.finalName}</webAppSourceDirectory>
-        </configuration>
-      </plugin>
-      <plugin>
-          <groupId>org.apache.maven.plugins</groupId>
-          <artifactId>maven-dependency-plugin</artifactId>
-          <version>2.0</version>
-          <executions>
-              <execution>
-                  <id>unpack-unix</id>
-                  <phase>generate-resources</phase>
-                  <goals>
-                      <goal>unpack</goal>
-                  </goals>
-                  <configuration>
-                      <artifactItems>
-                          <artifactItem>
-                              <groupId>org.apache.felix.karaf</groupId>
-                              <artifactId>apache-felix-karaf</artifactId>
-                              <type>zip</type>
-                              <overWrite>true</overWrite>
-                              <outputDirectory>${project.build.directory}/kernel/WEB-INF</outputDirectory>
-                              <excludes>**/lib/*,**/*.txt,**/bin/*,**/demos/**,**/lib,**/bin,**/demos</excludes>
-                          </artifactItem>
-                      </artifactItems>
-                  </configuration>
-              </execution>
-        </executions>
-      </plugin>
-      <plugin>
-          <groupId>org.apache.maven.plugins</groupId>
-          <artifactId>maven-antrun-plugin</artifactId>
-          <version>1.3</version>
-          <executions>
-              <execution>
-                  <id>copy-kernel</id>
-                  <phase>process-resources</phase>
-                  <goals>
-                      <goal>run</goal>
-                  </goals>
-                  <configuration>
-                      <tasks>
-                          <move todir="${project.build.directory}/kernel/WEB-INF/servicemix">
-                              <fileset dir="${project.build.directory}/kernel/WEB-INF/apache-felix-karaf-${pom.version}"/>
-                          </move>
-                      </tasks>
-                  </configuration>
-              </execution>
-          </executions>
-      </plugin>
-    </plugins>
-  </build>
-
-</project>
diff --git a/karaf/demos/smx4web/README.txt b/karaf/demos/web/README.txt
similarity index 100%
rename from karaf/demos/smx4web/README.txt
rename to karaf/demos/web/README.txt
diff --git a/karaf/demos/web/pom.xml b/karaf/demos/web/pom.xml
new file mode 100644
index 0000000..f997265
--- /dev/null
+++ b/karaf/demos/web/pom.xml
@@ -0,0 +1,158 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.felix.karaf.demos</groupId>
+    <artifactId>demos</artifactId>
+    <version>1.2.0-SNAPSHOT</version>
+  </parent>
+
+  <groupId>org.apache.felix.karaf.demos</groupId>
+  <artifactId>web</artifactId>
+  <packaging>war</packaging>
+  <name>Apache Felix Karaf :: Demos :: web</name>
+  
+  <properties>
+    <jetty.port>8080</jetty.port>
+    <jetty.version>6.1.12rc1</jetty.version>
+    <geronimo.servlet.version>1.1.2</geronimo.servlet.version>
+  </properties>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.felix.karaf</groupId>
+      <artifactId>org.apache.felix.karaf.main</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.felix.karaf.jaas</groupId>
+      <artifactId>org.apache.felix.karaf.jaas.boot</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.felix.karaf</groupId>
+      <artifactId>apache-felix-karaf</artifactId>
+      <type>zip</type>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.geronimo.specs</groupId>
+      <artifactId>geronimo-servlet_2.5_spec</artifactId>
+      <scope>provided</scope>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <configuration>
+          <source>1.5</source>
+          <target>1.5</target>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-war-plugin</artifactId>
+        <version>2.1-beta-1</version>
+        <configuration>
+          <warSourceDirectory>src/main/webapp/</warSourceDirectory>
+          <webResources>
+            <resource>
+              <directory>target/karaf</directory>
+            </resource>
+          </webResources>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.mortbay.jetty</groupId>
+        <artifactId>maven-jetty-plugin</artifactId>
+        <version>${jetty.version}</version>
+        <configuration>
+          <connectors>
+            <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
+              <port>${jetty.port}</port>
+              <maxIdleTime>60000</maxIdleTime>
+            </connector>
+          </connectors>
+          <systemProperties>
+            <!-- enable easy connection to JConsole -->
+            <systemProperty>
+              <name>com.sun.management.jmxremote</name>
+              <value></value>
+            </systemProperty>
+          </systemProperties>
+          <scanIntervalSeconds>10</scanIntervalSeconds>
+          <webAppSourceDirectory>${project.build.directory}/${project.build.finalName}</webAppSourceDirectory>
+        </configuration>
+      </plugin>
+      <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-dependency-plugin</artifactId>
+          <version>2.0</version>
+          <executions>
+              <execution>
+                  <id>unpack-unix</id>
+                  <phase>generate-resources</phase>
+                  <goals>
+                      <goal>unpack</goal>
+                  </goals>
+                  <configuration>
+                      <artifactItems>
+                          <artifactItem>
+                              <groupId>org.apache.felix.karaf</groupId>
+                              <artifactId>apache-felix-karaf</artifactId>
+                              <type>zip</type>
+                              <overWrite>true</overWrite>
+                              <outputDirectory>${project.build.directory}/karaf/WEB-INF</outputDirectory>
+                              <excludes>**/lib/*,**/*.txt,**/bin/*,**/demos/**,**/lib,**/bin,**/demos</excludes>
+                          </artifactItem>
+                      </artifactItems>
+                  </configuration>
+              </execution>
+        </executions>
+      </plugin>
+      <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-antrun-plugin</artifactId>
+          <version>1.3</version>
+          <executions>
+              <execution>
+                  <id>copy-karaf</id>
+                  <phase>process-resources</phase>
+                  <goals>
+                      <goal>run</goal>
+                  </goals>
+                  <configuration>
+                      <tasks>
+                          <move todir="${project.build.directory}/karaf/WEB-INF/karaf">
+                              <fileset dir="${project.build.directory}/karaf/WEB-INF/apache-felix-karaf-${pom.version}"/>
+                          </move>
+                      </tasks>
+                  </configuration>
+              </execution>
+          </executions>
+      </plugin>
+    </plugins>
+  </build>
+
+</project>
diff --git a/karaf/demos/smx4web/src/main/java/org/apache/servicemix/smx4webex/WebAppListener.java b/karaf/demos/web/src/main/java/org/apache/felix/karaf/web/WebAppListener.java
similarity index 90%
rename from karaf/demos/smx4web/src/main/java/org/apache/servicemix/smx4webex/WebAppListener.java
rename to karaf/demos/web/src/main/java/org/apache/felix/karaf/web/WebAppListener.java
index d0cda99..8db85b1 100644
--- a/karaf/demos/smx4web/src/main/java/org/apache/servicemix/smx4webex/WebAppListener.java
+++ b/karaf/demos/web/src/main/java/org/apache/felix/karaf/web/WebAppListener.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.servicemix.smx4webex;
+package org.apache.felix.karaf.web;
 
 import java.io.File;
 
@@ -22,6 +22,7 @@
 import javax.servlet.ServletContextListener;
 
 import org.apache.felix.karaf.main.Main;
+import org.apache.felix.karaf.main.Bootstrap;
 
 public class WebAppListener implements ServletContextListener {
 	
@@ -30,14 +31,13 @@
 	public void contextInitialized(ServletContextEvent sce) {
 		try {
 			System.err.println("contextInitialized");
-			String root = new File(sce.getServletContext().getRealPath("/") + "WEB-INF/servicemix").getAbsolutePath();
+			String root = new File(sce.getServletContext().getRealPath("/") + "WEB-INF/karaf").getAbsolutePath();
 			System.err.println("Root: " + root);
 			System.setProperty("karaf.home", root);
 			System.setProperty("karaf.base", root);
 			System.setProperty("karaf.startLocalConsole", "false");
 			System.setProperty("karaf.startRemoteShell", "true");
-			main = new Main(new String[0]);
-			main.launch();
+			main = Bootstrap.launch(new String[0]);
 		} catch (Exception e) {
 			main = null;
 			e.printStackTrace();
diff --git a/karaf/demos/smx4web/src/main/webapp/WEB-INF/web.xml b/karaf/demos/web/src/main/webapp/WEB-INF/web.xml
similarity index 85%
rename from karaf/demos/smx4web/src/main/webapp/WEB-INF/web.xml
rename to karaf/demos/web/src/main/webapp/WEB-INF/web.xml
index 30f7072..4e2471b 100644
--- a/karaf/demos/smx4web/src/main/webapp/WEB-INF/web.xml
+++ b/karaf/demos/web/src/main/webapp/WEB-INF/web.xml
@@ -22,11 +22,11 @@
          xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
                              http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
 
-  <description>ServiceMix 4 Embedded Example</description>
-  <display-name>ServiceMix 4 Embedded Example</display-name>
+  <description>Karaf Embedded Example</description>
+  <display-name>Karaf Embedded Example</display-name>
 
   <listener>
-    <listener-class>org.apache.servicemix.smx4webex.WebAppListener</listener-class>
+    <listener-class>org.apache.felix.karaf.web.WebAppListener</listener-class>
   </listener>
 
   <welcome-file-list>
diff --git a/karaf/demos/smx4web/src/main/webapp/index.jsp b/karaf/demos/web/src/main/webapp/index.jsp
similarity index 79%
rename from karaf/demos/smx4web/src/main/webapp/index.jsp
rename to karaf/demos/web/src/main/webapp/index.jsp
index 3734ee9..ab13f33 100644
--- a/karaf/demos/smx4web/src/main/webapp/index.jsp
+++ b/karaf/demos/web/src/main/webapp/index.jsp
@@ -16,18 +16,18 @@
 --%>
 <html>
 <head>
-<title>Apache ServiceMix Kernel</title>
+<title>Apache Felix Karaf</title>
 </head>
 <body>
 
 <h2>Welcome!</h2>
 
 <p>
-Welcome to Apache ServiceMix Kernel web application demo
+Welcome to Apache Karaf web application demo
 </p>
 
 <p>
-You can find more information about ServiceMix Kernel on the <a href="http://servicemix.apache.org/kernel">Apache ServiceMix Kernel Site</a>
+You can find more information about Karaf on the <a href="http://felix.apache.org/site/apache-felix-karaf.html">Apache Karaf Site</a>
 </p>
 </body>
 </html>
diff --git a/karaf/main/src/main/java/org/apache/felix/karaf/main/Bootstrap.java b/karaf/main/src/main/java/org/apache/felix/karaf/main/Bootstrap.java
index 86b6a2f..59c05e6 100644
--- a/karaf/main/src/main/java/org/apache/felix/karaf/main/Bootstrap.java
+++ b/karaf/main/src/main/java/org/apache/felix/karaf/main/Bootstrap.java
@@ -35,39 +35,48 @@
 
     public static void main(String[] args) {
         try {
-            File home = Utils.getKarafHome();
-            File file = new File(new File(home, "etc"), FRAMEWORK_PROPERTIES_FILE_NAME);
-            if (!file.exists()) {
-                throw new FileNotFoundException(file.getAbsolutePath());
-            }
-            Properties props = new Properties();
-            InputStream is = new FileInputStream(file);
-            props.load(is);
-            is.close();
-
-            String framework = props.getProperty(KARAF_FRAMEWORK);
-            if (framework == null) {
-                throw new IllegalArgumentException("Property " + KARAF_FRAMEWORK + " must be set in the etc/" + FRAMEWORK_PROPERTIES_FILE_NAME + " configuration file");
-            }
-            String bundle = props.getProperty(KARAF_FRAMEWORK + "." + framework);
-            if (bundle == null) {
-                throw new IllegalArgumentException("Property " + KARAF_FRAMEWORK + "." + framework + " must be set in the etc/" + FRAMEWORK_PROPERTIES_FILE_NAME + " configuration file");
-            }
-            File bundleFile = new File(home, bundle);
-            if (!bundleFile.exists()) {
-                throw new FileNotFoundException(bundleFile.getAbsolutePath());
-            }
-
-            URLClassLoader classLoader = (URLClassLoader) Bootstrap.class.getClassLoader();
-            Method mth = URLClassLoader.class.getDeclaredMethod("addURL", URL.class);
-            mth.setAccessible(true);
-            mth.invoke(classLoader, bundleFile.toURL());
-
+            updateClassLoader();
             Main.main(args);
-
         } catch (Throwable t) {
             t.printStackTrace();
             System.exit(-1);
         }
     }
+
+    public static Main launch(String[] args) throws Exception {
+        updateClassLoader();
+        Main main = new Main(args);
+        main.launch();
+        return main;
+    }
+
+    private static void updateClassLoader() throws Exception {
+        File home = Utils.getKarafHome();
+        File file = new File(new File(home, "etc"), FRAMEWORK_PROPERTIES_FILE_NAME);
+        if (!file.exists()) {
+            throw new FileNotFoundException(file.getAbsolutePath());
+        }
+        Properties props = new Properties();
+        InputStream is = new FileInputStream(file);
+        props.load(is);
+        is.close();
+
+        String framework = props.getProperty(KARAF_FRAMEWORK);
+        if (framework == null) {
+            throw new IllegalArgumentException("Property " + KARAF_FRAMEWORK + " must be set in the etc/" + FRAMEWORK_PROPERTIES_FILE_NAME + " configuration file");
+        }
+        String bundle = props.getProperty(KARAF_FRAMEWORK + "." + framework);
+        if (bundle == null) {
+            throw new IllegalArgumentException("Property " + KARAF_FRAMEWORK + "." + framework + " must be set in the etc/" + FRAMEWORK_PROPERTIES_FILE_NAME + " configuration file");
+        }
+        File bundleFile = new File(home, bundle);
+        if (!bundleFile.exists()) {
+            throw new FileNotFoundException(bundleFile.getAbsolutePath());
+        }
+
+        URLClassLoader classLoader = (URLClassLoader) Bootstrap.class.getClassLoader();
+        Method mth = URLClassLoader.class.getDeclaredMethod("addURL", URL.class);
+        mth.setAccessible(true);
+        mth.invoke(classLoader, bundleFile.toURL());
+    }
 }
diff --git a/karaf/pom.xml b/karaf/pom.xml
index 14021b5..fdcaf2a 100644
--- a/karaf/pom.xml
+++ b/karaf/pom.xml
@@ -44,9 +44,7 @@
         <module>management</module>
         <module>webconsole</module>
         <module>assembly</module>
-        <!--
         <module>demos</module>
-        -->
         <module>itests</module>
         <module>tooling</module>
     </modules>