You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by da...@apache.org on 2006/12/13 21:24:58 UTC
svn commit: r486827 - in
/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon:
components/treeprocessor/TreeProcessorSitemapErrorHandler.java
components/treeprocessor/sitemap/PipelineNode.java
sitemap/SitemapErrorHandler.java
Author: danielf
Date: Wed Dec 13 12:24:57 2006
New Revision: 486827
URL: http://svn.apache.org/viewvc?view=rev&rev=486827
Log:
Made SitemapErrorHandler and interface and moved the previous implementation to the treeprocessor package as motivated in http://marc2.theaimsgroup.com/?l=xml-cocoon-dev&m=116602656201960&w=2.
Added:
cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/TreeProcessorSitemapErrorHandler.java
Modified:
cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/PipelineNode.java
cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/sitemap/SitemapErrorHandler.java
Added: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/TreeProcessorSitemapErrorHandler.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/TreeProcessorSitemapErrorHandler.java?view=auto&rev=486827
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/TreeProcessorSitemapErrorHandler.java (added)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/TreeProcessorSitemapErrorHandler.java Wed Dec 13 12:24:57 2006
@@ -0,0 +1,91 @@
+/*
+ * 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.components.treeprocessor;
+
+import org.apache.cocoon.Processor;
+import org.apache.cocoon.components.pipeline.ProcessingPipeline;
+import org.apache.cocoon.components.treeprocessor.InvokeContext;
+import org.apache.cocoon.components.treeprocessor.sitemap.ErrorHandlerHelper;
+import org.apache.cocoon.environment.Environment;
+import org.apache.cocoon.sitemap.SitemapErrorHandler;
+
+/**
+ * Class providing error handling capabilities to the pipeline
+ * as configured in the sitemap.
+ *
+ * @since 2.2
+ * @version $Id: SitemapErrorHandler.java 486818 2006-12-13 19:50:39Z danielf $
+ */
+public class TreeProcessorSitemapErrorHandler implements SitemapErrorHandler {
+ /**
+ * Error handler helper of the pipeline node
+ */
+ private ErrorHandlerHelper handler;
+
+ /**
+ * Environment of the pipeline node
+ */
+ private Environment environment;
+
+ /**
+ * Sitemap invocation context
+ */
+ private InvokeContext context;
+
+ // Environment state
+ private String envPrefix;
+ private String envURI;
+
+ /**
+ * Construct error handler with everything needed to handle an error.
+ */
+ public TreeProcessorSitemapErrorHandler(ErrorHandlerHelper handler,
+ Environment environment,
+ InvokeContext context) {
+ this.handler = handler;
+ this.environment = environment;
+ this.context = context;
+
+ this.envPrefix = environment.getURIPrefix();
+ this.envURI = environment.getURI();
+ }
+
+ /**
+ * Handle an error.
+ * @return true if error was handled.
+ */
+ public boolean handleError(Exception e) throws Exception {
+ // Restore environment state
+ this.environment.setURI(this.envPrefix, this.envURI);
+
+ return this.handler.invokeErrorHandler(e, this.environment, this.context);
+ }
+
+ /**
+ * Build error handling pipeline.
+ * @return error handling pipeline, or null if error was not handled.
+ */
+ public ProcessingPipeline prepareErrorPipeline(Exception e) throws Exception {
+ // Restore environment state
+ this.environment.setURI(this.envPrefix, this.envURI);
+
+ Processor.InternalPipelineDescription pipelineDescription =
+ this.handler.prepareErrorHandler(e, this.environment, this.context);
+
+ return pipelineDescription != null ? pipelineDescription.processingPipeline : null;
+ }
+}
Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/PipelineNode.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/PipelineNode.java?view=diff&rev=486827&r1=486826&r2=486827
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/PipelineNode.java (original)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/PipelineNode.java Wed Dec 13 12:24:57 2006
@@ -16,24 +16,23 @@
*/
package org.apache.cocoon.components.treeprocessor.sitemap;
+import java.util.Map;
+
import org.apache.avalon.framework.logger.Logger;
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.avalon.framework.service.ServiceManager;
import org.apache.avalon.framework.service.Serviceable;
-
import org.apache.cocoon.ConnectionResetException;
import org.apache.cocoon.ResourceNotFoundException;
import org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode;
import org.apache.cocoon.components.treeprocessor.InvokeContext;
import org.apache.cocoon.components.treeprocessor.ParameterizableProcessingNode;
import org.apache.cocoon.components.treeprocessor.ProcessingNode;
+import org.apache.cocoon.components.treeprocessor.TreeProcessorSitemapErrorHandler;
import org.apache.cocoon.components.treeprocessor.variables.VariableResolver;
import org.apache.cocoon.environment.Environment;
-import org.apache.cocoon.sitemap.SitemapErrorHandler;
import org.apache.cocoon.sitemap.SitemapExecutor;
-import java.util.Map;
-
/**
* Handles <map:pipeline>
*
@@ -143,7 +142,7 @@
if (this.errorHandlerHelper.isInternal()) {
// Set internal error handler in the pipeline
context.setErrorHandler(
- new SitemapErrorHandler(this.errorHandlerHelper, env, context));
+ new TreeProcessorSitemapErrorHandler(this.errorHandlerHelper, env, context));
} else {
// Reset internal error handler (previous pipeline might had set it)
context.setErrorHandler(null);
Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/sitemap/SitemapErrorHandler.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/sitemap/SitemapErrorHandler.java?view=diff&rev=486827&r1=486826&r2=486827
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/sitemap/SitemapErrorHandler.java (original)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/sitemap/SitemapErrorHandler.java Wed Dec 13 12:24:57 2006
@@ -16,75 +16,26 @@
*/
package org.apache.cocoon.sitemap;
-import org.apache.cocoon.Processor;
import org.apache.cocoon.components.pipeline.ProcessingPipeline;
-import org.apache.cocoon.components.treeprocessor.InvokeContext;
-import org.apache.cocoon.components.treeprocessor.sitemap.ErrorHandlerHelper;
-import org.apache.cocoon.environment.Environment;
/**
- * Class providing error handling capabilities to the pipeline
- * as configured in the sitemap.
+ * Interface providing error handling capabilities to the pipeline
*
- * @since 2.1.7
+ * @since 2.2
* @version $Id$
*/
-public class SitemapErrorHandler {
- /**
- * Error handler helper of the pipeline node
- */
- private ErrorHandlerHelper handler;
-
- /**
- * Environment of the pipeline node
- */
- private Environment environment;
-
- /**
- * Sitemap invocation context
- */
- private InvokeContext context;
-
- // Environment state
- private String envPrefix;
- private String envURI;
-
- /**
- * Construct error handler with everything needed to handle an error.
- */
- public SitemapErrorHandler(ErrorHandlerHelper handler,
- Environment environment,
- InvokeContext context) {
- this.handler = handler;
- this.environment = environment;
- this.context = context;
-
- this.envPrefix = environment.getURIPrefix();
- this.envURI = environment.getURI();
- }
+public interface SitemapErrorHandler {
/**
* Handle an error.
* @return true if error was handled.
*/
- public boolean handleError(Exception e) throws Exception {
- // Restore environment state
- this.environment.setURI(this.envPrefix, this.envURI);
-
- return this.handler.invokeErrorHandler(e, this.environment, this.context);
- }
-
+ public boolean handleError(Exception e) throws Exception;
+
/**
* Build error handling pipeline.
* @return error handling pipeline, or null if error was not handled.
*/
- public ProcessingPipeline prepareErrorPipeline(Exception e) throws Exception {
- // Restore environment state
- this.environment.setURI(this.envPrefix, this.envURI);
-
- Processor.InternalPipelineDescription pipelineDescription =
- this.handler.prepareErrorHandler(e, this.environment, this.context);
+ public ProcessingPipeline prepareErrorPipeline(Exception e) throws Exception;
- return pipelineDescription != null ? pipelineDescription.processingPipeline : null;
- }
}