Package org.apache.cocoon.components.pipeline

Examples of org.apache.cocoon.components.pipeline.ProcessingPipeline


        try {
            env.changeContext(resolvedPrefix, resolvedSource);

            if (context.isInternalRequest()) {
                // Propagate pipelines
                ProcessingPipeline pp = processor.processInternal(env);
                if ( pp != null ) {
                    context.setProcessingPipeline( pp );
                    return true;
                } else {
                    return false;


            new FileSavingEnvironment(deparameterizedURI, lastModified, context,
                                      attributes, parameters, links,
                                      gatheredLinks, cliContext, null, log);

        XMLConsumer consumer = new ContentHandlerWrapper(handler);
        ProcessingPipeline pipeline = cocoon.buildPipeline(env);
        CocoonComponentManager.enterEnvironment(env, cocoon.getComponentManager(), cocoon);
        try {
            pipeline.prepareInternal(env);
            pipeline.process(env, consumer);
        } finally {
            CocoonComponentManager.leaveEnvironment();
        }

        // if we get here, the page was created :-)

        try {
            env.changeContext(resolvedPrefix, resolvedSource);

            if (context.isBuildingPipelineOnly()) {
                // Propagate pipelines
                ProcessingPipeline pp = processor.buildPipeline(env);
                if ( pp != null ) {
                    context.setProcessingPipeline( pp );
                    return true;
                } else {
                    return false;

                }
            }
        }
       
        Map objectModel = env.getObjectModel();
        ProcessingPipeline pipeline = context.getProcessingPipeline();

        // Perform link translation if requested
        if (objectModel.containsKey(Constants.LINK_OBJECT)) {
            pipeline.addTransformer("<translator>", null, Parameters.EMPTY_PARAMETERS, Parameters.EMPTY_PARAMETERS);
        }
       
        if (objectModel.containsKey(Constants.LINK_COLLECTION_OBJECT) && env.isExternal()) {
            pipeline.addTransformer("<gatherer>", null, Parameters.EMPTY_PARAMETERS, Parameters.EMPTY_PARAMETERS);
        }

        pipeline.setSerializer(
            this.serializerName,
            source.resolve(context, objectModel),
            VariableResolver.buildParameters(this.parameters, context, objectModel),
            this.pipelineHints == null
                ? Parameters.EMPTY_PARAMETERS
                : VariableResolver.buildParameters(this.pipelineHints, context, objectModel),
            this.mimeType.resolve(context, env.getObjectModel())
        );

        // Set status code if there is one
        if (this.statusCode >= 0) {
            env.setStatus(this.statusCode);
        }

        if (! context.isBuildingPipelineOnly()) {
            // Process pipeline
            return pipeline.process(env);

        } else {
            // Return true : pipeline is finished.
            return true;
        }

                }
            }
        }

        final Map objectModel = env.getObjectModel();
        final ProcessingPipeline pipeline = context.getProcessingPipeline();

        // Perform link translation if requested
        if (objectModel.containsKey(Constants.LINK_OBJECT)) {
            pipeline.addTransformer("<translator>", null, Parameters.EMPTY_PARAMETERS, Parameters.EMPTY_PARAMETERS);
        }

        if (objectModel.containsKey(Constants.LINK_COLLECTION_OBJECT) && env.isExternal()) {
            pipeline.addTransformer("<gatherer>", null, Parameters.EMPTY_PARAMETERS, Parameters.EMPTY_PARAMETERS);
        }

        String type = this.serializerName;
        String source = this.source.resolve(context, objectModel);
        Parameters parameters = VariableResolver.buildParameters(this.parameters, context, objectModel);
        Parameters hintParameters = this.pipelineHints == null
                ? Parameters.EMPTY_PARAMETERS
                : VariableResolver.buildParameters(this.pipelineHints, context, objectModel);
        String mimeType = this.mimeType.resolve(context, objectModel);

        pipeline.setSerializer(type,
                               source,
                               parameters,
                               hintParameters,
                               mimeType);

        // Set status code *only* if there is one - do not override status
        // code if it was set elsewhere.
        String statusCodeString = this.statusCode.resolve(context, objectModel);
        if (statusCodeString != null) {
            int statusCodeInt = DEFAULT_STATUS_CODE;
            try {
                statusCodeInt = Integer.parseInt(statusCodeString);
            } catch (NumberFormatException e) {
                getLogger().warn("Status code value '" + statusCodeString + "' is not an integer. " +
                                 "Using " + DEFAULT_STATUS_CODE + " instead.", e);
            }
            if (statusCodeInt >= 0) {
                env.setStatus(statusCodeInt);
            }
        }

        if (!context.isBuildingPipelineOnly()) {
            // Process pipeline
            return pipeline.process(env);
        }
        // Return true : pipeline is finished.
        return true;
    }

            context.getProcessingPipeline().addTransformer(
                "<gatherer>", null, Parameters.EMPTY_PARAMETERS, Parameters.EMPTY_PARAMETERS
            );
        }

        ProcessingPipeline pipeline = context.getProcessingPipeline();

        Map objectModel = env.getObjectModel();

        pipeline.setSerializer(
            this.serializerName,
            null,
            Parameters.EMPTY_PARAMETERS, // No parameters on serializers
            this.pipelineHints == null
                ? Parameters.EMPTY_PARAMETERS
                : VariableResolver.buildParameters(this.pipelineHints, context, objectModel),
            this.mimeType.resolve(context, env.getObjectModel())
        );

        // Set status code if there is one
        if (this.statusCode >= 0) {
            env.setStatus(this.statusCode);
        }

        if (! context.isBuildingPipelineOnly()) {
            // Process pipeline
            return pipeline.process(env);

        } else {
            // Return true : pipeline is finished.
            return true;
        }

        try {
            env.changeContext(resolvedPrefix, resolvedSource);

            if (context.isBuildingPipelineOnly()) {
                // Propagate pipelines
                ProcessingPipeline pp = processor.buildPipeline(env);
                if ( pp != null ) {
                    context.setProcessingPipeline( pp );
                    return true;
                } else {
                    return false;

            try {
               
                if ( !this.internal ) {
                    processingResult = usedProcessor.process(newEnv);
                } else {
                    ProcessingPipeline pp = usedProcessor.processInternal(newEnv);
                    if (pp != null) pp.release();
                    processingResult = pp != null;
                }
            } finally {
                CocoonComponentManager.endProcessing(newEnv, processKey);
            }

    public final boolean invoke(Environment env,  InvokeContext context)
    throws Exception {

        final Map objectModel = env.getObjectModel();

        final ProcessingPipeline pipeline = context.getProcessingPipeline();

        SitemapExecutor.PipelineComponentDescription desc = new SitemapExecutor.PipelineComponentDescription();
        desc.type = this.readerName;
        desc.source = source.resolve(context, objectModel);
        desc.parameters = VariableResolver.buildParameters(this.parameters, context, objectModel);
        desc.mimeType = this.mimeType.resolve(context, objectModel);

        desc = this.executor.addReader(this, objectModel, desc);

        pipeline.setReader(desc.type,
                           desc.source,
                           desc.parameters,
                           desc.mimeType);

        // Set status code if there is one
        if (this.statusCode >= 0) {
            env.setStatus(this.statusCode);
        }

        if (!context.isBuildingPipelineOnly()) {
            // Process pipeline
            return pipeline.process(env);
        }

        // Return true : pipeline is finished.
        return true;
    }

                }
            }
        }

        final Map objectModel = env.getObjectModel();
        final ProcessingPipeline pipeline = context.getProcessingPipeline();

        // Perform link translation if requested
        if (objectModel.containsKey(Constants.LINK_OBJECT)) {
            pipeline.addTransformer("<translator>", null, Parameters.EMPTY_PARAMETERS, Parameters.EMPTY_PARAMETERS);
        }

        if (objectModel.containsKey(Constants.LINK_COLLECTION_OBJECT) && env.isExternal()) {
            pipeline.addTransformer("<gatherer>", null, Parameters.EMPTY_PARAMETERS, Parameters.EMPTY_PARAMETERS);
        }

        SitemapExecutor.PipelineComponentDescription desc = new SitemapExecutor.PipelineComponentDescription();
        desc.type = this.serializerName;
        desc.source = source.resolve(context, objectModel);
        desc.parameters = VariableResolver.buildParameters(this.parameters, context, objectModel);
        desc.hintParameters = this.pipelineHints == null
                ? Parameters.EMPTY_PARAMETERS
                : VariableResolver.buildParameters(this.pipelineHints, context, objectModel);
        desc.mimeType = this.mimeType.resolve(context, objectModel);

        // inform executor
        desc = this.executor.addSerializer(this, objectModel, desc);

        pipeline.setSerializer(desc.type,
                               desc.source,
                               desc.parameters,
                               desc.hintParameters,
                               desc.mimeType);

        // Set status code *only* if there is one - do not override status
        // code if it was set elsewhere.
        String statusCodeString = this.statusCode.resolve(context, objectModel);
        if (statusCodeString != null) {
            int statusCodeInt = DEFAULT_STATUS_CODE;
            try {
                statusCodeInt = Integer.parseInt(statusCodeString);
            } catch (NumberFormatException e) {
                getLogger().warn("Status code value '" + statusCodeString + "' is not an integer. " +
                                 "Using " + DEFAULT_STATUS_CODE + " instead.", e);
            }
            if (statusCodeInt >= 0) {
                env.setStatus(statusCodeInt);
            }
        }

        if (!context.isBuildingPipelineOnly()) {
            // Process pipeline
            return pipeline.process(env);
        }
        // Return true : pipeline is finished.
        return true;
    }

TOP

Related Classes of org.apache.cocoon.components.pipeline.ProcessingPipeline

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.