Package org.apache.cocoon.xml

Examples of org.apache.cocoon.xml.XMLConsumer


        long startTime = System.currentTimeMillis();
        // Test for url rewriting
        if (typeParameters != null
            && typeParameters.getParameter(URLRewriter.PARAMETER_MODE, null) != null) {
            XMLConsumer consumer = new URLRewriter(typeParameters,
                                                   contentHandler,
                                                   lexicalHandler);
            contentHandler = consumer;
            lexicalHandler = consumer;
        }
View Full Code Here


            setContentHandler(originalContentHandler);
            setLexicalHandler(originalLexicalHandler);
            this.originalLexicalHandler = null;
            this.originalContentHandler = null;
        } else {
            XMLConsumer next = (XMLConsumer) recorderStack.peek();
            setContentHandler(next);
            setLexicalHandler(next);
        }

        return recorder;
View Full Code Here

            localXMLSerializer = this.xmlSerializer;
        }

        if (this.cachedResponse == null) {
            XMLProducer prev = super.generator;
            XMLConsumer next;

            int cacheableTransformerCount = this.firstNotCacheableTransformerIndex;
            int currentTransformerIndex = 0; //start with the first transformer

            Iterator itt = this.transformers.iterator();
            while ( itt.hasNext() ) {
                next = (XMLConsumer) itt.next();

                // if we have cacheable transformers,
                // check the tranformers for cachepoints
                if (cacheableTransformerCount > 0) {
                    if ( (this.isCachePoint.get(currentTransformerIndex) != null&&
                            ((Boolean)this.isCachePoint.get(currentTransformerIndex)).booleanValue()) {

                        cachePointXMLSerializer = new XMLByteStreamCompiler();
                        next = new XMLTeePipe(next, cachePointXMLSerializer);
                        this.xmlSerializerArray.add(cachePointXMLSerializer);
                    }
                }


                // Serializer is not cacheable,
                // but we  have the longest cacheable key. Do default longest key caching
                if (localXMLSerializer != null) {
                    if (cacheableTransformerCount == 0) {
                        next = new XMLTeePipe(next, localXMLSerializer);
                        this.xmlSerializerArray.add(localXMLSerializer);
                        localXMLSerializer = null;
                    } else {
                        cacheableTransformerCount--;
                    }
                }
                this.connect(environment, prev, next);
                prev = (XMLProducer) next;

                currentTransformerIndex++;
            }
            next = super.lastConsumer;


            // if the serializer is not cacheable, but all the transformers are:
            // (this is default longest key caching)
            if (localXMLSerializer != null) {
                next = new XMLTeePipe(next, localXMLSerializer);
                this.xmlSerializerArray.add(localXMLSerializer);
                localXMLSerializer = null;
            }

            // else if the serializer is cacheable and has cocoon views
            else if ((currentTransformerIndex == this.firstNotCacheableTransformerIndex) &&
                    this.nextIsCachePoint) {
                cachePointXMLSerializer = new XMLByteStreamCompiler();
                next = new XMLTeePipe(next, cachePointXMLSerializer);
                this.xmlSerializerArray.add(cachePointXMLSerializer);
            }
            this.connect(environment, prev, next);

        } else {
            // Here the first part of the pipeline has been retrived from cache
            // we now check if any part of the rest of the pipeline can be cached
            this.xmlDeserializer = new XMLByteStreamInterpreter();
            // connect the pipeline:
            XMLProducer prev = xmlDeserializer;
            XMLConsumer next;
            int cacheableTransformerCount = 0;
            Iterator itt = this.transformers.iterator();
            while ( itt.hasNext() ) {
                next = (XMLConsumer) itt.next();
View Full Code Here

        if ( this.lastConsumer != this.serializer ) {
            // internal
            if ( this.cachedResponse == null) {
                // if we cache, we need an xml serializer
                if ( this.cacheExpires != 0) {
                    final XMLConsumer old = this.lastConsumer;
                    this.xmlSerializer = new XMLByteStreamCompiler();
                    this.lastConsumer = new XMLTeePipe(this.lastConsumer, this.xmlSerializer);

                    super.connectPipeline( environment );
View Full Code Here

            localXMLSerializer = this.xmlSerializer;
        }

        if (this.cachedResponse == null) {
            XMLProducer prev = super.generator;
            XMLConsumer next;

            int cacheableTransformerCount = this.firstNotCacheableTransformerIndex;

            Iterator itt = this.transformers.iterator();
            while (itt.hasNext()) {
                next = (XMLConsumer) itt.next();
                if (localXMLSerializer != null) {
                    if (cacheableTransformerCount == 0) {
                        next = new XMLTeePipe(next, localXMLSerializer);
                        localXMLSerializer = null;
                    } else {
                        cacheableTransformerCount--;
                    }
                }
                connect(environment, prev, next);
                prev = (XMLProducer) next;
            }

            next = super.lastConsumer;
            if (localXMLSerializer != null) {
                next = new XMLTeePipe(next, localXMLSerializer);
                localXMLSerializer = null;
            }
            connect(environment, prev, next);
        } else {
            this.xmlDeserializer = new XMLByteStreamInterpreter();

            // connect the pipeline:
            XMLProducer prev = xmlDeserializer;
            XMLConsumer next;
            int cacheableTransformerCount = 0;
            Iterator itt = this.transformers.iterator();
            while (itt.hasNext()) {
                next = (XMLConsumer) itt.next();
                if (cacheableTransformerCount >= this.firstProcessedTransformerIndex) {
View Full Code Here

        }
        try {
            if (this.redirectSource != null) {
                SourceUtil.parse(this.manager, this.redirectSource, contentHandler);
            } else {
                XMLConsumer consumer;
                if (contentHandler instanceof XMLConsumer) {
                    consumer = (XMLConsumer)contentHandler;
                } else if (contentHandler instanceof LexicalHandler) {
                    consumer = new ContentHandlerWrapper(contentHandler, (LexicalHandler)contentHandler);
                } else {
View Full Code Here

            } catch (Exception e) {
                throw new SAXException("XPointerPart: error looking up XPathProcessor.", e);
            }
            NodeList nodeList = xpathProcessor.selectNodeList(document, expression, ctx);
            if (nodeList.getLength() > 0) {
                XMLConsumer consumer = ctx.getXmlConsumer();
                LocatorImpl locator = new LocatorImpl();
                locator.setSystemId(ctx.getSource().getURI());
                consumer.setDocumentLocator(locator);
                for (int i = 0; i < nodeList.getLength(); i++) {
                    DOMStreamer streamer = new DOMStreamer();
                    streamer.setNormalizeNamespaces(true);
                    streamer.setConsumer(consumer);
                    streamer.stream(nodeList.item(i));
View Full Code Here

    private void connectPipeline(Environment   environment,
                                 ArrayList     usedTransformers,
                                 XMLSerializer xmlSerializer)
    throws ProcessingException {
        XMLProducer prev = this.producer;
        XMLConsumer next;

        boolean configuredSAXConnector = this.manager.hasComponent(SAXConnector.ROLE);

        try {
            int cacheableTransformerCount = this.firstNotCacheableTransformerIndex;
View Full Code Here

    /** Connect the pipeline.
     */
    protected void connectPipeline(Environment environment) throws ProcessingException {
        XMLProducer prev = (XMLProducer)this.generator;
        XMLConsumer next;
       
        // Looked up in manager and not newManager (it's not a sitemap component)
        boolean configuredSAXConnector = this.manager.hasComponent(SAXConnector.ROLE);

        try {
View Full Code Here

        FileSavingEnvironment env =
            new FileSavingEnvironment(deparameterizedURI, lastModified, context,
                                      null, 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);
View Full Code Here

TOP

Related Classes of org.apache.cocoon.xml.XMLConsumer

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.