Search in sources :

Example 1 with XMLSerializer

use of org.apache.cocoon.pipeline.component.sax.XMLSerializer in project sling by apache.

the class PipelineImpl method eval.

@Override
public void eval() throws Exception {
    try {
        this.getEnv().setCcPipeline(new NonCachingPipeline());
        // generator
        AbstractGenerator generator = new SlingGenerator(this.getEnv().getSling());
        this.getEnv().getCcPipeline().addComponent(generator);
        // subpipeline evaluated
        for (Step step : this.getSubpipeline()) {
            step.eval();
        }
        this.getEnv().getCcPipeline().addComponent(new XMLSerializer());
        // Don't retrieve OutputStream from response until actually writing
        // to response, so that error handlers can retrieve it without getting
        // an error
        final OutputStream out = new OutputStreamWrapper() {

            @Override
            protected OutputStream getWrappedStream() throws IOException {
                return getEnv().getSling().getResponse().getOutputStream();
            }
        };
        this.getEnv().getCcPipeline().setup(out);
        this.getEnv().getCcPipeline().execute();
    } catch (Exception e) {
        String absPath = this.getEnv().getSling().getRequest().getResource().getPath();
        throw new Exception("Error in pipeline for resource: " + absPath, e);
    }
}
Also used : NonCachingPipeline(org.apache.cocoon.pipeline.NonCachingPipeline) XMLSerializer(org.apache.cocoon.pipeline.component.sax.XMLSerializer) SlingGenerator(org.apache.sling.scripting.xproc.cocoon.generator.SlingGenerator) AbstractGenerator(org.apache.cocoon.pipeline.component.sax.AbstractGenerator) OutputStream(java.io.OutputStream) Step(org.apache.sling.scripting.xproc.xpl.api.Step) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)1 OutputStream (java.io.OutputStream)1 NonCachingPipeline (org.apache.cocoon.pipeline.NonCachingPipeline)1 AbstractGenerator (org.apache.cocoon.pipeline.component.sax.AbstractGenerator)1 XMLSerializer (org.apache.cocoon.pipeline.component.sax.XMLSerializer)1 SlingGenerator (org.apache.sling.scripting.xproc.cocoon.generator.SlingGenerator)1 Step (org.apache.sling.scripting.xproc.xpl.api.Step)1