1 16 package org.apache.cocoon.components.treeprocessor.sitemap; 17 18 import org.apache.avalon.framework.activity.Disposable; 19 import org.apache.avalon.framework.component.ComponentManager; 20 import org.apache.avalon.framework.component.Composable; 21 import org.apache.avalon.framework.logger.Logger; 22 23 import org.apache.cocoon.ConnectionResetException; 24 import org.apache.cocoon.components.treeprocessor.InvokeContext; 25 import org.apache.cocoon.components.treeprocessor.ProcessingNode; 26 import org.apache.cocoon.components.treeprocessor.SimpleParentProcessingNode; 27 import org.apache.cocoon.environment.Environment; 28 29 38 public final class PipelinesNode extends SimpleParentProcessingNode 39 implements Composable, Disposable { 40 41 private ComponentManager manager; 42 43 private ErrorHandlerHelper errorHandlerHelper; 44 45 46 public PipelinesNode() { 47 this.errorHandlerHelper = new ErrorHandlerHelper(); 48 } 49 50 54 public void compose(ComponentManager manager) { 55 this.manager = manager; 56 this.errorHandlerHelper.compose(manager); 57 } 58 59 public void enableLogging(Logger logger) { 60 super.enableLogging(logger); 61 this.errorHandlerHelper.enableLogging(logger); 62 } 63 64 public void setErrorHandler(ProcessingNode node) { 65 this.errorHandlerHelper.set500Handler(node); 66 } 67 68 public void setChildren(ProcessingNode[] nodes) { 69 ((PipelineNode) nodes[nodes.length - 1]).setLast(true); 71 super.setChildren(nodes); 72 } 73 74 79 public final boolean invoke(Environment env, InvokeContext context) 80 throws Exception { 81 82 super.invoke(env, context); 84 85 context.recompose(this.manager); 87 88 try { 89 92 return invokeNodes(this.children, env, context); 93 94 } catch (ConnectionResetException e) { 95 throw e; 97 } catch (Exception ex) { 98 return this.errorHandlerHelper.invokeErrorHandler(ex, env, context); 100 } 101 } 102 103 106 public void dispose() { 107 if (this.manager instanceof Disposable) { 108 ((Disposable) this.manager).dispose(); 109 } 110 this.manager = null; 111 } 112 } 113 | Popular Tags |