You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by il...@apache.org on 2012/01/03 12:23:59 UTC
svn commit: r1226743 - in /cocoon/cocoon3/trunk:
cocoon-archetype-block/src/main/resources/archetype-resources/
cocoon-sample-webapp/src/test/java/org/apache/cocoon/it/
cocoon-sample-wicket-webapp/src/main/java/org/apache/cocoon/sample/wicket/
cocoon-s...
Author: ilgrosso
Date: Tue Jan 3 11:23:58 2012
New Revision: 1226743
URL: http://svn.apache.org/viewvc?rev=1226743&view=rev
Log:
COCOON3-86
Added:
cocoon/cocoon3/trunk/cocoon-sample-wicket-webapp/src/main/webapp/sitemap.xmap
- copied unchanged from r1226360, cocoon/cocoon3/trunk/cocoon-sample-wicket-webapp/src/main/webapp/sitemap.xmap.xml
cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/read/favicon.ico (with props)
cocoon/cocoon3/trunk/cocoon-wicket/src/main/java/org/apache/cocoon/wicket/markup/
cocoon/cocoon3/trunk/cocoon-wicket/src/main/java/org/apache/cocoon/wicket/markup/html/
cocoon/cocoon3/trunk/cocoon-wicket/src/main/java/org/apache/cocoon/wicket/markup/html/CocoonSAXPipelineComponent.java
- copied, changed from r1226360, cocoon/cocoon3/trunk/cocoon-sample-wicket-webapp/src/main/java/org/apache/cocoon/sample/wicket/CocoonSAXPipeline.java
cocoon/cocoon3/trunk/cocoon-wicket/src/main/java/org/apache/cocoon/wicket/request/ (with props)
cocoon/cocoon3/trunk/cocoon-wicket/src/main/java/org/apache/cocoon/wicket/request/CocoonSitemapRequestHandler.java
- copied, changed from r1226360, cocoon/cocoon3/trunk/cocoon-wicket/src/main/java/org/apache/cocoon/wicket/target/CocoonSitemapRequestTarget.java
cocoon/cocoon3/trunk/cocoon-wicket/src/main/java/org/apache/cocoon/wicket/request/CocoonSitemapRequestMapper.java
- copied, changed from r1226360, cocoon/cocoon3/trunk/cocoon-wicket/src/main/java/org/apache/cocoon/wicket/target/CocoonSitemap.java
cocoon/cocoon3/trunk/cocoon-wicket/src/main/java/org/apache/cocoon/wicket/request/CocoonWicketRequestWrapper.java
cocoon/cocoon3/trunk/cocoon-wicket/src/main/java/org/apache/cocoon/wicket/request/CocoonWicketRuntimeException.java
cocoon/cocoon3/trunk/cocoon-wicket/src/main/java/org/apache/cocoon/wicket/sitemap/CocoonWicketHttpServletResponse.java
cocoon/cocoon3/trunk/cocoon-wicket/src/main/java/org/apache/cocoon/wicket/sitemap/CocoonWicketServletContext.java
Removed:
cocoon/cocoon3/trunk/cocoon-sample-wicket-webapp/src/main/java/org/apache/cocoon/sample/wicket/CocoonSAXPipeline.java
cocoon/cocoon3/trunk/cocoon-sample-wicket-webapp/src/main/webapp/sitemap.xmap.xml
cocoon/cocoon3/trunk/cocoon-wicket/src/main/java/org/apache/cocoon/wicket/target/
Modified:
cocoon/cocoon3/trunk/cocoon-archetype-block/src/main/resources/archetype-resources/pom.xml
cocoon/cocoon3/trunk/cocoon-sample-webapp/src/test/java/org/apache/cocoon/it/CocoonHtmlUnitTestCase.java
cocoon/cocoon3/trunk/cocoon-sample-webapp/src/test/java/org/apache/cocoon/it/WicketTest.java
cocoon/cocoon3/trunk/cocoon-sample-wicket-webapp/src/main/java/org/apache/cocoon/sample/wicket/CocoonWicketSampleReloadingWicketFilter.java
cocoon/cocoon3/trunk/cocoon-sample-wicket-webapp/src/main/java/org/apache/cocoon/sample/wicket/CocoonWicketSampleWebApplication.java
cocoon/cocoon3/trunk/cocoon-sample-wicket-webapp/src/main/java/org/apache/cocoon/sample/wicket/Homepage.html
cocoon/cocoon3/trunk/cocoon-sample-wicket-webapp/src/main/java/org/apache/cocoon/sample/wicket/Homepage.java
cocoon/cocoon3/trunk/cocoon-sample-wicket-webapp/src/main/webapp/WEB-INF/applicationContext.xml
cocoon/cocoon3/trunk/cocoon-sample-wicket-webapp/src/main/webapp/WEB-INF/web.xml
cocoon/cocoon3/trunk/cocoon-sample/pom.xml
cocoon/cocoon3/trunk/cocoon-sample/src/main/java/org/apache/cocoon/sample/wicket/CocoonSampleWicketWebapp.java
cocoon/cocoon3/trunk/cocoon-sample/src/main/java/org/apache/cocoon/sample/wicket/HelloWicketPage.java
cocoon/cocoon3/trunk/cocoon-sample/src/main/java/org/apache/cocoon/sample/wicket/OtherPage.java
cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/sitemap.xmap
cocoon/cocoon3/trunk/cocoon-wicket/pom.xml
cocoon/cocoon3/trunk/cocoon-wicket/src/main/java/org/apache/cocoon/wicket/sitemap/WicketReader.java
cocoon/cocoon3/trunk/parent/pom.xml
Modified: cocoon/cocoon3/trunk/cocoon-archetype-block/src/main/resources/archetype-resources/pom.xml
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-archetype-block/src/main/resources/archetype-resources/pom.xml?rev=1226743&r1=1226742&r2=1226743&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-archetype-block/src/main/resources/archetype-resources/pom.xml (original)
+++ cocoon/cocoon3/trunk/cocoon-archetype-block/src/main/resources/archetype-resources/pom.xml Tue Jan 3 11:23:58 2012
@@ -37,6 +37,7 @@
<properties>
<cocoon.version>3.0.0-beta-1-SNAPSHOT</cocoon.version>
+ <spring.version>3.1.0.RELEASE</spring.version>
</properties>
<dependencies>
@@ -61,32 +62,32 @@
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
- <version>3.0.5.RELEASE</version>
+ <version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
- <version>3.0.5.RELEASE</version>
+ <version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
- <version>3.0.5.RELEASE</version>
+ <version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
- <version>3.0.5.RELEASE</version>
+ <version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
- <version>3.0.5.RELEASE</version>
+ <version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
- <version>3.0.5.RELEASE</version>
+ <version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
@@ -96,29 +97,29 @@
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
- <version>1.6.11</version>
+ <version>1.6.12</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
- <version>1.6.11</version>
+ <version>1.6.12</version>
</dependency>
<!-- Logging -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
- <version>1.6.1</version>
+ <version>1.6.4</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
- <version>0.9.29</version>
+ <version>1.0.0</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
- <version>0.9.29</version>
+ <version>1.0.0</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
@@ -129,7 +130,7 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
- <version>1.6.1</version>
+ <version>1.6.4</version>
</dependency>
<!-- Test dependencies -->
@@ -137,11 +138,13 @@
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
- <version>4.8.2</version>
+ <version>4.9</version>
</dependency>
</dependencies>
<build>
+ <outputDirectory>${project.build.directory}/rcl/webapp/WEB-INF/classes</outputDirectory>
+
<plugins>
<plugin>
<artifactId>maven-eclipse-plugin</artifactId>
Modified: cocoon/cocoon3/trunk/cocoon-sample-webapp/src/test/java/org/apache/cocoon/it/CocoonHtmlUnitTestCase.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sample-webapp/src/test/java/org/apache/cocoon/it/CocoonHtmlUnitTestCase.java?rev=1226743&r1=1226742&r2=1226743&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sample-webapp/src/test/java/org/apache/cocoon/it/CocoonHtmlUnitTestCase.java (original)
+++ cocoon/cocoon3/trunk/cocoon-sample-webapp/src/test/java/org/apache/cocoon/it/CocoonHtmlUnitTestCase.java Tue Jan 3 11:23:58 2012
@@ -16,6 +16,8 @@
*/
package org.apache.cocoon.it;
+import com.gargoylesoftware.htmlunit.SubmitMethod;
+import com.gargoylesoftware.htmlunit.WebRequestSettings;
import java.net.URL;
import org.apache.cocoon.tools.it.HtmlUnitTestCase;
@@ -27,7 +29,9 @@ public abstract class CocoonHtmlUnitTest
private static final String BASEURL = "http://localhost:8890";
@Override
- protected URL setupBaseUrl() throws Exception {
+ protected URL setupBaseUrl()
+ throws Exception {
+
String baseUrl = System.getProperty("htmlunit.base-url");
if (baseUrl == null) {
baseUrl = BASEURL;
@@ -35,12 +39,29 @@ public abstract class CocoonHtmlUnitTest
return new URL(baseUrl);
}
- protected HeadMethod loadHeadResponse(String pageURL, int expectedStatusCode) throws Exception {
- URL url = new URL(this.setupBaseUrl(), pageURL);
- HeadMethod method = new HeadMethod(url.toExternalForm());
- HttpClient client = new HttpClient();
- int statusCode = client.executeMethod(method);
+ protected HeadMethod loadHeadResponse(final String pageURL,
+ final int expectedStatusCode)
+ throws Exception {
+
+ final URL url = new URL(this.setupBaseUrl(), pageURL);
+ final HeadMethod method = new HeadMethod(url.toExternalForm());
+ final HttpClient client = new HttpClient();
+ final int statusCode = client.executeMethod(method);
assertEquals(expectedStatusCode, statusCode);
+
return method;
}
+
+ /**
+ * Sends HTTP GET request and loads response object. Handle redirects.
+ */
+ protected void loadResponseWithRedirects(final String pageURL)
+ throws Exception {
+
+ final URL url = new URL(this.setupBaseUrl(), pageURL);
+ this.webClient.setRedirectEnabled(true);
+ this.response = this.webClient.loadWebResponse(
+ new WebRequestSettings(url, SubmitMethod.GET));
+ this.webClient.setRedirectEnabled(false);
+ }
}
Modified: cocoon/cocoon3/trunk/cocoon-sample-webapp/src/test/java/org/apache/cocoon/it/WicketTest.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sample-webapp/src/test/java/org/apache/cocoon/it/WicketTest.java?rev=1226743&r1=1226742&r2=1226743&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sample-webapp/src/test/java/org/apache/cocoon/it/WicketTest.java (original)
+++ cocoon/cocoon3/trunk/cocoon-sample-webapp/src/test/java/org/apache/cocoon/it/WicketTest.java Tue Jan 3 11:23:58 2012
@@ -24,26 +24,34 @@ public class WicketTest extends CocoonHt
/**
* The the Wicket homepage.
*/
- public void testHomepage() throws Exception {
- this.loadResponse("/wicket/hello-wicket");
- assertTrue(this.response.getStatusCode() == 200);
+ public void testHomepage()
+ throws Exception {
+
+ this.loadResponseWithRedirects("/wicket/hello-wicket");
+ assertEquals(200, this.response.getStatusCode());
assertEquals("text/html", this.response.getContentType());
}
/**
* A Wicket redirect
*/
- public void testRedirect() throws Exception {
+ public void testRedirect()
+ throws Exception {
+
this.loadResponse("/wicket/");
- assertTrue(this.response.getStatusCode() == 302);
- assertTrue(this.response.getResponseHeaderValue("Location").endsWith("/wicket/hello-wicket"));
+ assertEquals(302, this.response.getStatusCode());
+ assertTrue(this.response.getResponseHeaderValue("Location").
+ endsWith("/wicket/hello-wicket"));
}
/**
* A Wicket resource
*/
- public void testWicketAjaxResource() throws Exception {
- this.loadResponse("/wicket/resources/org.apache.wicket.ajax.WicketAjaxReference/wicket-ajax.js");
- assertTrue(this.response.getStatusCode() == 200);
+ public void testWicketAjaxResource()
+ throws Exception {
+
+ this.loadResponse("/wicket/resources/org.apache.wicket.ajax."
+ + "WicketAjaxReference/wicket-ajax.js");
+ assertEquals(200, this.response.getStatusCode());
}
}
Modified: cocoon/cocoon3/trunk/cocoon-sample-wicket-webapp/src/main/java/org/apache/cocoon/sample/wicket/CocoonWicketSampleReloadingWicketFilter.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sample-wicket-webapp/src/main/java/org/apache/cocoon/sample/wicket/CocoonWicketSampleReloadingWicketFilter.java?rev=1226743&r1=1226742&r2=1226743&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sample-wicket-webapp/src/main/java/org/apache/cocoon/sample/wicket/CocoonWicketSampleReloadingWicketFilter.java (original)
+++ cocoon/cocoon3/trunk/cocoon-sample-wicket-webapp/src/main/java/org/apache/cocoon/sample/wicket/CocoonWicketSampleReloadingWicketFilter.java Tue Jan 3 11:23:58 2012
@@ -19,9 +19,11 @@ package org.apache.cocoon.sample.wicket;
import org.apache.wicket.application.ReloadingClassLoader;
import org.apache.wicket.protocol.http.ReloadingWicketFilter;
-public class CocoonWicketSampleReloadingWicketFilter extends ReloadingWicketFilter {
+public class CocoonWicketSampleReloadingWicketFilter
+ extends ReloadingWicketFilter {
static {
- ReloadingClassLoader.includePattern("org.apache.cocoon.sample.wicket.*");
+ ReloadingClassLoader.includePattern(
+ "org.apache.cocoon.sample.wicket.*");
}
}
Modified: cocoon/cocoon3/trunk/cocoon-sample-wicket-webapp/src/main/java/org/apache/cocoon/sample/wicket/CocoonWicketSampleWebApplication.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sample-wicket-webapp/src/main/java/org/apache/cocoon/sample/wicket/CocoonWicketSampleWebApplication.java?rev=1226743&r1=1226742&r2=1226743&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sample-wicket-webapp/src/main/java/org/apache/cocoon/sample/wicket/CocoonWicketSampleWebApplication.java (original)
+++ cocoon/cocoon3/trunk/cocoon-sample-wicket-webapp/src/main/java/org/apache/cocoon/sample/wicket/CocoonWicketSampleWebApplication.java Tue Jan 3 11:23:58 2012
@@ -16,11 +16,10 @@
*/
package org.apache.cocoon.sample.wicket;
-import org.apache.cocoon.wicket.target.CocoonSitemap;
+import org.apache.cocoon.wicket.request.CocoonSitemapRequestMapper;
import org.apache.wicket.Application;
import org.apache.wicket.Page;
import org.apache.wicket.protocol.http.WebApplication;
-import org.apache.wicket.request.target.coding.HybridUrlCodingStrategy;
import org.apache.wicket.spring.injection.annot.SpringComponentInjector;
public class CocoonWicketSampleWebApplication extends WebApplication {
@@ -35,11 +34,13 @@ public class CocoonWicketSampleWebApplic
super.init();
// setup Spring
- this.addComponentInstantiationListener(new SpringComponentInjector(this));
+ this.getComponentInstantiationListeners().add(
+ new SpringComponentInjector(this));
// mounts
- this.mount(new CocoonSitemap("/sitemap", "/sitemap.xmap.xml"));
- this.mount(new HybridUrlCodingStrategy("/404.html", Error404Page.class));
+ this.mount(new CocoonSitemapRequestMapper(
+ "/sitemap", "/sitemap.xmap"));
+ this.mountPage("/404.html", Error404Page.class);
// settings
this.getMarkupSettings().setStripWicketTags(true);
Modified: cocoon/cocoon3/trunk/cocoon-sample-wicket-webapp/src/main/java/org/apache/cocoon/sample/wicket/Homepage.html
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sample-wicket-webapp/src/main/java/org/apache/cocoon/sample/wicket/Homepage.html?rev=1226743&r1=1226742&r2=1226743&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sample-wicket-webapp/src/main/java/org/apache/cocoon/sample/wicket/Homepage.html (original)
+++ cocoon/cocoon3/trunk/cocoon-sample-wicket-webapp/src/main/java/org/apache/cocoon/sample/wicket/Homepage.html Tue Jan 3 11:23:58 2012
@@ -18,13 +18,13 @@
under the License.
-->
<!-- $Id: pom.xml 829840 2009-10-26 15:53:36Z reinhard $ -->
-<html lang="de" xmlns="http://www.w3.org/1999/xhtml">
+<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Cocoon/Wicket samples</title>
</head>
<body>
<h1>Cocoon/Wicket samples</h1>
- <h2>Content produced by the CocoonPipelineComponent</h2>
- <p wicket:id="cocoon-pipeline-component">[cocoon-pipeline-component content]</p>
+ <h2>Content produced by the CocoonSAXPipelineComponent</h2>
+ <p wicket:id="cocoon-sax-pipeline-component">[cocoon-sax-pipeline-component content]</p>
</body>
</html>
Modified: cocoon/cocoon3/trunk/cocoon-sample-wicket-webapp/src/main/java/org/apache/cocoon/sample/wicket/Homepage.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sample-wicket-webapp/src/main/java/org/apache/cocoon/sample/wicket/Homepage.java?rev=1226743&r1=1226742&r2=1226743&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sample-wicket-webapp/src/main/java/org/apache/cocoon/sample/wicket/Homepage.java (original)
+++ cocoon/cocoon3/trunk/cocoon-sample-wicket-webapp/src/main/java/org/apache/cocoon/sample/wicket/Homepage.java Tue Jan 3 11:23:58 2012
@@ -16,6 +16,7 @@
*/
package org.apache.cocoon.sample.wicket;
+import org.apache.cocoon.wicket.markup.html.CocoonSAXPipelineComponent;
import org.apache.cocoon.pipeline.NonCachingPipeline;
import org.apache.cocoon.sax.SAXPipelineComponent;
import org.apache.cocoon.sax.component.XMLGenerator;
@@ -25,10 +26,12 @@ import org.apache.wicket.markup.html.Web
public class Homepage extends WebPage {
public Homepage() {
- CocoonSAXPipeline pipeline = new CocoonSAXPipeline("cocoon-pipeline-component",
+ final CocoonSAXPipelineComponent pipeline =
+ new CocoonSAXPipelineComponent("cocoon-sax-pipeline-component",
new NonCachingPipeline<SAXPipelineComponent>());
pipeline.addComponent(new XMLGenerator("<b>hello, Cocoon!</b>"));
- pipeline.addComponent(new XSLTTransformer(this.getClass().getResource("transform.xslt")));
+ pipeline.addComponent(new XSLTTransformer(
+ this.getClass().getResource("transform.xslt")));
this.add(pipeline);
}
Modified: cocoon/cocoon3/trunk/cocoon-sample-wicket-webapp/src/main/webapp/WEB-INF/applicationContext.xml
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sample-wicket-webapp/src/main/webapp/WEB-INF/applicationContext.xml?rev=1226743&r1=1226742&r2=1226743&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sample-wicket-webapp/src/main/webapp/WEB-INF/applicationContext.xml (original)
+++ cocoon/cocoon3/trunk/cocoon-sample-wicket-webapp/src/main/webapp/WEB-INF/applicationContext.xml Tue Jan 3 11:23:58 2012
@@ -27,6 +27,10 @@
http://cocoon.apache.org/schema/configurator
http://cocoon.apache.org/schema/configurator/cocoon-configurator-1.0.1.xsd">
+ <!-- Activate Wicket/Spring integration -->
+ <bean id="cocoonWicketSampleWebApplication"
+ class="org.apache.cocoon.sample.wicket.CocoonWicketSampleWebApplication"/>
+
<!-- Activate Cocoon Spring Configurator -->
<configurator:settings>
<configurator:property name="org.apache.cocoon.logback.loglevel" value="ERROR"/>
Modified: cocoon/cocoon3/trunk/cocoon-sample-wicket-webapp/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sample-wicket-webapp/src/main/webapp/WEB-INF/web.xml?rev=1226743&r1=1226742&r2=1226743&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sample-wicket-webapp/src/main/webapp/WEB-INF/web.xml (original)
+++ cocoon/cocoon3/trunk/cocoon-sample-wicket-webapp/src/main/webapp/WEB-INF/web.xml Tue Jan 3 11:23:58 2012
@@ -25,6 +25,15 @@
<display-name>Apache Cocoon/Wicket Sample</display-name>
+ <context-param>
+ <param-name>configuration</param-name>
+ <param-value>deployment</param-value>
+ </context-param>
+ <context-param>
+ <param-name>contextConfigLocation</param-name>
+ <param-value>WEB-INF/applicationContext.xml</param-value>
+ </context-param>
+
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
@@ -33,15 +42,11 @@
<filter-name>cocoon-wicket-sample</filter-name>
<filter-class>org.apache.cocoon.sample.wicket.CocoonWicketSampleReloadingWicketFilter</filter-class>
<init-param>
- <param-name>applicationClassName</param-name>
- <param-value>org.apache.cocoon.sample.wicket.CocoonWicketSampleWebApplication</param-value>
- </init-param>
- <init-param>
- <param-name>wicket.configuration</param-name>
- <param-value>deployment</param-value>
+ <param-name>applicationFactoryClassName</param-name>
+ <param-value>org.apache.wicket.spring.SpringWebApplicationFactory</param-value>
</init-param>
</filter>
-
+
<filter-mapping>
<filter-name>cocoon-wicket-sample</filter-name>
<url-pattern>/*</url-pattern>
Modified: cocoon/cocoon3/trunk/cocoon-sample/pom.xml
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sample/pom.xml?rev=1226743&r1=1226742&r2=1226743&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sample/pom.xml (original)
+++ cocoon/cocoon3/trunk/cocoon-sample/pom.xml Tue Jan 3 11:23:58 2012
@@ -131,6 +131,8 @@
</dependencies>
<build>
+ <outputDirectory>${project.build.directory}/rcl/webapp/WEB-INF/classes</outputDirectory>
+
<plugins>
<plugin>
<groupId>org.apache.cocoon</groupId>
Modified: cocoon/cocoon3/trunk/cocoon-sample/src/main/java/org/apache/cocoon/sample/wicket/CocoonSampleWicketWebapp.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sample/src/main/java/org/apache/cocoon/sample/wicket/CocoonSampleWicketWebapp.java?rev=1226743&r1=1226742&r2=1226743&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sample/src/main/java/org/apache/cocoon/sample/wicket/CocoonSampleWicketWebapp.java (original)
+++ cocoon/cocoon3/trunk/cocoon-sample/src/main/java/org/apache/cocoon/sample/wicket/CocoonSampleWicketWebapp.java Tue Jan 3 11:23:58 2012
@@ -29,7 +29,9 @@ public class CocoonSampleWicketWebapp ex
@Override
protected void init() {
- this.addComponentInstantiationListener(new SpringComponentInjector(this));
- this.mountBookmarkablePage("hello-wicket", HelloWicketPage.class);
+ this.getComponentInstantiationListeners().add(
+ new SpringComponentInjector(this));
+ this.mountPage("hello-wicket", HelloWicketPage.class);
+
}
}
Modified: cocoon/cocoon3/trunk/cocoon-sample/src/main/java/org/apache/cocoon/sample/wicket/HelloWicketPage.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sample/src/main/java/org/apache/cocoon/sample/wicket/HelloWicketPage.java?rev=1226743&r1=1226742&r2=1226743&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sample/src/main/java/org/apache/cocoon/sample/wicket/HelloWicketPage.java (original)
+++ cocoon/cocoon3/trunk/cocoon-sample/src/main/java/org/apache/cocoon/sample/wicket/HelloWicketPage.java Tue Jan 3 11:23:58 2012
@@ -25,10 +25,14 @@ import org.apache.wicket.markup.html.lin
public class HelloWicketPage extends WebPage {
private AjaxFallbackLink<Object> ajaxFallbackLink;
+
private Label text;
+
private int counter = 1;
public HelloWicketPage() {
+ super();
+
this.add(new Label("message", "hello, wicket!"));
this.text = new Label("text", "text-1");
this.text.setOutputMarkupId(true);
@@ -39,9 +43,10 @@ public class HelloWicketPage extends Web
private static final long serialVersionUID = 1L;
@Override
- public void onClick(AjaxRequestTarget target) {
- HelloWicketPage.this.text.setDefaultModelObject("text-" + ++HelloWicketPage.this.counter);
- target.addComponent(HelloWicketPage.this.text);
+ public void onClick(final AjaxRequestTarget target) {
+ HelloWicketPage.this.text.setDefaultModelObject(
+ "text-" + ++HelloWicketPage.this.counter);
+ target.add(HelloWicketPage.this.text);
}
};
this.add(this.ajaxFallbackLink);
Modified: cocoon/cocoon3/trunk/cocoon-sample/src/main/java/org/apache/cocoon/sample/wicket/OtherPage.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sample/src/main/java/org/apache/cocoon/sample/wicket/OtherPage.java?rev=1226743&r1=1226742&r2=1226743&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sample/src/main/java/org/apache/cocoon/sample/wicket/OtherPage.java (original)
+++ cocoon/cocoon3/trunk/cocoon-sample/src/main/java/org/apache/cocoon/sample/wicket/OtherPage.java Tue Jan 3 11:23:58 2012
@@ -22,6 +22,8 @@ import org.apache.wicket.markup.html.lin
public class OtherPage extends WebPage {
public OtherPage() {
+ super();
+
this.add(new Link<Object>("link") {
private static final long serialVersionUID = 1L;
Added: cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/read/favicon.ico
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/read/favicon.ico?rev=1226743&view=auto
==============================================================================
Binary file - no diff available.
Propchange: cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/read/favicon.ico
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Modified: cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/sitemap.xmap
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/sitemap.xmap?rev=1226743&r1=1226742&r2=1226743&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/sitemap.xmap (original)
+++ cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/sitemap.xmap Tue Jan 3 11:23:58 2012
@@ -39,7 +39,10 @@
<map:match pattern="images/{filename}.gif">
<map:read src="read/{map:filename}.gif" />
</map:match>
- </map:pipeline>
+ <map:match pattern="favicon.ico">
+ <map:read src="read/favicon.ico" />
+ </map:match>
+ </map:pipeline>
<!-- ~~~~~~~~~~~~~~~~ sax pipelines ~~~~~~~~~~~~~~~ -->
<map:pipeline jmx-group-name="sax">
Modified: cocoon/cocoon3/trunk/cocoon-wicket/pom.xml
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-wicket/pom.xml?rev=1226743&r1=1226742&r2=1226743&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-wicket/pom.xml (original)
+++ cocoon/cocoon3/trunk/cocoon-wicket/pom.xml Tue Jan 3 11:23:58 2012
@@ -52,6 +52,7 @@
<dependency>
<groupId>org.apache.wicket</groupId>
<artifactId>wicket</artifactId>
+ <type>pom</type>
</dependency>
<dependency>
<groupId>org.apache.wicket</groupId>
Copied: cocoon/cocoon3/trunk/cocoon-wicket/src/main/java/org/apache/cocoon/wicket/markup/html/CocoonSAXPipelineComponent.java (from r1226360, cocoon/cocoon3/trunk/cocoon-sample-wicket-webapp/src/main/java/org/apache/cocoon/sample/wicket/CocoonSAXPipeline.java)
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-wicket/src/main/java/org/apache/cocoon/wicket/markup/html/CocoonSAXPipelineComponent.java?p2=cocoon/cocoon3/trunk/cocoon-wicket/src/main/java/org/apache/cocoon/wicket/markup/html/CocoonSAXPipelineComponent.java&p1=cocoon/cocoon3/trunk/cocoon-sample-wicket-webapp/src/main/java/org/apache/cocoon/sample/wicket/CocoonSAXPipeline.java&r1=1226360&r2=1226743&rev=1226743&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sample-wicket-webapp/src/main/java/org/apache/cocoon/sample/wicket/CocoonSAXPipeline.java (original)
+++ cocoon/cocoon3/trunk/cocoon-wicket/src/main/java/org/apache/cocoon/wicket/markup/html/CocoonSAXPipelineComponent.java Tue Jan 3 11:23:58 2012
@@ -14,19 +14,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-/**
- *
- */
-package org.apache.cocoon.sample.wicket;
+package org.apache.cocoon.wicket.markup.html;
import java.io.ByteArrayOutputStream;
import java.util.Map;
import java.util.Properties;
-
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-
import org.apache.cocoon.configuration.Settings;
import org.apache.cocoon.pipeline.Pipeline;
import org.apache.cocoon.pipeline.ProcessingException;
@@ -34,16 +29,14 @@ import org.apache.cocoon.sax.SAXPipeline
import org.apache.cocoon.sax.SAXProducer;
import org.apache.cocoon.sax.component.XMLSerializer;
import org.apache.cocoon.servlet.RequestProcessor;
-import org.apache.wicket.RequestCycle;
import org.apache.wicket.markup.ComponentTag;
import org.apache.wicket.markup.MarkupStream;
import org.apache.wicket.markup.html.WebComponent;
import org.apache.wicket.protocol.http.WebApplication;
-import org.apache.wicket.protocol.http.WebRequest;
-import org.apache.wicket.protocol.http.WebResponse;
+import org.apache.wicket.request.cycle.RequestCycle;
import org.apache.wicket.spring.injection.annot.SpringBean;
-public class CocoonSAXPipeline extends WebComponent {
+public class CocoonSAXPipelineComponent extends WebComponent {
private static final long serialVersionUID = 1L;
@@ -52,41 +45,53 @@ public class CocoonSAXPipeline extends W
@SpringBean
private Settings settings;
- CocoonSAXPipeline(String id, Pipeline<SAXPipelineComponent> pipeline) {
+ public CocoonSAXPipelineComponent(final String id,
+ final Pipeline<SAXPipelineComponent> pipeline) {
+
super(id);
this.pipeline = pipeline;
}
- public void addComponent(SAXProducer component) {
+ public void addComponent(final SAXProducer component) {
this.pipeline.addComponent(component);
}
@Override
- protected void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag) {
+ public void onComponentTagBody(final MarkupStream markupStream,
+ final ComponentTag openTag) {
+
this.pipeline.addComponent(createXMLSerializer());
- HttpServletRequest request = ((WebRequest) RequestCycle.get().getRequest()).getHttpServletRequest();
- HttpServletResponse response = ((WebResponse) RequestCycle.get().getResponse()).getHttpServletResponse();
- ServletContext servletContext = WebApplication.get().getServletContext();
- Map<String, Object> parameters = RequestProcessor.prepareParameters(request, response, this.settings,
- servletContext);
+ final HttpServletRequest request =
+ (HttpServletRequest) RequestCycle.get().
+ getRequest().getContainerRequest();
+ final HttpServletResponse response =
+ (HttpServletResponse) RequestCycle.get().
+ getResponse().getContainerResponse();
+ final ServletContext servletContext =
+ WebApplication.get().getServletContext();
+ final Map<String, Object> parameters =
+ RequestProcessor.prepareParameters(request, response,
+ this.settings, servletContext);
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ final ByteArrayOutputStream baos = new ByteArrayOutputStream();
this.pipeline.setup(baos, parameters);
try {
this.pipeline.execute();
} catch (Exception e) {
- throw new ProcessingException("Error while execution a Cocoon pipeline.", e);
+ throw new ProcessingException(
+ "Error while execution a Cocoon pipeline.", e);
}
- this.replaceComponentTagBody(markupStream, openTag, new String(baos.toByteArray()));
+ this.replaceComponentTagBody(markupStream, openTag,
+ new String(baos.toByteArray()));
}
private static XMLSerializer createXMLSerializer() {
- XMLSerializer xmlSerializer = new XMLSerializer();
+ final XMLSerializer xmlSerializer = new XMLSerializer();
- Properties format = new Properties();
+ final Properties format = new Properties();
format.put("encoding", "UTF-8");
format.put("method", "xml");
format.put("omit-xml-declaration", "yes");
Propchange: cocoon/cocoon3/trunk/cocoon-wicket/src/main/java/org/apache/cocoon/wicket/request/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue Jan 3 11:23:58 2012
@@ -0,0 +1 @@
+.CocoonSitemapRequestHandler.java.rej.swp
Copied: cocoon/cocoon3/trunk/cocoon-wicket/src/main/java/org/apache/cocoon/wicket/request/CocoonSitemapRequestHandler.java (from r1226360, cocoon/cocoon3/trunk/cocoon-wicket/src/main/java/org/apache/cocoon/wicket/target/CocoonSitemapRequestTarget.java)
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-wicket/src/main/java/org/apache/cocoon/wicket/request/CocoonSitemapRequestHandler.java?p2=cocoon/cocoon3/trunk/cocoon-wicket/src/main/java/org/apache/cocoon/wicket/request/CocoonSitemapRequestHandler.java&p1=cocoon/cocoon3/trunk/cocoon-wicket/src/main/java/org/apache/cocoon/wicket/target/CocoonSitemapRequestTarget.java&r1=1226360&r2=1226743&rev=1226743&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-wicket/src/main/java/org/apache/cocoon/wicket/target/CocoonSitemapRequestTarget.java (original)
+++ cocoon/cocoon3/trunk/cocoon-wicket/src/main/java/org/apache/cocoon/wicket/request/CocoonSitemapRequestHandler.java Tue Jan 3 11:23:58 2012
@@ -14,87 +14,78 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.cocoon.wicket.target;
+package org.apache.cocoon.wicket.request;
import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletRequestWrapper;
+import javax.servlet.http.HttpServletResponse;
import org.apache.cocoon.servlet.RequestProcessor;
import org.apache.cocoon.servlet.RequestProcessor.InvalidBaseUrlException;
import org.apache.cocoon.servlet.RequestProcessor.SitemapInitializationException;
import org.apache.cocoon.servlet.RequestProcessor.SitemapNotFoundException;
import org.apache.cocoon.sitemap.NoMatchingPipelineException;
import org.apache.cocoon.spring.configurator.WebAppContextUtils;
-import org.apache.wicket.IRequestTarget;
-import org.apache.wicket.RequestCycle;
import org.apache.wicket.protocol.http.WebApplication;
-import org.apache.wicket.protocol.http.WebRequest;
-import org.apache.wicket.protocol.http.WebResponse;
-import org.apache.wicket.protocol.http.request.WebErrorCodeResponseTarget;
+import org.apache.wicket.request.IRequestCycle;
+import org.apache.wicket.request.IRequestHandler;
+import org.apache.wicket.request.http.handler.ErrorCodeRequestHandler;
import org.apache.wicket.settings.IExceptionSettings;
-public class CocoonSitemapRequestTarget implements IRequestTarget {
+public class CocoonSitemapRequestHandler implements IRequestHandler {
- private RequestProcessor requestProcessor;
private final String mountPath;
- public CocoonSitemapRequestTarget(final String sitemapPath, String mountPath) {
+ private RequestProcessor requestProcessor;
+
+ public CocoonSitemapRequestHandler(final String sitemapPath,
+ final String mountPath) {
+
this.mountPath = mountPath;
synchronized (this) {
try {
- this.requestProcessor = new RequestProcessor(WebApplication.get().getServletContext(), sitemapPath,
+ this.requestProcessor = new RequestProcessor(
+ WebApplication.get().getServletContext(), sitemapPath,
WebAppContextUtils.getCurrentWebApplicationContext());
} catch (SitemapNotFoundException e) {
- throw new CocoonRuntimeException("Can't initialize Cocoon sitemap.", e);
+ throw new CocoonWicketRuntimeException(
+ "Can't initialize Cocoon sitemap.", e);
} catch (InvalidBaseUrlException e) {
- throw new CocoonRuntimeException("Invalid base URL for the Cocoon sitemap.", e);
+ throw new CocoonWicketRuntimeException(
+ "Invalid base URL for the Cocoon sitemap.", e);
} catch (SitemapInitializationException e) {
- throw new CocoonRuntimeException("Can't initialize Cocoon sitemap.", e);
+ throw new CocoonWicketRuntimeException(
+ "Can't initialize Cocoon sitemap.", e);
}
}
}
- public void detach(RequestCycle requestCycle) {
+ public String getMountPath() {
+ return mountPath;
+ }
+
+ @Override
+ public void detach(final IRequestCycle requestCycle) {
// do nothing
}
- public void respond(RequestCycle requestCycle) {
+ @Override
+ public void respond(final IRequestCycle requestCycle) {
try {
- HttpServletRequest request = new CocoonWicketRequestWrapper(((WebRequest) requestCycle.getRequest())
- .getHttpServletRequest());
- this.requestProcessor.service(request,
- ((WebResponse) requestCycle.getResponse()).getHttpServletResponse());
+ final HttpServletRequest request = new CocoonWicketRequestWrapper(
+ (HttpServletRequest) requestCycle.getRequest().
+ getContainerRequest(), this);
+ final HttpServletResponse response =
+ (HttpServletResponse) requestCycle.getResponse().
+ getContainerResponse();
+ this.requestProcessor.service(request, response);
} catch (NoMatchingPipelineException e) {
- WebApplication.get().getExceptionSettings().setUnexpectedExceptionDisplay(
+ WebApplication.get().getExceptionSettings().
+ setUnexpectedExceptionDisplay(
IExceptionSettings.SHOW_INTERNAL_ERROR_PAGE);
- RequestCycle.get().setRequestTarget(new WebErrorCodeResponseTarget(404));
+ new ErrorCodeRequestHandler(404).respond(requestCycle);
} catch (Exception e) {
- throw new CocoonRuntimeException("Error occurred while executing a Cocoon sitemap.", e);
- }
- }
-
- public static class CocoonRuntimeException extends RuntimeException {
-
- private static final long serialVersionUID = 1L;
-
- public CocoonRuntimeException(String msg, Throwable cause) {
- super(msg, cause);
- }
- }
-
- private class CocoonWicketRequestWrapper extends HttpServletRequestWrapper {
-
- private final HttpServletRequest request;
-
- public CocoonWicketRequestWrapper(HttpServletRequest request) {
- super(request);
- this.request = request;
- }
-
- @Override
- public String getServletPath() {
- return this.request.getServletPath().substring(
- CocoonSitemapRequestTarget.this.mountPath.length());
+ throw new CocoonWicketRuntimeException(
+ "Error occurred while executing a Cocoon sitemap.", e);
}
}
-}
+}
\ No newline at end of file
Copied: cocoon/cocoon3/trunk/cocoon-wicket/src/main/java/org/apache/cocoon/wicket/request/CocoonSitemapRequestMapper.java (from r1226360, cocoon/cocoon3/trunk/cocoon-wicket/src/main/java/org/apache/cocoon/wicket/target/CocoonSitemap.java)
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-wicket/src/main/java/org/apache/cocoon/wicket/request/CocoonSitemapRequestMapper.java?p2=cocoon/cocoon3/trunk/cocoon-wicket/src/main/java/org/apache/cocoon/wicket/request/CocoonSitemapRequestMapper.java&p1=cocoon/cocoon3/trunk/cocoon-wicket/src/main/java/org/apache/cocoon/wicket/target/CocoonSitemap.java&r1=1226360&r2=1226743&rev=1226743&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-wicket/src/main/java/org/apache/cocoon/wicket/target/CocoonSitemap.java (original)
+++ cocoon/cocoon3/trunk/cocoon-wicket/src/main/java/org/apache/cocoon/wicket/request/CocoonSitemapRequestMapper.java Tue Jan 3 11:23:58 2012
@@ -14,32 +14,59 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.cocoon.wicket.target;
+package org.apache.cocoon.wicket.request;
-import org.apache.wicket.IRequestTarget;
-import org.apache.wicket.request.RequestParameters;
-import org.apache.wicket.request.target.coding.AbstractRequestTargetUrlCodingStrategy;
+import javax.servlet.http.HttpServletRequest;
+import org.apache.wicket.request.IRequestHandler;
+import org.apache.wicket.request.IRequestMapper;
+import org.apache.wicket.request.Request;
+import org.apache.wicket.request.Url;
+import org.apache.wicket.request.mapper.AbstractMapper;
-public class CocoonSitemap extends AbstractRequestTargetUrlCodingStrategy {
+public class CocoonSitemapRequestMapper extends AbstractMapper
+ implements IRequestMapper {
private final String sitemapPath;
+
private final String mountPath;
- public CocoonSitemap(final String mountPath, final String sitemapPath) {
- super(mountPath);
+ public CocoonSitemapRequestMapper(final String mountPath,
+ final String sitemapPath) {
+
+ super();
+
this.mountPath = mountPath;
this.sitemapPath = sitemapPath;
}
- public IRequestTarget decode(RequestParameters requestParameters) {
- return new CocoonSitemapRequestTarget(this.sitemapPath, this.mountPath);
+ @Override
+ public int getCompatibilityScore(final Request rqst) {
+ return 0; // pages always have priority over cocoon sitemap resources
}
- public CharSequence encode(IRequestTarget requestTarget) {
- return null;
+ @Override
+ public IRequestHandler mapRequest(final Request request) {
+ IRequestHandler handler = null;
+
+ final String requestURI =
+ ((HttpServletRequest) request.getContainerRequest()).
+ getRequestURI();
+ if (requestURI.startsWith(this.mountPath)) {
+ handler = new CocoonSitemapRequestHandler(
+ this.sitemapPath, this.mountPath);
+ }
+
+ return handler;
}
- public boolean matches(IRequestTarget requestTarget) {
- return false;
+ @Override
+ public Url mapHandler(final IRequestHandler requestHandler) {
+ Url url = null;
+ if (requestHandler instanceof CocoonSitemapRequestHandler) {
+ url = new Url();
+ url.getSegments().add(this.mountPath);
+ }
+
+ return url;
}
-}
+}
\ No newline at end of file
Added: cocoon/cocoon3/trunk/cocoon-wicket/src/main/java/org/apache/cocoon/wicket/request/CocoonWicketRequestWrapper.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-wicket/src/main/java/org/apache/cocoon/wicket/request/CocoonWicketRequestWrapper.java?rev=1226743&view=auto
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-wicket/src/main/java/org/apache/cocoon/wicket/request/CocoonWicketRequestWrapper.java (added)
+++ cocoon/cocoon3/trunk/cocoon-wicket/src/main/java/org/apache/cocoon/wicket/request/CocoonWicketRequestWrapper.java Tue Jan 3 11:23:58 2012
@@ -0,0 +1,42 @@
+/*
+ * 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.cocoon.wicket.request;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletRequestWrapper;
+
+class CocoonWicketRequestWrapper extends HttpServletRequestWrapper {
+
+ private final HttpServletRequest request;
+
+ private CocoonSitemapRequestHandler outer;
+
+ public CocoonWicketRequestWrapper(final HttpServletRequest request,
+ final CocoonSitemapRequestHandler outer) {
+
+ super(request);
+
+ this.outer = outer;
+ this.request = request;
+ }
+
+ @Override
+ public String getServletPath() {
+ return this.request.getServletPath().substring(
+ outer.getMountPath().length());
+ }
+}
Added: cocoon/cocoon3/trunk/cocoon-wicket/src/main/java/org/apache/cocoon/wicket/request/CocoonWicketRuntimeException.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-wicket/src/main/java/org/apache/cocoon/wicket/request/CocoonWicketRuntimeException.java?rev=1226743&view=auto
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-wicket/src/main/java/org/apache/cocoon/wicket/request/CocoonWicketRuntimeException.java (added)
+++ cocoon/cocoon3/trunk/cocoon-wicket/src/main/java/org/apache/cocoon/wicket/request/CocoonWicketRuntimeException.java Tue Jan 3 11:23:58 2012
@@ -0,0 +1,28 @@
+/*
+ * 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.cocoon.wicket.request;
+
+public class CocoonWicketRuntimeException extends RuntimeException {
+
+ private static final long serialVersionUID = 1L;
+
+ public CocoonWicketRuntimeException(
+ final String msg, final Throwable cause) {
+
+ super(msg, cause);
+ }
+}
Added: cocoon/cocoon3/trunk/cocoon-wicket/src/main/java/org/apache/cocoon/wicket/sitemap/CocoonWicketHttpServletResponse.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-wicket/src/main/java/org/apache/cocoon/wicket/sitemap/CocoonWicketHttpServletResponse.java?rev=1226743&view=auto
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-wicket/src/main/java/org/apache/cocoon/wicket/sitemap/CocoonWicketHttpServletResponse.java (added)
+++ cocoon/cocoon3/trunk/cocoon-wicket/src/main/java/org/apache/cocoon/wicket/sitemap/CocoonWicketHttpServletResponse.java Tue Jan 3 11:23:58 2012
@@ -0,0 +1,70 @@
+/*
+ * 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.cocoon.wicket.sitemap;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.PrintWriter;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpServletResponseWrapper;
+
+class CocoonWicketHttpServletResponse extends HttpServletResponseWrapper {
+
+ private final OutputStream outputStream;
+
+ private final PrintWriter printWriter;
+
+ public CocoonWicketHttpServletResponse(final HttpServletResponse response,
+ final OutputStream outputStream) {
+
+ super(response);
+ this.outputStream = outputStream;
+ this.printWriter = new PrintWriter(this.outputStream, true);
+ }
+
+ @Override
+ public void flushBuffer()
+ throws IOException {
+
+ outputStream.flush();
+ printWriter.flush();
+ super.flushBuffer();
+ }
+
+ @Override
+ public ServletOutputStream getOutputStream()
+ throws IOException {
+
+ return new ServletOutputStream() {
+
+ @Override
+ public void write(final int b)
+ throws IOException {
+
+ outputStream.write(b);
+ }
+ };
+ }
+
+ @Override
+ public PrintWriter getWriter()
+ throws IOException {
+
+ return this.printWriter;
+ }
+}
Added: cocoon/cocoon3/trunk/cocoon-wicket/src/main/java/org/apache/cocoon/wicket/sitemap/CocoonWicketServletContext.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-wicket/src/main/java/org/apache/cocoon/wicket/sitemap/CocoonWicketServletContext.java?rev=1226743&view=auto
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-wicket/src/main/java/org/apache/cocoon/wicket/sitemap/CocoonWicketServletContext.java (added)
+++ cocoon/cocoon3/trunk/cocoon-wicket/src/main/java/org/apache/cocoon/wicket/sitemap/CocoonWicketServletContext.java Tue Jan 3 11:23:58 2012
@@ -0,0 +1,190 @@
+/*
+ * 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.cocoon.wicket.sitemap;
+
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.Set;
+import javax.servlet.RequestDispatcher;
+import javax.servlet.Servlet;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import org.apache.cocoon.servletservice.ServletServiceContext;
+import org.apache.commons.io.IOUtils;
+
+class CocoonWicketServletContext implements ServletContext {
+
+ private final String basePath;
+
+ private final ServletServiceContext ssContext;
+
+ public CocoonWicketServletContext(
+ final ServletServiceContext ssContext,
+ final String basPath) {
+
+ this.ssContext = ssContext;
+ this.basePath = basPath;
+ }
+
+ @Override
+ public Object getAttribute(final String name) {
+ return this.ssContext.getAttribute(name);
+ }
+
+ @Override
+ public Enumeration<String> getAttributeNames() {
+ return this.ssContext.getAttributeNames();
+ }
+
+ @Override
+ public ServletContext getContext(final String uripath) {
+ return this.ssContext.getContext(uripath);
+ }
+
+ @Override
+ public String getInitParameter(final String name) {
+ return this.ssContext.getInitParameter(name);
+ }
+
+ @Override
+ public Enumeration<String> getInitParameterNames() {
+ return this.ssContext.getInitParameterNames();
+ }
+
+ @Override
+ public int getMajorVersion() {
+ return this.ssContext.getMajorVersion();
+ }
+
+ @Override
+ public String getMimeType(final String file) {
+ return this.ssContext.getMimeType(file);
+ }
+
+ @Override
+ public int getMinorVersion() {
+ return this.ssContext.getMinorVersion();
+ }
+
+ @Override
+ public RequestDispatcher getNamedDispatcher(final String name) {
+ return this.ssContext.getNamedDispatcher(name);
+ }
+
+ @Override
+ public String getRealPath(final String path) {
+ return this.ssContext.getRealPath(path);
+ }
+
+ @Override
+ public RequestDispatcher getRequestDispatcher(final String path) {
+ return this.ssContext.getRequestDispatcher(path);
+ }
+
+ @Override
+ public URL getResource(final String path)
+ throws MalformedURLException {
+
+ // Get resource from classpath, not via ServletServiceContext, otherwise
+ // Wicket resources (HTML, JS, ...) won't be loaded
+ return getClass().getResource(path);
+ }
+
+ @Override
+ public InputStream getResourceAsStream(final String path) {
+ if ("/WEB-INF/web.xml".equals(path)) {
+ final String filterDefinition =
+ "<web-app><filter-mapping><filter-name>"
+ + WicketReader.WICKET_FILTER_NAME
+ + "</filter-name><url-pattern>"
+ + this.basePath + "/*</url-pattern>"
+ + "</filter-mapping></web-app>";
+ return IOUtils.toInputStream(filterDefinition);
+ }
+ return this.ssContext.getResourceAsStream(path);
+ }
+
+ @Override
+ public Set<String> getResourcePaths(final String path) {
+ return this.ssContext.getResourcePaths(path);
+ }
+
+ @Override
+ public String getServerInfo() {
+ return this.ssContext.getServerInfo();
+ }
+
+ @Deprecated
+ @Override
+ public Servlet getServlet(final String name)
+ throws ServletException {
+ return this.ssContext.getServlet(name);
+ }
+
+ @Override
+ public String getServletContextName() {
+ return this.ssContext.getServletContextName();
+ }
+
+ @Deprecated
+ @SuppressWarnings(value = "unchecked")
+ @Override
+ public Enumeration<String> getServletNames() {
+ return this.ssContext.getServletNames();
+ }
+
+ @Deprecated
+ @Override
+ public Enumeration<Servlet> getServlets() {
+ return this.ssContext.getServlets();
+ }
+
+ @Deprecated
+ @Override
+ public void log(final Exception exception, final String msg) {
+ this.ssContext.log(exception, msg);
+ }
+
+ @Override
+ public void log(final String msg) {
+ this.ssContext.log(msg);
+ }
+
+ @Override
+ public void log(final String message, final Throwable throwable) {
+ this.ssContext.log(message, throwable);
+ }
+
+ @Override
+ public void removeAttribute(final String name) {
+ this.ssContext.removeAttribute(name);
+ }
+
+ @Override
+ public void setAttribute(final String name, final Object object) {
+ this.ssContext.setAttribute(name, object);
+ }
+
+ @Override
+ public String getContextPath() {
+ // Current implementation of ServletServiceContext
+ // does not provide getContextPath()
+ return this.basePath;
+ }
+}
Modified: cocoon/cocoon3/trunk/cocoon-wicket/src/main/java/org/apache/cocoon/wicket/sitemap/WicketReader.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-wicket/src/main/java/org/apache/cocoon/wicket/sitemap/WicketReader.java?rev=1226743&r1=1226742&r2=1226743&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-wicket/src/main/java/org/apache/cocoon/wicket/sitemap/WicketReader.java (original)
+++ cocoon/cocoon3/trunk/cocoon-wicket/src/main/java/org/apache/cocoon/wicket/sitemap/WicketReader.java Tue Jan 3 11:23:58 2012
@@ -17,33 +17,21 @@
package org.apache.cocoon.wicket.sitemap;
import java.io.IOException;
-import java.io.InputStream;
import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.PrintWriter;
-import java.net.MalformedURLException;
-import java.net.URL;
import java.util.Collections;
import java.util.Enumeration;
-import java.util.Locale;
import java.util.Map;
-import java.util.Set;
import javax.servlet.FilterConfig;
-import javax.servlet.RequestDispatcher;
-import javax.servlet.Servlet;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
-import javax.servlet.ServletOutputStream;
-import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.cocoon.pipeline.ProcessingException;
import org.apache.cocoon.pipeline.SetupException;
import org.apache.cocoon.pipeline.component.Finisher;
import org.apache.cocoon.pipeline.component.Starter;
-import org.apache.cocoon.servlet.collector.ResponseHeaderCollector;
import org.apache.cocoon.servlet.util.HttpContextHelper;
-import org.apache.commons.io.IOUtils;
+import org.apache.cocoon.servletservice.ServletServiceContext;
import org.apache.wicket.protocol.http.WicketFilter;
import org.apache.wicket.spring.SpringWebApplicationFactory;
@@ -52,7 +40,7 @@ import org.apache.wicket.spring.SpringWe
*/
public class WicketReader implements Starter, Finisher {
- private static final String WICKET_FILTER_NAME = "wicket.filter";
+ public static final String WICKET_FILTER_NAME = "wicket.filter";
private static WicketFilter wicketFilter;
@@ -66,11 +54,13 @@ public class WicketReader implements Sta
private ServletContext servletContext;
+ @Override
public void execute() {
- if ("GET".equalsIgnoreCase(this.request.getMethod()) || "POST".
- equalsIgnoreCase(this.request.getMethod())) {
+ if ("GET".equalsIgnoreCase(this.request.getMethod())
+ || "POST".equalsIgnoreCase(this.request.getMethod())) {
+
try {
- wicketFilter.doGet(this.request, this.response);
+ wicketFilter.doFilter(this.request, this.response, null);
} catch (ServletException e) {
throw new ProcessingException(e);
} catch (IOException e) {
@@ -79,10 +69,12 @@ public class WicketReader implements Sta
}
}
+ @Override
public void finish() {
// nothing to do
}
+ @Override
public String getContentType() {
// no relevance because this is handled by Wicket
return null;
@@ -120,8 +112,8 @@ public class WicketReader implements Sta
this.request = HttpContextHelper.getRequest(parameters);
this.response = HttpContextHelper.getResponse(parameters);
this.servletContext = new CocoonWicketServletContext(
- HttpContextHelper.getServletContext(parameters),
- this.basePath);
+ (ServletServiceContext) HttpContextHelper.getServletContext(
+ parameters), this.basePath);
this.initWicketFilter();
}
@@ -135,6 +127,7 @@ public class WicketReader implements Sta
try {
wicketFilter.init(new FilterConfig() {
+ @Override
public String getFilterName() {
return WICKET_FILTER_NAME;
}
@@ -147,12 +140,13 @@ public class WicketReader implements Sta
return null;
}
+ @Override
public Enumeration<String> getInitParameterNames() {
- return Collections.enumeration(
- Collections.singleton(
+ return Collections.enumeration(Collections.singleton(
"applicationFactoryClassName"));
}
+ @Override
public ServletContext getServletContext() {
return WicketReader.this.servletContext;
}
@@ -162,358 +156,4 @@ public class WicketReader implements Sta
}
}
}
-
- private static class CocoonWicketHttpServletResponse
- implements HttpServletResponse {
-
- private final OutputStream cocoonOutputStream;
-
- private PrintWriter printWriter;
-
- private final HttpServletResponse response;
-
- public CocoonWicketHttpServletResponse(
- final HttpServletResponse response, final OutputStream cocoonOS) {
-
- this.response = response;
- this.cocoonOutputStream = cocoonOS;
- }
-
- @Override
- public void addCookie(final Cookie cookie) {
- this.response.addCookie(cookie);
- }
-
- @Override
- public void addDateHeader(final String name, final long date) {
- this.response.addDateHeader(name, date);
- }
-
- @Override
- public void addHeader(final String name, final String value) {
- this.response.addHeader(name, value);
- }
-
- @Override
- public void addIntHeader(final String name, final int value) {
- this.response.addIntHeader(name, value);
- }
-
- @Override
- public boolean containsHeader(final String name) {
- return this.response.containsHeader(name);
- }
-
- @Deprecated
- @Override
- public String encodeRedirectUrl(final String url) {
- return this.response.encodeRedirectUrl(url);
- }
-
- @Override
- public String encodeRedirectURL(final String url) {
- return this.response.encodeRedirectURL(url);
- }
-
- @Deprecated
- @Override
- public String encodeUrl(final String url) {
- return this.response.encodeUrl(url);
- }
-
- @Override
- public String encodeURL(final String url) {
- return this.response.encodeURL(url);
- }
-
- public void flushBuffer()
- throws IOException {
- this.response.flushBuffer();
- }
-
- public int getBufferSize() {
- return this.response.getBufferSize();
- }
-
- public String getCharacterEncoding() {
- return this.response.getCharacterEncoding();
- }
-
- public String getContentType() {
- return this.response.getContentType();
- }
-
- public Locale getLocale() {
- return this.response.getLocale();
- }
-
- public ServletOutputStream getOutputStream()
- throws IOException {
-
- return new ServletOutputStream() {
-
- @Override
- public void write(final int b)
- throws IOException {
-
- CocoonWicketHttpServletResponse.this.cocoonOutputStream.
- write(b);
- }
- };
- }
-
- public PrintWriter getWriter()
- throws IOException {
- if (this.printWriter == null) {
- this.printWriter = new PrintWriter(new OutputStreamWriter(
- this.cocoonOutputStream), true) {
-
- @Override
- public void write(final char[] buf, final int off,
- final int len) {
-
- super.write(buf, off, len);
- // flush the print-writer because otherwise it never
- // happens at all
- super.flush();
- }
- };
- }
-
- return this.printWriter;
- }
-
- public boolean isCommitted() {
- return this.response.isCommitted();
- }
-
- public void reset() {
- this.response.reset();
- }
-
- public void resetBuffer() {
- this.response.resetBuffer();
- }
-
- @Override
- public void sendError(final int sc)
- throws IOException {
-
- this.response.sendError(sc);
- }
-
- @Override
- public void sendError(final int sc, final String msg)
- throws IOException {
-
- this.response.sendError(sc, msg);
- }
-
- @Override
- public void sendRedirect(final String location)
- throws IOException {
-
- this.response.sendRedirect(location);
- }
-
- @Override
- public void setBufferSize(final int size) {
- this.response.setBufferSize(size);
- }
-
- @Override
- public void setCharacterEncoding(final String charset) {
- this.response.setCharacterEncoding(charset);
- }
-
- @Override
- public void setContentLength(final int len) {
- this.response.setContentLength(len);
- }
-
- @Override
- public void setContentType(final String type) {
- this.response.setContentType(type);
- }
-
- @Override
- public void setDateHeader(final String name, final long date) {
- if ("Last-Modified".equals(name)) {
- ResponseHeaderCollector.setLastModified(date);
- }
- this.response.setDateHeader(name, date);
- }
-
- @Override
- public void setHeader(final String name, final String value) {
- this.response.setHeader(name, value);
- }
-
- @Override
- public void setIntHeader(final String name, final int value) {
- this.response.setIntHeader(name, value);
- }
-
- @Override
- public void setLocale(final Locale loc) {
- this.response.setLocale(loc);
- }
-
- @Override
- public void setStatus(final int sc) {
- this.response.setStatus(sc);
- }
-
- @Override
- @Deprecated
- public void setStatus(final int sc, final String sm) {
- this.response.setStatus(sc, sm);
- }
- }
-
- private static class CocoonWicketServletContext implements ServletContext {
-
- private final String basePath;
-
- private final ServletContext servletContext;
-
- public CocoonWicketServletContext(final ServletContext servletContext,
- final String basPath) {
-
- this.servletContext = servletContext;
- this.basePath = basPath;
- }
-
- @Override
- public Object getAttribute(final String name) {
- return this.servletContext.getAttribute(name);
- }
-
- @Override
- public Enumeration<String> getAttributeNames() {
- return this.servletContext.getAttributeNames();
- }
-
- @Override
- public ServletContext getContext(final String uripath) {
- return this.servletContext.getContext(uripath);
- }
-
- @Override
- public String getInitParameter(final String name) {
- return this.servletContext.getInitParameter(name);
- }
-
- public Enumeration<String> getInitParameterNames() {
- return this.servletContext.getInitParameterNames();
- }
-
- public int getMajorVersion() {
- return this.servletContext.getMajorVersion();
- }
-
- @Override
- public String getMimeType(final String file) {
- return this.servletContext.getMimeType(file);
- }
-
- public int getMinorVersion() {
- return this.servletContext.getMinorVersion();
- }
-
- @Override
- public RequestDispatcher getNamedDispatcher(final String name) {
- return this.servletContext.getNamedDispatcher(name);
- }
-
- @Override
- public String getRealPath(final String path) {
- return this.servletContext.getRealPath(path);
- }
-
- @Override
- public RequestDispatcher getRequestDispatcher(final String path) {
- return this.servletContext.getRequestDispatcher(path);
- }
-
- @Override
- public URL getResource(final String path)
- throws MalformedURLException {
-
- return this.servletContext.getResource(path);
- }
-
- @Override
- public InputStream getResourceAsStream(final String path) {
- if ("/WEB-INF/web.xml".equals(path)) {
- final String filterDefinition =
- "<web-app><filter-mapping><filter-name>"
- + WICKET_FILTER_NAME
- + "</filter-name><url-pattern>" + this.basePath
- + "/*</url-pattern></filter-mapping></web-app>";
- return IOUtils.toInputStream(filterDefinition);
- }
- return this.servletContext.getResourceAsStream(path);
- }
-
- @Override
- public Set<String> getResourcePaths(final String path) {
- return this.servletContext.getResourcePaths(path);
- }
-
- public String getServerInfo() {
- return this.servletContext.getServerInfo();
- }
-
- @Deprecated
- public Servlet getServlet(final String name)
- throws ServletException {
-
- return this.servletContext.getServlet(name);
- }
-
- public String getServletContextName() {
- return this.servletContext.getServletContextName();
- }
-
- @Deprecated
- @SuppressWarnings("unchecked")
- public Enumeration<String> getServletNames() {
- return this.servletContext.getServletNames();
- }
-
- @Deprecated
- public Enumeration<Servlet> getServlets() {
- return this.servletContext.getServlets();
- }
-
- @Deprecated
- public void log(final Exception exception, final String msg) {
- this.servletContext.log(exception, msg);
- }
-
- @Override
- public void log(final String msg) {
- this.servletContext.log(msg);
- }
-
- @Override
- public void log(final String message, final Throwable throwable) {
- this.servletContext.log(message, throwable);
- }
-
- @Override
- public void removeAttribute(final String name) {
- this.servletContext.removeAttribute(name);
- }
-
- @Override
- public void setAttribute(final String name, final Object object) {
- this.servletContext.setAttribute(name, object);
- }
-
- public String getContextPath() {
- return this.servletContext.getContextPath();
- }
- }
}
Modified: cocoon/cocoon3/trunk/parent/pom.xml
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/parent/pom.xml?rev=1226743&r1=1226742&r2=1226743&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/parent/pom.xml (original)
+++ cocoon/cocoon3/trunk/parent/pom.xml Tue Jan 3 11:23:58 2012
@@ -416,12 +416,13 @@
<dependency>
<groupId>org.apache.wicket</groupId>
<artifactId>wicket</artifactId>
- <version>1.4.19</version>
+ <version>1.5.3</version>
+ <type>pom</type>
</dependency>
<dependency>
<groupId>org.apache.wicket</groupId>
<artifactId>wicket-spring</artifactId>
- <version>1.4.19</version>
+ <version>1.5.3</version>
<exclusions>
<exclusion>
<groupId>org.springframework</groupId>