WIP: Examples aufgeteilt
authorKai Moritz <kai@coolibri.de>
Sun, 10 Jun 2012 19:36:53 +0000 (21:36 +0200)
committerKai Moritz <kai@coolibri.de>
Thu, 2 Aug 2012 07:03:26 +0000 (09:03 +0200)
12 files changed:
examples/servlet/src/main/webapp/WEB-INF/web.xml
examples/static/jetty.sh [new file with mode: 0755]
examples/static/pom.xml [new file with mode: 0644]
examples/static/src/main/resources/config.xml [new file with mode: 0644]
examples/static/src/main/resources/log4j.xml [new file with mode: 0644]
examples/static/src/main/webapp/WEB-INF/web.xml [new file with mode: 0644]
examples/static/src/main/webapp/index.html [new file with mode: 0644]
examples/static/src/main/webapp/static/page.html [new file with mode: 0644]
examples/static/src/main/webapp/static/stylesheets.css [new file with mode: 0644]
examples/static/src/test/java/de/halbekunst/cachecontrol/examples/jsp/.JspTest.java.swp [new file with mode: 0644]
examples/static/src/test/java/de/halbekunst/cachecontrol/examples/jsp/StaticTest.java [new file with mode: 0644]
examples/static/tomcat.sh [new file with mode: 0755]

index 64cdaf7..53de033 100644 (file)
 
   <filter-mapping>
     <filter-name>logger</filter-name>
-    <url-pattern>*.jsp</url-pattern>
+    <url-pattern>/test-servlet</url-pattern>
   </filter-mapping>
 
-  <filter-mapping>
-    <filter-name>accelerator</filter-name>
-    <url-pattern>*.html</url-pattern>
-  </filter-mapping>
-  <filter-mapping>
-    <filter-name>accelerator</filter-name>
-    <url-pattern>*.jsp</url-pattern>
-  </filter-mapping>
-  <filter-mapping>
-    <filter-name>accelerator</filter-name>
-    <url-pattern>*.css</url-pattern>
-  </filter-mapping>
   <filter-mapping>
     <filter-name>accelerator</filter-name>
     <url-pattern>/test-servlet</url-pattern>
   </filter-mapping>
