Package org.apache.sling.rewriter

Examples of org.apache.sling.rewriter.PipelineConfiguration


     */
    public void init(ProcessingContext processingContext,
                     ProcessorConfiguration c)
    throws IOException {
        LOGGER.debug("Setting up pipeline...");
        final PipelineConfiguration config = (PipelineConfiguration)c;
        final ProcessingComponentConfiguration[] transformerConfigs = config.getTransformerConfigurations();

        // create components and initialize them

        // lets get custom rewriter transformers
        final Transformer[][] rewriters = this.factoryCache.getGlobalTransformers(processingContext);

        final ProcessingComponentConfiguration generatorConfig = config.getGeneratorConfiguration();
        this.generator = this.getPipelineComponent(Generator.class, generatorConfig.getType(), false);
        LOGGER.debug("Using generator type {}: {}.", generatorConfig.getType(), generator);
        generator.init(processingContext, generatorConfig);

        final int transformerCount = (transformerConfigs == null ? 0 : transformerConfigs.length) + rewriters[0].length + rewriters[1].length;
        int index = 0;
        if ( transformerCount > 0 ) {
            // add all pre rewriter transformers
            transformers = new Transformer[transformerCount];
            for(int i=0; i< rewriters[0].length; i++) {
                transformers[index] = rewriters[0][i];
                LOGGER.debug("Using pre transformer: {}.", transformers[index]);
                transformers[index].init(processingContext, ProcessingComponentConfigurationImpl.EMPTY);
                index++;
            }
            if ( transformerConfigs != null ) {
                for(int i=0; i< transformerConfigs.length;i++) {
                    transformers[index] = this.getPipelineComponent(Transformer.class, transformerConfigs[i].getType(),
                            transformerConfigs[i].getConfiguration().get(ProcessingComponentConfiguration.CONFIGURATION_COMPONENT_OPTIONAL, false));
                    if ( transformers[index] != null ) {
                        LOGGER.debug("Using transformer type {}: {}.", transformerConfigs[i].getType(), transformers[index]);
                        transformers[index].init(processingContext, transformerConfigs[i]);
                        index++;
                    } else {
                        LOGGER.debug("Skipping missing optional transformer of type {}", transformerConfigs[i].getType());
                    }
                }
            }
            for(int i=0; i< rewriters[1].length; i++) {
                transformers[index] = rewriters[1][i];
                LOGGER.debug("Using post transformer: {}.", transformers[index]);
                transformers[index].init(processingContext, ProcessingComponentConfigurationImpl.EMPTY);
                index++;
            }
        } else {
            transformers = EMPTY_TRANSFORMERS;
        }

        final ProcessingComponentConfiguration serializerConfig = config.getSerializerConfiguration();
        this.serializer = this.getPipelineComponent(Serializer.class, serializerConfig.getType(), false);
        LOGGER.debug("Using serializer type {}: {}.", serializerConfig.getType(), serializer);
        serializer.init(processingContext, serializerConfig);

        ContentHandler pipelineComponent = serializer;
View Full Code Here

TOP

Related Classes of org.apache.sling.rewriter.PipelineConfiguration

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.