Move ServiceMix Kernel trunk into Felix

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@768912 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/karaf/demos/smx4web/src/main/java/org/apache/servicemix/smx4webex/WebAppListener.java b/karaf/demos/smx4web/src/main/java/org/apache/servicemix/smx4webex/WebAppListener.java
new file mode 100644
index 0000000..11e9bbb
--- /dev/null
+++ b/karaf/demos/smx4web/src/main/java/org/apache/servicemix/smx4webex/WebAppListener.java
@@ -0,0 +1,58 @@
+/*
+ * 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.
+ */
+package org.apache.servicemix.smx4webex;
+
+import java.io.File;
+
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+
+import org.apache.servicemix.kernel.main.Main;
+
+public class WebAppListener implements ServletContextListener {
+	
+	private Main main;
+	
+	public void contextInitialized(ServletContextEvent sce) {
+		try {
+			System.err.println("contextInitialized");
+			String root = new File(sce.getServletContext().getRealPath("/") + "WEB-INF/servicemix").getAbsolutePath();
+			System.err.println("Root: " + root);
+			System.setProperty("servicemix.home", root);
+			System.setProperty("servicemix.base", root);
+			System.setProperty("servicemix.startLocalConsole", "false");
+			System.setProperty("servicemix.startRemoteShell", "true");
+			main = new Main(new String[0]);
+			main.launch();
+		} catch (Exception e) {
+			main = null;
+			e.printStackTrace();
+		}
+	}
+
+	public void contextDestroyed(ServletContextEvent sce) {
+		try {
+			System.err.println("contextDestroyed");
+			if (main != null) {
+				main.destroy(false);
+			}
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+	}
+
+}
diff --git a/karaf/demos/smx4web/src/main/webapp/WEB-INF/web.xml b/karaf/demos/smx4web/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000..30f7072
--- /dev/null
+++ b/karaf/demos/smx4web/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+
+<web-app version="2.4"
+         xmlns="http://java.sun.com/xml/ns/j2ee"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         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>
+
+  <listener>
+    <listener-class>org.apache.servicemix.smx4webex.WebAppListener</listener-class>
+  </listener>
+
+  <welcome-file-list>
+    <welcome-file>index.jsp</welcome-file>
+  </welcome-file-list>
+		
+</web-app>
diff --git a/karaf/demos/smx4web/src/main/webapp/index.jsp b/karaf/demos/smx4web/src/main/webapp/index.jsp
new file mode 100644
index 0000000..3734ee9
--- /dev/null
+++ b/karaf/demos/smx4web/src/main/webapp/index.jsp
@@ -0,0 +1,34 @@
+<%--
+    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.
+--%>
+<html>
+<head>
+<title>Apache ServiceMix Kernel</title>
+</head>
+<body>
+
+<h2>Welcome!</h2>
+
+<p>
+Welcome to Apache ServiceMix Kernel 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>
+</p>
+</body>
+</html>
+