-  <filter-mapping>
-    <filter-name>accelerator</filter-name>
-    <url-pattern>/spring/*</url-pattern>
-  </filter-mapping>
 
 
   <!-- Servlet-Definitions -->
     <servlet-class>de.halbekunst.juplo.test.TestServlet</servlet-class>
   </servlet>
 
-  <servlet>
-    <servlet-name>dispatcher-servlet</servlet-name>
-    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
-    <init-param>
-      <param-name>contextConfigLocation</param-name>
-      <param-value>
-      </param-value>
-    </init-param>
-    <load-on-startup>1</load-on-startup>
-  </servlet>
-
 
   <!-- Servlet-Mappings -->
 
@@ -86,9 +59,4 @@
     <url-pattern>/test-servlet</url-pattern>
   </servlet-mapping>
 
-  <servlet-mapping>
-    <servlet-name>dispatcher-servlet</servlet-name>
-    <url-pattern>/spring/*</url-pattern>
-  </servlet-mapping>
-
 </web-app>
diff --git a/examples/static/jetty.sh b/examples/static/jetty.sh
new file mode 100755 (executable)
index 0000000..4950796
--- /dev/null
@@ -0,0 +1,11 @@
+#!/bin/bash
+#
+
+# OutOfMemoryException beim "mvn jetty:run" umgehen und
+# Parameter zum nachträglichen anhängen eines Debuggers
+# setzen
+export MAVEN_OPTS="-Xmx512m -XX:MaxPermSize=256m -XX:-UseGCOverheadLimit -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=4000,server=y,suspend=n"
+
+rm -v src/main/webapp/WEB-INF/lib/juplo*
+
+mvn jetty:run
diff --git a/examples/static/pom.xml b/examples/static/pom.xml
new file mode 100644 (file)
index 0000000..bbe5b9b
--- /dev/null
@@ -0,0 +1,17 @@
+<?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">
+
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>de.halbekunst</groupId>
+    <artifactId>juplo-examples</artifactId>
+    <version>2.0-SNAPSHOT</version>
+  </parent>
+
+  <artifactId>juplo-examples-static</artifactId>
+  <packaging>war</packaging>
+  <name>Juplo - Examples: Static Content</name>
+
+</project>
diff --git a/examples/static/src/main/resources/config.xml b/examples/static/src/main/resources/config.xml
new file mode 100644 (file)
index 0000000..e414ce9
--- /dev/null
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:context="http://www.springframework.org/schema/context"
+       xsi:schemaLocation="
+           http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
+           http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
+
+  <!-- Activates the AspectJ-Weaver -->
+  <context:component-scan base-package="de.halbekunst"/>
+  <context:spring-configured/>
+
+  <bean id="eTag" class="java.lang.String">
+    <constructor-arg value="Hallo Welt!"/>
+  </bean>
+
+  <bean id="weak" class="java.lang.Boolean">
+    <constructor-arg value="true"/>
+  </bean>
+
+  <bean id="lastModified" class="java.lang.Long">
+    <constructor-arg value="1338593731"/>
+  </bean>
+
+  <bean id="cacheSeconds" class="java.lang.Integer">
+    <constructor-arg value="3600"/>
+  </bean>
+
+</beans>
diff --git a/examples/static/src/main/resources/log4j.xml b/examples/static/src/main/resources/log4j.xml
new file mode 100644 (file)
index 0000000..d3414bd
--- /dev/null
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
+
+  <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
+    <layout class="org.apache.log4j.PatternLayout">
+      <param name="ConversionPattern" value="%p - %C{1}.%M(%L) | %m%n"/>
+    </layout>
+  </appender>
+
+  <logger name="de.halbekunst">
+   <level value="trace"/>
+  </logger>
+
+  <root>
+    <level value="info"/>
+    <appender-ref ref="CONSOLE"/>
+  </root>
+
+</log4j:configuration>
diff --git a/examples/static/src/main/webapp/WEB-INF/web.xml b/examples/static/src/main/webapp/WEB-INF/web.xml
new file mode 100644 (file)
index 0000000..9e0b504
--- /dev/null
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
+
+  <!-- Context Configuration locations for Spring XML files -->
+
+  <context-param>
+    <param-name>contextConfigLocation</param-name>
+    <param-value>classpath:/config.xml</param-value>
+  </context-param>
+
+
+  <!-- Listener-Definitions -->
+
+  <listener>
+    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
+  </listener>
+
+
+  <!-- Filter-Definitions -->
+
+  <filter>
+    <filter-name>accelerator</filter-name>
+    <filter-class>de.halbekunst.juplo.cachecontrol.AcceleratorFilter</filter-class>
+  </filter>
+
+  <filter>
+    <filter-name>logger</filter-name>
+    <filter-class>de.halbekunst.juplo.test.LoggingHttpServletResponseFilter</filter-class>
+  </filter>
+
+
+  <!-- Filter-Mappings -->
+
+  <filter-mapping>
+    <filter-name>logger</filter-name>
+    <url-pattern>/static</url-pattern>
+  </filter-mapping>
+
+  <filter-mapping>
+    <filter-name>accelerator</filter-name>
+    <url-pattern>/static</url-pattern>
+  </filter-mapping>
+
+</web-app>
diff --git a/examples/static/src/main/webapp/index.html b/examples/static/src/main/webapp/index.html
new file mode 100644 (file)
index 0000000..107f247
--- /dev/null
@@ -0,0 +1,16 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+
+<html>
+  <head>
+    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+    <title>Examples for Static Content</title>
+    <link rel="stylesheet" type="text/css" media="all" href="/default.css">
+  </head>
+  <body>
+    <h1>Examples for Static Content</h1>
+    <ul>
+      <li><a href="/static/page.html">A plain static HTML-file</a></li>
+      <li><a href="/static/stylesheets.css">A plain static CSS-file</a></li>
+    </ul>
+  </body>
+</html>
diff --git a/examples/static/src/main/webapp/static/page.html b/examples/static/src/main/webapp/static/page.html
new file mode 100644 (file)
index 0000000..f851795
--- /dev/null
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+
+<html>
+  <head>
+    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+    <title>A Static Page</title>
+    <link rel="stylesheet" type="text/css" media="all" href="/static/stylesheets.css">
+  </head>
+  <body>
+    <h1>A Static Page</h1>
+    <p>This page is a static HTML-page</p>
+  </body>
+</html>
diff --git a/examples/static/src/main/webapp/static/stylesheets.css b/examples/static/src/main/webapp/static/stylesheets.css
new file mode 100644 (file)
index 0000000..e04bba2
--- /dev/null
@@ -0,0 +1,7 @@
+body {
+  background-color: #ccc;
+  color: #444;
+}
+h1,h2,h3,h4 {
+  color: #000;
+}
\ No newline at end of file
diff --git a/examples/static/src/test/java/de/halbekunst/cachecontrol/examples/jsp/.JspTest.java.swp b/examples/static/src/test/java/de/halbekunst/cachecontrol/examples/jsp/.JspTest.java.swp
new file mode 100644 (file)
index 0000000..765075a
Binary files /dev/null and b/examples/static/src/test/java/de/halbekunst/cachecontrol/examples/jsp/.JspTest.java.swp differ
diff --git a/examples/static/src/test/java/de/halbekunst/cachecontrol/examples/jsp/StaticTest.java b/examples/static/src/test/java/de/halbekunst/cachecontrol/examples/jsp/StaticTest.java
new file mode 100644 (file)
index 0000000..66a2826
--- /dev/null
@@ -0,0 +1,28 @@
+package de.halbekunst.cachecontrol.examples.jsp;
+
+import de.halbekunst.juplo.test.HttpTestCase;
+import com.meterware.httpunit.WebResponse;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ *
+ * @author kai
+ */
+public class StaticTest extends HttpTestCase {
+
+  private static final Logger log = LoggerFactory.getLogger(StaticTest.class);
+
+
+  public StaticTest() {
+    super("src/main/webapp/WEB-INF/web.xml");
+  }
+
+  @Test
+  public void testStaticContent() throws Exception {
+    WebResponse response = executeRequest("http://localhost:8080/default.css");
+    log.info("Title:\t\t{}", response.getTitle());
+    log.debug("Text:\t\t{}", response.getText());
+  }
+}
diff --git a/examples/static/tomcat.sh b/examples/static/tomcat.sh
new file mode 100755 (executable)
index 0000000..4378a12
--- /dev/null
@@ -0,0 +1,11 @@
+#!/bin/bash
+#
+
+# OutOfMemoryException beim "mvn jetty:run" umgehen und
+# Parameter zum nachträglichen anhängen eines Debuggers
+# setzen
+export MAVEN_OPTS="-Xmx512m -XX:MaxPermSize=256m -XX:-UseGCOverheadLimit -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=4000,server=y,suspend=n"
+
+rm -v src/main/webapp/WEB-INF/lib/juplo*
+
+mvn tomcat:run-war