You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by re...@apache.org on 2008/04/14 16:28:10 UTC
svn commit: r647814 - in /cocoon/whiteboard/corona/trunk/corona-servlet: ./
src/main/java/org/apache/cocoon/corona/servlet/
src/main/java/org/apache/cocoon/corona/servlet/component/
src/main/java/org/apache/cocoon/corona/servlet/node/ src/main/resource...
Author: reinhard
Date: Mon Apr 14 07:28:00 2008
New Revision: 647814
URL: http://svn.apache.org/viewvc?rev=647814&view=rev
Log:
COCOON-2195
. support controllers in sitemaps
. add mime-type handling (using AOP)
. support for the servlet protocol
. experimental sitemap delegator stuff
. adding more samples
Added:
cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/ServletURLConnection.java (with props)
cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/ServletURLStreamHandler.java (with props)
cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/ServletURLStreamHandlerFactory.java (with props)
cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/SitemapDelegator.java (with props)
cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/component/Controller.java (with props)
cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/component/DefaultControllerComponent.java (with props)
cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/node/MimeTypeCollector.java (with props)
cocoon/whiteboard/corona/trunk/corona-servlet/src/main/resources/sax-pipeline/simple.xslt (with props)
cocoon/whiteboard/corona/trunk/corona-servlet/src/main/resources/xslt/
cocoon/whiteboard/corona/trunk/corona-servlet/src/main/resources/xslt/main.xslt (with props)
cocoon/whiteboard/corona/trunk/corona-servlet/src/main/resources/xslt/sub-file.xslt (with props)
cocoon/whiteboard/corona/trunk/corona-servlet/src/main/resources/xslt/sub-servlet.xslt (with props)
Modified:
cocoon/whiteboard/corona/trunk/corona-servlet/pom.xml
cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/SitemapServlet.java
cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/component/RedirectorComponent.java
cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/component/RequestParametersGenerator.java
cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/node/StatusCodeCollector.java
cocoon/whiteboard/corona/trunk/corona-servlet/src/main/resources/META-INF/cocoon/spring/corona-servlet-component.xml
cocoon/whiteboard/corona/trunk/corona-servlet/src/main/resources/META-INF/cocoon/spring/corona-servlet-node.xml
cocoon/whiteboard/corona/trunk/corona-servlet/src/test/java/org/apache/cocoon/corona/sitemap/SitemapBuilderTest.java
Modified: cocoon/whiteboard/corona/trunk/corona-servlet/pom.xml
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/corona/trunk/corona-servlet/pom.xml?rev=647814&r1=647813&r2=647814&view=diff
==============================================================================
--- cocoon/whiteboard/corona/trunk/corona-servlet/pom.xml (original)
+++ cocoon/whiteboard/corona/trunk/corona-servlet/pom.xml Mon Apr 14 07:28:00 2008
@@ -42,6 +42,13 @@
<artifactId>corona-sitemap</artifactId>
</dependency>
+<!--
+ <dependency>
+ <groupId>org.apache.cocoon</groupId>
+ <artifactId>corona-image</artifactId>
+ </dependency>
+ -->
+
<dependency>
<groupId>org.apache.cocoon</groupId>
<artifactId>cocoon-servlet-service-impl</artifactId>
Added: cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/ServletURLConnection.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/ServletURLConnection.java?rev=647814&view=auto
==============================================================================
--- cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/ServletURLConnection.java (added)
+++ cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/ServletURLConnection.java Mon Apr 14 07:28:00 2008
@@ -0,0 +1,90 @@
+/*
+ * 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.corona.servlet;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.net.URLConnection;
+
+import javax.servlet.ServletException;
+
+import org.apache.cocoon.servletservice.AbsoluteServletConnection;
+import org.apache.cocoon.servletservice.Absolutizable;
+import org.apache.cocoon.servletservice.CallStackHelper;
+
+public class ServletURLConnection extends URLConnection {
+
+ private AbsoluteServletConnection connection;
+
+ public ServletURLConnection(URL url) {
+ super(url);
+ }
+
+ @Override
+ public void connect() throws IOException {
+ if (this.connected) {
+ return;
+ }
+
+ // get the referenced servlet and find out if it is an absolute or relative connection
+ URI locationUri;
+ try {
+ locationUri = new URI(this.url.getPath());
+ } catch (URISyntaxException e) {
+ throw new IOException(e.toString());
+ }
+
+ final String servletReference = locationUri.getScheme();
+ final Absolutizable absolutizable = (Absolutizable) CallStackHelper.getCurrentServletContext();
+ final String servletName;
+
+ // find out the type of the reference and create a service name
+ if (servletReference == null) {
+ // self-reference
+ servletName = absolutizable.getServiceName();
+ } else if (servletReference.endsWith(AbsoluteServletConnection.ABSOLUTE_SERVLET_SOURCE_POSTFIX)) {
+ // absolute reference
+ servletName = servletReference.substring(0, servletReference.length() - 1);
+ } else {
+ // relative reference
+ servletName = absolutizable.getServiceName(servletReference);
+ }
+
+ this.connection = new AbsoluteServletConnection(servletName, locationUri.getRawPath(), locationUri.getRawQuery());
+ try {
+ this.connection.connect();
+ } catch (ServletException e) {
+ throw new IOException(e.toString());
+ }
+
+ this.connected = true;
+ }
+
+ @Override
+ public InputStream getInputStream() throws IOException {
+ this.connect();
+
+ try {
+ return this.connection.getInputStream();
+ } catch (ServletException e) {
+ throw new IOException(e.toString());
+ }
+ }
+}
Propchange: cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/ServletURLConnection.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/ServletURLConnection.java
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/ServletURLConnection.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/ServletURLStreamHandler.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/ServletURLStreamHandler.java?rev=647814&view=auto
==============================================================================
--- cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/ServletURLStreamHandler.java (added)
+++ cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/ServletURLStreamHandler.java Mon Apr 14 07:28:00 2008
@@ -0,0 +1,35 @@
+/*
+ * 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.corona.servlet;
+
+import java.io.IOException;
+import java.net.URL;
+import java.net.URLConnection;
+import java.net.URLStreamHandler;
+
+public class ServletURLStreamHandler extends URLStreamHandler {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see java.net.URLStreamHandler#openConnection(java.net.URL)
+ */
+ @Override
+ protected URLConnection openConnection(URL url) throws IOException {
+ return new ServletURLConnection(url);
+ }
+}
Propchange: cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/ServletURLStreamHandler.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/ServletURLStreamHandler.java
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/ServletURLStreamHandler.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/ServletURLStreamHandlerFactory.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/ServletURLStreamHandlerFactory.java?rev=647814&view=auto
==============================================================================
--- cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/ServletURLStreamHandlerFactory.java (added)
+++ cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/ServletURLStreamHandlerFactory.java Mon Apr 14 07:28:00 2008
@@ -0,0 +1,37 @@
+/*
+ * 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.corona.servlet;
+
+import java.net.URLStreamHandler;
+import java.net.URLStreamHandlerFactory;
+
+final class ServletURLStreamHandlerFactory implements URLStreamHandlerFactory {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see java.net.URLStreamHandlerFactory#createURLStreamHandler(java.lang.String)
+ */
+ public URLStreamHandler createURLStreamHandler(String protocol) {
+ if ("servlet".equalsIgnoreCase(protocol)) {
+ System.out.println("ServletURLStreamHandlerFactory creating ServletURLStreamHandler");
+ return new ServletURLStreamHandler();
+ }
+
+ return null;
+ }
+}
Propchange: cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/ServletURLStreamHandlerFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/ServletURLStreamHandlerFactory.java
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/ServletURLStreamHandlerFactory.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/SitemapDelegator.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/SitemapDelegator.java?rev=647814&view=auto
==============================================================================
--- cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/SitemapDelegator.java (added)
+++ cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/SitemapDelegator.java Mon Apr 14 07:28:00 2008
@@ -0,0 +1,43 @@
+/*
+ * 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.corona.servlet;
+
+import java.io.OutputStream;
+import java.util.Map;
+
+public class SitemapDelegator {
+
+ private static final ThreadLocal<SitemapServlet> SITEMAP_SERVLET = new ThreadLocal<SitemapServlet>();
+
+ public static void delegate(String requestURI, Map<String, Object> parameters, OutputStream outputStream) throws Exception {
+ SitemapServlet sitemapServlet = SITEMAP_SERVLET.get();
+
+ if (sitemapServlet == null) {
+ throw new IllegalStateException("No current SitemapServlet.");
+ }
+
+ sitemapServlet.invoke(requestURI, parameters, outputStream);
+ }
+
+ public static final void removeSitemapServlet() {
+ SITEMAP_SERVLET.set(null);
+ }
+
+ public static final void setSitemapServlet(SitemapServlet sitemapServlet) {
+ SITEMAP_SERVLET.set(sitemapServlet);
+ }
+}
Propchange: cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/SitemapDelegator.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/SitemapDelegator.java
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/SitemapDelegator.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/SitemapServlet.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/SitemapServlet.java?rev=647814&r1=647813&r2=647814&view=diff
==============================================================================
--- cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/SitemapServlet.java (original)
+++ cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/SitemapServlet.java Mon Apr 14 07:28:00 2008
@@ -19,6 +19,7 @@
package org.apache.cocoon.corona.servlet;
import java.io.IOException;
+import java.io.OutputStream;
import java.io.PrintWriter;
import java.net.URL;
import java.util.Enumeration;
@@ -31,12 +32,15 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import org.apache.cocoon.corona.servlet.node.MimeTypeCollector;
import org.apache.cocoon.corona.servlet.node.StatusCodeCollector;
import org.apache.cocoon.corona.servlet.util.HttpContextHelper;
import org.apache.cocoon.corona.sitemap.Invocation;
import org.apache.cocoon.corona.sitemap.InvocationImpl;
import org.apache.cocoon.corona.sitemap.SitemapBuilder;
import org.apache.cocoon.corona.sitemap.node.Sitemap;
+import org.apache.excalibur.sourceresolve.jnet.DynamicURLStreamHandlerFactory;
+import org.apache.excalibur.sourceresolve.jnet.URLStreamHandlerFactoryInstaller;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
@@ -45,11 +49,8 @@
private static final long serialVersionUID = 1L;
- private Sitemap sitemap;
-
private BeanFactory beanFactory;
-
- private StatusCodeCollector statusCodeCollector;
+ private Sitemap sitemap;
@Override
public void init(ServletConfig servletConfig) throws ServletException {
@@ -59,33 +60,51 @@
SitemapBuilder sitemapBuilder = (SitemapBuilder) this.beanFactory.getBean(SitemapBuilder.class.getName());
URL url = servletConfig.getServletContext().getResource("/sitemap.xmap");
this.sitemap = sitemapBuilder.build(url);
- this.statusCodeCollector = (StatusCodeCollector) beanFactory.getBean(StatusCodeCollector.class.getName());
+
+ URLStreamHandlerFactoryInstaller.setURLStreamHandlerFactory(new DynamicURLStreamHandlerFactory());
} catch (Exception e) {
throw new ServletException(e);
}
}
+ public void invoke(String requestURI, Map<String, Object> parameters, OutputStream outputStream) {
+ InvocationImpl invocation = (InvocationImpl) this.beanFactory.getBean(Invocation.class.getName());
+
+ System.out.println("Starting invocation for RequestURI " + requestURI);
+ invocation.setRequestURI(requestURI);
+ invocation.setParameters(parameters);
+ invocation.setOutputStream(outputStream);
+
+ this.sitemap.invoke(invocation);
+ }
+
+ public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
+ this.beanFactory = beanFactory;
+ }
+
@Override
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
try {
- InvocationImpl invocation = (InvocationImpl) this.beanFactory.getBean(Invocation.class.getName());
- // parameters
- invocation.setParameters(this.getInvocationParameters(request));
- HttpContextHelper.storeRequest(request, invocation.getParameters());
- HttpContextHelper.storeResponse(response, invocation.getParameters());
-
- // request
- invocation.setRequestURI(request.getRequestURI());
- // output stream
- invocation.setOutputStream(response.getOutputStream());
-
- this.sitemap.invoke(invocation);
+ DynamicURLStreamHandlerFactory.push(new ServletURLStreamHandlerFactory());
+ SitemapDelegator.setSitemapServlet(this);
- response.setStatus(this.statusCodeCollector.getStatusCode());
+ // assemble parameters
+ Map<String, Object> parameters = this.getInvocationParameters(request);
+ HttpContextHelper.storeRequest(request, parameters);
+ HttpContextHelper.storeResponse(response, parameters);
+
+ this.invoke(request.getRequestURI(), parameters, response.getOutputStream());
+
+ response.setStatus(StatusCodeCollector.getStatusCode());
+ response.setContentType(MimeTypeCollector.getMimeType());
+ response.setContentType("text/html;charset=UTF-8");
} catch (Exception e) {
PrintWriter writer = new PrintWriter(response.getOutputStream());
e.printStackTrace(writer);
writer.close();
+ } finally {
+ SitemapDelegator.removeSitemapServlet();
+ DynamicURLStreamHandlerFactory.pop();
}
}
@@ -99,9 +118,5 @@
}
return invocationParameters;
- }
-
- public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
- this.beanFactory = beanFactory;
}
}
Added: cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/component/Controller.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/component/Controller.java?rev=647814&view=auto
==============================================================================
--- cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/component/Controller.java (added)
+++ cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/component/Controller.java Mon Apr 14 07:28:00 2008
@@ -0,0 +1,25 @@
+/*
+ * 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.corona.servlet.component;
+
+import java.io.OutputStream;
+import java.util.Map;
+
+public interface Controller {
+
+ void invoke(String function, Map<String, Object> parameters, OutputStream outputStream);
+}
Propchange: cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/component/Controller.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/component/Controller.java
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/component/Controller.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/component/DefaultControllerComponent.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/component/DefaultControllerComponent.java?rev=647814&view=auto
==============================================================================
--- cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/component/DefaultControllerComponent.java (added)
+++ cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/component/DefaultControllerComponent.java Mon Apr 14 07:28:00 2008
@@ -0,0 +1,63 @@
+/*
+ * 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.corona.servlet.component;
+
+import java.io.OutputStream;
+import java.util.Map;
+
+import org.apache.cocoon.corona.pipeline.component.Finisher;
+import org.apache.cocoon.corona.pipeline.component.Starter;
+import org.springframework.beans.BeansException;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+
+public class DefaultControllerComponent implements Starter, Finisher, ApplicationContextAware {
+
+ private ApplicationContext applicationContext;
+ private Map<String, ? extends Object> configuration;
+ private String controllerName;
+ private String functionName;
+ private OutputStream outputStream;
+ private Map<String, Object> parameters;
+
+ public void execute() {
+ Controller controller = (Controller) this.applicationContext.getBean(this.controllerName, Controller.class);
+ controller.invoke(this.functionName, this.parameters, this.outputStream);
+ }
+
+ public String getContentType() {
+ return null;
+ }
+
+ public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
+ this.applicationContext = applicationContext;
+ }
+
+ public void setConfiguration(Map<String, ? extends Object> configuration) {
+ this.functionName = (String) configuration.get("function");
+ this.controllerName = (String) configuration.get("controller");
+ this.configuration = configuration;
+ }
+
+ public void setInputParameters(Map<String, Object> parameters) {
+ this.parameters = parameters;
+ }
+
+ public void setOutputStream(OutputStream outputStream) {
+ this.outputStream = outputStream;
+ }
+}
Propchange: cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/component/DefaultControllerComponent.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/component/DefaultControllerComponent.java
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/component/DefaultControllerComponent.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/component/RedirectorComponent.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/component/RedirectorComponent.java?rev=647814&r1=647813&r2=647814&view=diff
==============================================================================
--- cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/component/RedirectorComponent.java (original)
+++ cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/component/RedirectorComponent.java Mon Apr 14 07:28:00 2008
@@ -30,15 +30,16 @@
public class RedirectorComponent implements Starter, Finisher {
+ private Map<String, Object> parameters;
private String uri;
/**
* {@inheritDoc}
- *
- * @see org.apache.cocoon.corona.pipeline.component.Starter#execute(Map)
+ *
+ * @see org.apache.cocoon.corona.pipeline.component.Starter#execute()
*/
- public void execute(Map<String, ? extends Object> parameters) {
- HttpServletResponse response = HttpContextHelper.getResponse(parameters);
+ public void execute() {
+ HttpServletResponse response = HttpContextHelper.getResponse(this.parameters);
try {
String location = response.encodeRedirectURL(this.uri);
@@ -48,26 +49,34 @@
}
}
+ public String getContentType() {
+ return null;
+ }
+
/**
* {@inheritDoc}
- *
- * @see org.apache.cocoon.corona.pipeline.component.Finisher#setOutputStream(java.io.OutputStream)
+ *
+ * @see org.apache.cocoon.corona.pipeline.component.PipelineComponent#setConfiguration(java.util.Map)
*/
- public void setOutputStream(OutputStream outputStream) {
+ public void setConfiguration(Map<String, ? extends Object> configuration) {
+ this.uri = (String) configuration.get("uri");
+ }
+
+ public void setInputParameters(Map<String, Object> parameters) {
+ this.parameters = parameters;
}
/**
* {@inheritDoc}
- *
- * @see org.apache.cocoon.corona.pipeline.component.PipelineComponent#setParameters(java.util.Map)
+ *
+ * @see org.apache.cocoon.corona.pipeline.component.Finisher#setOutputStream(java.io.OutputStream)
*/
- public void setParameters(Map<String, ? extends Object> parameters) {
- this.uri = (String) parameters.get("uri");
+ public void setOutputStream(OutputStream outputStream) {
}
/**
* {@inheritDoc}
- *
+ *
* @see java.lang.Object#toString()
*/
@Override
Modified: cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/component/RequestParametersGenerator.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/component/RequestParametersGenerator.java?rev=647814&r1=647813&r2=647814&view=diff
==============================================================================
--- cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/component/RequestParametersGenerator.java (original)
+++ cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/component/RequestParametersGenerator.java Mon Apr 14 07:28:00 2008
@@ -32,14 +32,16 @@
public class RequestParametersGenerator extends AbstractXMLProducer implements Starter {
+ private Map<String, Object> parameters;
+
/**
* {@inheritDoc}
- *
- * @see org.apache.cocoon.corona.pipeline.component.Starter#execute(Map)
+ *
+ * @see org.apache.cocoon.corona.pipeline.component.Starter#execute()
*/
@SuppressWarnings("unchecked")
- public void execute(Map<String, ? extends Object> parameters) {
- HttpServletRequest request = HttpContextHelper.getRequest(parameters);
+ public void execute() {
+ HttpServletRequest request = HttpContextHelper.getRequest(this.parameters);
Enumeration<String> parameterNames = request.getParameterNames();
try {
@@ -59,5 +61,10 @@
} catch (SAXException e) {
throw new InvocationException(e);
}
+ }
+
+ @Override
+ public void setInputParameters(Map<String, Object> parameters) {
+ this.parameters = parameters;
}
}
Added: cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/node/MimeTypeCollector.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/node/MimeTypeCollector.java?rev=647814&view=auto
==============================================================================
--- cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/node/MimeTypeCollector.java (added)
+++ cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/node/MimeTypeCollector.java Mon Apr 14 07:28:00 2008
@@ -0,0 +1,49 @@
+/*
+ * 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.corona.servlet.node;
+
+import org.apache.cocoon.corona.pipeline.Pipeline;
+import org.aspectj.lang.ProceedingJoinPoint;
+import org.aspectj.lang.annotation.Around;
+import org.aspectj.lang.annotation.Aspect;
+
+@Aspect
+public class MimeTypeCollector {
+
+ private static final ThreadLocal<String> THREAD_LOCAL = new ThreadLocal<String>();
+
+ @Around("execution(* org.apache.cocoon.corona.pipeline.Pipeline.execute(..))")
+ public Object interceptInvoke(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
+ System.out.println("Executing MimeTypeCollector");
+ Object result = proceedingJoinPoint.proceed();
+
+ Pipeline pipeline = (Pipeline) proceedingJoinPoint.getTarget();
+ THREAD_LOCAL.set(pipeline.getContentType());
+
+ return result;
+ }
+
+ public static String getMimeType() {
+ String mimeType = THREAD_LOCAL.get();
+
+ return mimeType;
+ }
+
+ public static void setMimeType(String mimeType) {
+ THREAD_LOCAL.set(mimeType);
+ }
+}
Propchange: cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/node/MimeTypeCollector.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/node/MimeTypeCollector.java
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/node/MimeTypeCollector.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/node/StatusCodeCollector.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/node/StatusCodeCollector.java?rev=647814&r1=647813&r2=647814&view=diff
==============================================================================
--- cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/node/StatusCodeCollector.java (original)
+++ cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/node/StatusCodeCollector.java Mon Apr 14 07:28:00 2008
@@ -45,7 +45,7 @@
return invocationResult;
}
- public int getStatusCode() {
+ public static int getStatusCode() {
Integer integer = threadLocal.get();
if (integer == null) {
@@ -53,5 +53,9 @@
}
return integer.intValue();
+ }
+
+ public static void setStatusCode(int statusCode) {
+ threadLocal.set(statusCode);
}
}
Modified: cocoon/whiteboard/corona/trunk/corona-servlet/src/main/resources/META-INF/cocoon/spring/corona-servlet-component.xml
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/corona/trunk/corona-servlet/src/main/resources/META-INF/cocoon/spring/corona-servlet-component.xml?rev=647814&r1=647813&r2=647814&view=diff
==============================================================================
--- cocoon/whiteboard/corona/trunk/corona-servlet/src/main/resources/META-INF/cocoon/spring/corona-servlet-component.xml (original)
+++ cocoon/whiteboard/corona/trunk/corona-servlet/src/main/resources/META-INF/cocoon/spring/corona-servlet-component.xml Mon Apr 14 07:28:00 2008
@@ -26,4 +26,6 @@
<bean name="generator:request-parameters" class="org.apache.cocoon.corona.servlet.component.RequestParametersGenerator" scope="prototype" />
+ <bean name="controller:default" class="org.apache.cocoon.corona.servlet.component.DefaultControllerComponent" scope="prototype" />
+
</beans>
Modified: cocoon/whiteboard/corona/trunk/corona-servlet/src/main/resources/META-INF/cocoon/spring/corona-servlet-node.xml
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/corona/trunk/corona-servlet/src/main/resources/META-INF/cocoon/spring/corona-servlet-node.xml?rev=647814&r1=647813&r2=647814&view=diff
==============================================================================
--- cocoon/whiteboard/corona/trunk/corona-servlet/src/main/resources/META-INF/cocoon/spring/corona-servlet-node.xml (original)
+++ cocoon/whiteboard/corona/trunk/corona-servlet/src/main/resources/META-INF/cocoon/spring/corona-servlet-node.xml Mon Apr 14 07:28:00 2008
@@ -28,4 +28,6 @@
<bean id="org.apache.cocoon.corona.servlet.node.StatusCodeCollector" class="org.apache.cocoon.corona.servlet.node.StatusCodeCollector" />
+ <bean id="org.apache.cocoon.corona.servlet.node.MimeTypeCollector" class="org.apache.cocoon.corona.servlet.node.MimeTypeCollector" />
+
</beans>
Added: cocoon/whiteboard/corona/trunk/corona-servlet/src/main/resources/sax-pipeline/simple.xslt
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/corona/trunk/corona-servlet/src/main/resources/sax-pipeline/simple.xslt?rev=647814&view=auto
==============================================================================
--- cocoon/whiteboard/corona/trunk/corona-servlet/src/main/resources/sax-pipeline/simple.xslt (added)
+++ cocoon/whiteboard/corona/trunk/corona-servlet/src/main/resources/sax-pipeline/simple.xslt Mon Apr 14 07:28:00 2008
@@ -0,0 +1,35 @@
+<?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.
+-->
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+
+ <xsl:param name="myParam"/>
+
+ <xsl:template match="/">
+ <html>
+ <head>
+ <title>Simple Pipeline</title>
+ </head>
+
+ <body>
+ <h1>Simple Pipeline</h1>
+ <p><xsl:value-of select="$myParam"/></p>
+ </body>
+ </html>
+ </xsl:template>
+
+</xsl:stylesheet>
Propchange: cocoon/whiteboard/corona/trunk/corona-servlet/src/main/resources/sax-pipeline/simple.xslt
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/whiteboard/corona/trunk/corona-servlet/src/main/resources/sax-pipeline/simple.xslt
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: cocoon/whiteboard/corona/trunk/corona-servlet/src/main/resources/sax-pipeline/simple.xslt
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added: cocoon/whiteboard/corona/trunk/corona-servlet/src/main/resources/xslt/main.xslt
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/corona/trunk/corona-servlet/src/main/resources/xslt/main.xslt?rev=647814&view=auto
==============================================================================
--- cocoon/whiteboard/corona/trunk/corona-servlet/src/main/resources/xslt/main.xslt (added)
+++ cocoon/whiteboard/corona/trunk/corona-servlet/src/main/resources/xslt/main.xslt Mon Apr 14 07:28:00 2008
@@ -0,0 +1,34 @@
+<?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.
+-->
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+
+ <xsl:include href="sub-file.xslt"/>
+ <xsl:include href="servlet:/xslt/sub-servlet.xslt"/>
+
+ <xsl:template match="/">
+ <xslt>
+ <servlet>
+ <xsl:call-template name="servlet"/>
+ </servlet>
+ <file>
+ <xsl:call-template name="file"/>
+ </file>
+ </xslt>
+ </xsl:template>
+
+</xsl:stylesheet>
Propchange: cocoon/whiteboard/corona/trunk/corona-servlet/src/main/resources/xslt/main.xslt
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/whiteboard/corona/trunk/corona-servlet/src/main/resources/xslt/main.xslt
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: cocoon/whiteboard/corona/trunk/corona-servlet/src/main/resources/xslt/main.xslt
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added: cocoon/whiteboard/corona/trunk/corona-servlet/src/main/resources/xslt/sub-file.xslt
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/corona/trunk/corona-servlet/src/main/resources/xslt/sub-file.xslt?rev=647814&view=auto
==============================================================================
--- cocoon/whiteboard/corona/trunk/corona-servlet/src/main/resources/xslt/sub-file.xslt (added)
+++ cocoon/whiteboard/corona/trunk/corona-servlet/src/main/resources/xslt/sub-file.xslt Mon Apr 14 07:28:00 2008
@@ -0,0 +1,24 @@
+<?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.
+-->
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+
+ <xsl:template name="file">
+ <xsl:text>file</xsl:text>
+ </xsl:template>
+
+</xsl:stylesheet>
Propchange: cocoon/whiteboard/corona/trunk/corona-servlet/src/main/resources/xslt/sub-file.xslt
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/whiteboard/corona/trunk/corona-servlet/src/main/resources/xslt/sub-file.xslt
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: cocoon/whiteboard/corona/trunk/corona-servlet/src/main/resources/xslt/sub-file.xslt
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added: cocoon/whiteboard/corona/trunk/corona-servlet/src/main/resources/xslt/sub-servlet.xslt
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/corona/trunk/corona-servlet/src/main/resources/xslt/sub-servlet.xslt?rev=647814&view=auto
==============================================================================
--- cocoon/whiteboard/corona/trunk/corona-servlet/src/main/resources/xslt/sub-servlet.xslt (added)
+++ cocoon/whiteboard/corona/trunk/corona-servlet/src/main/resources/xslt/sub-servlet.xslt Mon Apr 14 07:28:00 2008
@@ -0,0 +1,24 @@
+<?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.
+-->
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+
+ <xsl:template name="servlet">
+ <xsl:text>servlet</xsl:text>
+ </xsl:template>
+
+</xsl:stylesheet>
Propchange: cocoon/whiteboard/corona/trunk/corona-servlet/src/main/resources/xslt/sub-servlet.xslt
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/whiteboard/corona/trunk/corona-servlet/src/main/resources/xslt/sub-servlet.xslt
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: cocoon/whiteboard/corona/trunk/corona-servlet/src/main/resources/xslt/sub-servlet.xslt
------------------------------------------------------------------------------
svn:mime-type = text/xml
Modified: cocoon/whiteboard/corona/trunk/corona-servlet/src/test/java/org/apache/cocoon/corona/sitemap/SitemapBuilderTest.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/corona/trunk/corona-servlet/src/test/java/org/apache/cocoon/corona/sitemap/SitemapBuilderTest.java?rev=647814&r1=647813&r2=647814&view=diff
==============================================================================
--- cocoon/whiteboard/corona/trunk/corona-servlet/src/test/java/org/apache/cocoon/corona/sitemap/SitemapBuilderTest.java (original)
+++ cocoon/whiteboard/corona/trunk/corona-servlet/src/test/java/org/apache/cocoon/corona/sitemap/SitemapBuilderTest.java Mon Apr 14 07:28:00 2008
@@ -39,7 +39,6 @@
private Sitemap sitemap;
private SitemapBuilder sitemapBuilder;
private ComponentProvider componentProvider;
- private StatusCodeCollector statusCodeCollector;
public void testErrorHandlingGlobal() {
// TODO: currently this cannot work since some components for error
@@ -69,7 +68,7 @@
assertTrue("Expected CustomException but received " + invocation.getThrowable(),
invocation.getThrowable() instanceof CustomException);
- assertEquals(501, this.statusCodeCollector.getStatusCode());
+ assertEquals(501, StatusCodeCollector.getStatusCode());
}
public void testGenerator() {
@@ -83,7 +82,7 @@
// invocation should not be marked as error-invocation
assertFalse(invocation.isErrorInvocation());
- assertEquals(401, this.statusCodeCollector.getStatusCode());
+ assertEquals(401, StatusCodeCollector.getStatusCode());
}
public void testNoMatchingPipeline() {
@@ -96,6 +95,20 @@
invocation.getThrowable() instanceof NoMatchingPipelineException);
}
+ public void testController() {
+ Invocation invocation = this.buildInvocation("controller/invoke");
+ InvocationResult invocationResult = this.sitemap.invoke(invocation);
+
+ assertNotNull(invocationResult);
+ }
+
+ public void testXSLT() {
+ Invocation invocation = this.buildInvocation("xslt/main");
+ InvocationResult invocationResult = this.sitemap.invoke(invocation);
+
+ assertNotNull(invocationResult);
+ }
+
public void testObjectModelPipeline() {
Invocation invocation = this.buildInvocation("object-model/request-parameters");
Map<String, String> requestParameters = new HashMap<String, String>();
@@ -176,8 +189,6 @@
"META-INF/cocoon/spring/corona-pipeline-component.xml", "META-INF/cocoon/spring/corona-pipeline.xml",
"META-INF/cocoon/spring/corona-sitemap-node.xml", "META-INF/cocoon/spring/corona-expression-language.xml",
"META-INF/cocoon/spring/corona-servlet-node.xml", "META-INF/cocoon/spring/corona-servlet-component.xml"});
-
- this.statusCodeCollector = (StatusCodeCollector) applicationContext.getBean(StatusCodeCollector.class.getName());
this.componentProvider = (ComponentProvider) applicationContext.getBean("org.apache.cocoon.corona.sitemap.ComponentProvider");