Author: ilgrosso
Date: Tue Apr 3 15:38:20 2012
New Revision: 1308984
URL: http://svn.apache.org/viewvc?rev=1308984&view=rev
Log:
[COCOON3-96] Sitemap extended for handling internal-only pipelines; samples updated
Modified:
cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/AbstractPipeline.java
cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/Pipeline.java
cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/overview.html
cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/sitemap.xmap
cocoon/cocoon3/trunk/cocoon-sitemap/pom.xml
cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/InvocationImpl.java
cocoon/cocoon3/trunk/cocoon-sitemap/src/main/resources/cocoon-sitemap-1.0.xsd
Modified: cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/AbstractPipeline.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/AbstractPipeline.java?rev=1308984&r1=1308983&r2=1308984&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/AbstractPipeline.java (original)
+++ cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/AbstractPipeline.java Tue Apr 3 15:38:20 2012
@@ -43,7 +43,9 @@ public abstract class AbstractPipeline<T
*/
private static final Logger LOG =
LoggerFactory.getLogger(AbstractPipeline.class);
-
+
+ private boolean internalOnly;
+
private final LinkedList<T> components = new LinkedList<T>();
private boolean setupDone;
@@ -93,13 +95,19 @@ public abstract class AbstractPipeline<T
return -1;
}
+ @Override
+ public boolean isInternalOnly() {
+ return this.internalOnly;
+ }
+
/**
* {@inheritDoc}
*
* @see org.apache.cocoon.pipeline.Pipeline#setConfiguration(java.util.Map)
*/
public void setConfiguration(Map<String, ? extends Object> parameters) {
- // do nothing
+ this.internalOnly = parameters.containsKey("internal-only")
+ && "true".equalsIgnoreCase((String) parameters.get("internal-only"));
}
/**
Modified: cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/Pipeline.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/Pipeline.java?rev=1308984&r1=1308983&r2=1308984&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/Pipeline.java (original)
+++ cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/Pipeline.java Tue Apr 3 15:38:20 2012
@@ -81,6 +81,13 @@ public interface Pipeline<T extends Pipe
void execute() throws Exception;
/**
+ * Indicates if this pipeline is only evaluated for internal (servlet:) requests. By default 'false'.
+ *
+ * @return whether this pipeline is only evaluated for internal (servlet:) requests.
+ */
+ boolean isInternalOnly();
+
+ /**
* Get the mime-type {@linkref http://tools.ietf.org/html/rfc2046} of the
* content produced by the pipeline.
*
Modified: cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/overview.html
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/overview.html?rev=1308984&r1=1308983&r2=1308984&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/overview.html (original)
+++ cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/overview.html Tue Apr 3 15:38:20 2012
@@ -60,17 +60,17 @@
<section id="caching">
<h2>Caching</h2>
<ul>
- <li><a href="caching-pipeline/off">Non-Caching pipeline</a>: The pipeline doesn't cache (although it's components support it)</li>
- <li><a href="caching-pipeline/on">Caching pipeline</a>: The result of the pipeline is cached for 1.5 seconds. The next request that occurs
- after the cached response has expires, triggers a reexecution of the pipeline in the same thread.</li>
- <li><a href="async-caching-pipeline/on">Async-Caching pipeline</a>: The result of the pipeline is cached for 1.5 seconds. The next request that occurs
- after the cached response has expires, triggers a reexecution of the pipeline in a separate thread.</li>
- <li><a href="/expires/caching-pipeline/on">Expires-Caching pipeline</a>: The pipeline returns a cached result for defined period,
- independently from whether components used in the pipeline support caching or not. The pipeline result is cached for 2 seconds. The
- recreation of the pipeline result is done in the same thread as the servlet request.</li>
- <li><a href="/expires/async-caching-pipeline/on">Expires-Async-Caching pipeline</a>: The pipeline returns a cached result for defined period,
- independently from whether components used in the pipeline support caching or not. The pipeline result is cached for 2 seconds. The recreation of the
- pipeline result is done in a separate thread than the servlet request.</li>
+ <li><a href="caching-pipeline/off">Non-Caching pipeline</a>: The pipeline doesn't cache (although it's components support it)</li>
+ <li><a href="caching-pipeline/on">Caching pipeline</a>: The result of the pipeline is cached for 1.5 seconds. The next request that occurs
+ after the cached response has expires, triggers a reexecution of the pipeline in the same thread.</li>
+ <li><a href="async-caching-pipeline/on">Async-Caching pipeline</a>: The result of the pipeline is cached for 1.5 seconds. The next request that occurs
+ after the cached response has expires, triggers a reexecution of the pipeline in a separate thread.</li>
+ <li><a href="/expires/caching-pipeline/on">Expires-Caching pipeline</a>: The pipeline returns a cached result for defined period,
+ independently from whether components used in the pipeline support caching or not. The pipeline result is cached for 2 seconds. The
+ recreation of the pipeline result is done in the same thread as the servlet request.</li>
+ <li><a href="/expires/async-caching-pipeline/on">Expires-Async-Caching pipeline</a>: The pipeline returns a cached result for defined period,
+ independently from whether components used in the pipeline support caching or not. The pipeline result is cached for 2 seconds. The recreation of the
+ pipeline result is done in a separate thread than the servlet request.</li>
</ul>
</section>
<section id="error-handling">
@@ -85,6 +85,8 @@
<h2>Servlet-Service-Components and servlet: protocol</h2>
<ul>
<li><a href="ssf/local">servlet:/</a>: Using a local servlet service.</li>
+ <li><a href="internal-only/simple-xml">ResourceNotFound/</a>: Try to access directly an internal-only pipeline.</li>
+ <li><a href="ssf/local-internal-only">servlet:/</a>: Using a local servlet service provided by an internal-only pipeline.</li>
<li><a href="ssf/calling-a-transformer-servlet-service">Servlet service transformer</a>: Call another pipeline that performs a transformation.</li>
<li><a href="ssf/calling-a-serializer-servlet-service">Servlet service serializer</a>: Call another pipeline that performs the serialization step.</li>
</ul>
@@ -155,7 +157,7 @@
<ul>
<li><a href="controller/abc/foo?reqparam=1">GET request</a>: Invoke a controller and pass two parameters</li>
<li><a href="controller/conditional-get/abc/foo?reqparam=1">Conditional GET request </a>: A controller that implements the o.a.c.rest.controller.method.ConditionalGet
- interface and provides a cache key.</li>
+ interface and provides a cache key.</li>
</ul>
</section>
<section id="jaxrs-rest-controller">
@@ -167,28 +169,28 @@
<section id="fop">
<h2>FOP</h2>
<ul>
- <li><a href="fop/test.pdf">PDF</a>: Create a PDF document by using Apache FOP.</li>
+ <li><a href="fop/test.pdf">PDF</a>: Create a PDF document by using Apache FOP.</li>
</ul>
</section>
<section id="encoding-serializers">
<h2>Encoding Serializers</h2>
<ul>
- <li><a href="serializers/exml">eXML</a>: A XML serializer not relying on the JAXP API.</li>
- <li><a href="serializers/exhtml">eXHTML</a>: A pedantinc XHTML serializer encoding all recognized entities with their proper HTML names.</li>
- <li><a href="serializers/ehtml">eHTML</a>: A serializer converting XHTML into plain old HTML.</li>
+ <li><a href="serializers/exml">eXML</a>: A XML serializer not relying on the JAXP API.</li>
+ <li><a href="serializers/exhtml">eXHTML</a>: A pedantinc XHTML serializer encoding all recognized entities with their proper HTML names.</li>
+ <li><a href="serializers/ehtml">eHTML</a>: A serializer converting XHTML into plain old HTML.</li>
</ul>
</section>
<section id="cocoon-wicket-integration">
<h2>Cocoon-Wicket integration</h2>
<ul>
- <li><a href="wicket/">Wicket Reader</a>: A reader defers redirects a request to a Wicket application.</li>
+ <li><a href="wicket/">Wicket Reader</a>: A reader defers redirects a request to a Wicket application.</li>
</ul>
</section>
<section id="stringtemplate">
<h2>StringTemplate</h2>
<ul>
- <li><a href="string-template/generator">StringTemplateGenerator</a>: A generator using <a href="http://www.stringtemplate.org/">StringTemplate</a> template engine.</li>
- <li><a href="string-template/transformer">StringTemplateTransformer</a>: A transformer using <a href="http://www.stringtemplate.org/">StringTemplate</a> template engine.</li>
+ <li><a href="string-template/generator">StringTemplateGenerator</a>: A generator using <a href="http://www.stringtemplate.org/">StringTemplate</a> template engine.</li>
+ <li><a href="string-template/transformer">StringTemplateTransformer</a>: A transformer using <a href="http://www.stringtemplate.org/">StringTemplate</a> template engine.</li>
</ul>
</section>
</article>
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=1308984&r1=1308983&r2=1308984&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 Apr 3 15:38:20 2012
@@ -143,11 +143,25 @@
</map:pipeline>
<!-- ~~~~~~~~~~~~~~~~ servlet service framework ~~~~~~~~~~~~~~~ -->
+ <map:pipeline internal-only="true">
+ <map:match pattern="internal-only/simple-xml">
+ <map:generate src="sax-pipeline/simple.xml" />
+ <map:transform src="sax-pipeline/simple.xslt">
+ <map:parameter name="myParam" value="3-{jexl:cocoon.request.ssf}" />
+ </map:transform>
+ <map:serialize type="xml" />
+ </map:match>
+ </map:pipeline>
+
<map:pipeline jmx-group-name="servlet-service">
<map:match pattern="ssf/local">
<map:generate src="servlet:/sax-pipeline/simple-xml" />
<map:serialize type="xml" />
</map:match>
+ <map:match pattern="ssf/local-internal-only">
+ <map:generate src="servlet:/internal-only/simple-xml" />
+ <map:serialize type="xml" />
+ </map:match>
<map:match pattern="ssf/read-resource">
<map:read src="servlet:/read/javascript-resource-explicit" />
</map:match>
@@ -387,13 +401,13 @@
<map:generate src="linkrewriting/apache_home.html" />
<map:transform type="regexplinkrewriter">
<map:parameter name="element1"
- value="a href"/>
+ value="a href"/>
<map:parameter name="element2"
- value="http://www.w3.org/1999/xhtml link * href"/>
+ value="http://www.w3.org/1999/xhtml link * href"/>
<map:parameter name="regexp1"
- value="^\./([\.]*) http://www.apache.org/$1"/>
+ value="^\./([\.]*) http://www.apache.org/$1"/>
<map:parameter name="regexp2"
- value="^/([\.]*) http://www.apache.org/$1"/>
+ value="^/([\.]*) http://www.apache.org/$1"/>
</map:transform>
<map:serialize type="xml" />
</map:match>
Modified: cocoon/cocoon3/trunk/cocoon-sitemap/pom.xml
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sitemap/pom.xml?rev=1308984&r1=1308983&r2=1308984&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sitemap/pom.xml (original)
+++ cocoon/cocoon3/trunk/cocoon-sitemap/pom.xml Tue Apr 3 15:38:20 2012
@@ -64,6 +64,12 @@
<artifactId>cocoon-spring-configurator</artifactId>
</dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
<!-- Logging -->
<dependency>
<groupId>org.slf4j</groupId>
Modified: cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/InvocationImpl.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/InvocationImpl.java?rev=1308984&r1=1308983&r2=1308984&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/InvocationImpl.java (original)
+++ cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/InvocationImpl.java Tue Apr 3 15:38:20 2012
@@ -27,8 +27,8 @@ import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import javax.servlet.http.HttpServletRequest;
import org.apache.cocoon.configuration.Settings;
-
import org.apache.cocoon.pipeline.Pipeline;
import org.apache.cocoon.pipeline.component.Finisher;
import org.apache.cocoon.pipeline.component.PipelineComponent;
@@ -144,6 +144,16 @@ public class InvocationImpl implements I
}
this.pipeline.setup(this.outputStream, this.parameters);
+ // check whether we are executing an internalOnly pipeline
+ if (this.pipeline.isInternalOnly() && this.getParameters().containsKey(HttpServletRequest.class.getName())) {
+ final HttpServletRequest request =
+ (HttpServletRequest) this.getParameters().get(HttpServletRequest.class.getName());
+
+ if (!"servlet".equals(request.getScheme())) {
+ throw new NoMatchingPipelineException("No pipeline matched the request '" + this.requestURI + "'");
+ }
+ }
+
// then execute
for (final Action action : this.actions) {
action.execute();
@@ -380,7 +390,7 @@ public class InvocationImpl implements I
"Could not resolve parameter '" + parameter + "'. "
+ "The language '" + language + "' is not supported.");
}
-
+
final String variable = matcher.group(2);
resolved = interpreter.resolve(variable, this.objectModel);
if (resolved == null) {
Modified: cocoon/cocoon3/trunk/cocoon-sitemap/src/main/resources/cocoon-sitemap-1.0.xsd
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sitemap/src/main/resources/cocoon-sitemap-1.0.xsd?rev=1308984&r1=1308983&r2=1308984&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sitemap/src/main/resources/cocoon-sitemap-1.0.xsd (original)
+++ cocoon/cocoon3/trunk/cocoon-sitemap/src/main/resources/cocoon-sitemap-1.0.xsd Tue Apr 3 15:38:20 2012
@@ -69,6 +69,13 @@
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
+ <xsd:attribute name="internal-only" type="xsd:boolean" use="optional">
+ <xsd:annotation>
+ <xsd:documentation>
+ Indicates if this pipeline is only evaluated for internal (servlet:) requests. Optional, by default 'false'.
+ </xsd:documentation>
+ </xsd:annotation>
+ </xsd:attribute>
<xsd:attribute name="jmx-group-name" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation>
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.