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/06/19 10:07:51 UTC

svn commit: r1351594 [2/2] - in /karaf/trunk: assemblies/ assemblies/apache-karaf/ assemblies/demos/ demos/ demos/branding/ demos/branding/src/main/filtered-resources/resources/demos/branding/shell/ demos/branding/src/main/resources/org/ demos/branding...

Modified: karaf/trunk/demos/web/pom.xml
URL: http://svn.apache.org/viewvc/karaf/trunk/demos/web/pom.xml?rev=1351594&r1=1351593&r2=1351594&view=diff
==============================================================================
--- karaf/trunk/demos/web/pom.xml (original)
+++ karaf/trunk/demos/web/pom.xml Tue Jun 19 08:07:48 2012
@@ -1,105 +1,162 @@
-<?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/xsd/maven-4.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.karaf.demos</groupId>
-        <artifactId>demos</artifactId>
-        <version>3.0.0-SNAPSHOT</version>
-    </parent>
-
-    <artifactId>org.apache.karaf.demos.web</artifactId>
-    <packaging>pom</packaging>
-    <name>Apache Karaf :: Demos :: Web</name>
-
-    <modules>
-        <module>src/main/resources/resources/demos/web</module>
-        <!--<module>branding-package</module>-->
-    </modules>
-    <build>
-        <resources>
-            <resource>
-                <directory>src/main/resources</directory>
-                <filtering>false</filtering>
-                <excludes>
-                    <exclude>**/target/**</exclude>
-                </excludes>
-            </resource>
-            <resource>
-                <directory>src/main/filtered-resources</directory>
-                <filtering>true</filtering>
-                <includes>
-                    <include>**/*</include>
-                </includes>
-            </resource>
-        </resources>
-        <plugins>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-resources-plugin</artifactId>
-                <!--<configuration>-->
-                    <!--<resources>-->
-                        <!--<resource>src/main/resources</resource>-->
-                    <!--</resources>-->
-                <!--</configuration>-->
-                <executions>
-                    <execution>
-                        <id>process-resources</id>
-                        <phase>process-resources</phase>
-                        <goals>
-                            <goal>resources</goal>
-                        </goals>
-                    </execution>
-                </executions>
-            </plugin>
-            <plugin>
-                <groupId>org.apache.karaf.tooling</groupId>
-                <artifactId>karaf-maven-plugin</artifactId>
-                <version>${project.version}</version>
-                <configuration>
-                    <startLevel>60</startLevel>
-                    <!--<checkDependencyChange>true</checkDependencyChange>-->
-                    <!--<overwriteChangedDependencies>true</overwriteChangedDependencies>-->
-                    <!--<failOnDependencyChange>false</failOnDependencyChange>-->
-                </configuration>
-                <executions>
-                    <execution>
-                        <id>compile</id>
-                        <phase>compile</phase>
-                        <goals>
-                            <goal>features-generate-descriptor</goal>
-                        </goals>
-                    </execution>
-                    <execution>
-                        <id>package</id>
-                        <goals>
-                            <goal>features-create-kar</goal>
-                        </goals>
-                    </execution>
-                </executions>
-            </plugin>
-        </plugins>
-    </build>
-</project>
+<?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/xsd/maven-4.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.karaf.demos</groupId>
+        <artifactId>demos</artifactId>
+        <version>3.0.0-SNAPSHOT</version>
+        <relativePath>../../../../../../../pom.xml</relativePath>
+    </parent>
+
+    <artifactId>web</artifactId>
+    <packaging>war</packaging>
+    <name>Apache Karaf :: Demos :: Web</name>
+
+    <properties>
+        <jetty.port>8080</jetty.port>
+        <maven-jetty-plugin.version>6.1.26</maven-jetty-plugin.version>
+        <geronimo.servlet.version>1.1.2</geronimo.servlet.version>
+
+        <appendedResourcesDirectory>${basedir}/../../etc/appended-resources</appendedResourcesDirectory>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.karaf</groupId>
+            <artifactId>org.osgi.core</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.karaf.jaas</groupId>
+            <artifactId>org.apache.karaf.jaas.boot</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.karaf</groupId>
+            <artifactId>apache-karaf</artifactId>
+            <type>zip</type>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-servlet_2.5_spec</artifactId>
+            <version>${geronimo.servlet.version}</version>
+            <scope>provided</scope>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <configuration>
+                    <source>1.6</source>
+                    <target>1.6</target>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-war-plugin</artifactId>
+                <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>${maven-jetty-plugin.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/>
+                        </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>
+                <executions>
+                    <execution>
+                        <id>unpack-unix</id>
+                        <phase>generate-resources</phase>
+                        <goals>
+                            <goal>unpack</goal>
+                        </goals>
+                        <configuration>
+                            <artifactItems>
+                                <artifactItem>
+                                    <groupId>org.apache.karaf</groupId>
+                                    <artifactId>apache-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>
+                <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-karaf-${project.version}"/>
+                                </move>
+                            </tasks>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>

Added: karaf/trunk/demos/web/src/main/java/org/apache/karaf/web/WebAppListener.java
URL: http://svn.apache.org/viewvc/karaf/trunk/demos/web/src/main/java/org/apache/karaf/web/WebAppListener.java?rev=1351594&view=auto
==============================================================================
--- karaf/trunk/demos/web/src/main/java/org/apache/karaf/web/WebAppListener.java (added)
+++ karaf/trunk/demos/web/src/main/java/org/apache/karaf/web/WebAppListener.java Tue Jun 19 08:07:48 2012
@@ -0,0 +1,62 @@
+/*
+ * 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.karaf.web;
+
+import java.io.File;
+
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+
+import org.apache.karaf.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/karaf").getAbsolutePath();
+			System.err.println("Root: " + root);
+			System.setProperty("karaf.home", root);
+            System.setProperty("karaf.base", root);
+            System.setProperty("karaf.data", root + "/data");
+            System.setProperty("karaf.history", root + "/data/history.txt");
+            System.setProperty("karaf.instances", root + "/instances");
+			System.setProperty("karaf.startLocalConsole", "false");
+			System.setProperty("karaf.startRemoteShell", "true");
+            System.setProperty("karaf.lock", "false");
+			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();
+			}
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+	}
+
+}
\ No newline at end of file

Added: karaf/trunk/demos/web/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/karaf/trunk/demos/web/src/main/webapp/WEB-INF/web.xml?rev=1351594&view=auto
==============================================================================
--- karaf/trunk/demos/web/src/main/webapp/WEB-INF/web.xml (added)
+++ karaf/trunk/demos/web/src/main/webapp/WEB-INF/web.xml Tue Jun 19 08:07:48 2012
@@ -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>Karaf Embedded Example</description>
+  <display-name>Karaf Embedded Example</display-name>
+
+  <listener>
+    <listener-class>org.apache.karaf.web.WebAppListener</listener-class>
+  </listener>
+
+  <welcome-file-list>
+    <welcome-file>index.jsp</welcome-file>
+  </welcome-file-list>
+		
+</web-app>

Added: karaf/trunk/demos/web/src/main/webapp/index.jsp
URL: http://svn.apache.org/viewvc/karaf/trunk/demos/web/src/main/webapp/index.jsp?rev=1351594&view=auto
==============================================================================
--- karaf/trunk/demos/web/src/main/webapp/index.jsp (added)
+++ karaf/trunk/demos/web/src/main/webapp/index.jsp Tue Jun 19 08:07:48 2012
@@ -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 Karaf</title>
+</head>
+<body>
+
+<h2>Welcome!</h2>
+
+<p>
+Welcome to Apache Karaf web application demo
+</p>
+
+<p>
+You can find more information about Karaf on the <a href="http://karaf.apache.org/">Apache Karaf Site</a>
+</p>
+</body>
+</html>
+