Package org.apache.cocoon.components.sax

Examples of org.apache.cocoon.components.sax.XMLSerializer


            }

            if (this.toCacheKey.size()>0) {
                ListIterator itt = this.xmlSerializerArray.listIterator(this.xmlSerializerArray.size());
                while (itt.hasPrevious()) {
                    XMLSerializer serializer = (XMLSerializer) itt.previous();
                    CachedResponse response = new CachedResponse(this.toCacheSourceValidities,
                                              (byte[])serializer.getSAXFragment());
                    this.cache.store(this.toCacheKey.copy(),
                                     response);

                    if (this.getLogger().isDebugEnabled()) {
                        this.getLogger().debug("Caching results for the following key: "
View Full Code Here


     * Connect the caching point pipeline.
     */
    protected void connectCachingPipeline(Environment   environment)
    throws ProcessingException {
            try {
                XMLSerializer localXMLSerializer = null;
                XMLSerializer cachePointXMLSerializer = null;
                if (!this.cacheCompleteResponse) {
                    this.xmlSerializer = (XMLSerializer)this.manager.lookup( XMLSerializer.ROLE );
                    localXMLSerializer = this.xmlSerializer;
                }

View Full Code Here

     * Connect the pipeline.
     */
    protected void connectCachingPipeline(Environment   environment)
    throws ProcessingException {
            try {
                XMLSerializer localXMLSerializer = null;
                if (!this.cacheCompleteResponse) {
                    this.xmlSerializer = (XMLSerializer)this.manager.lookup( XMLSerializer.ROLE );
                    localXMLSerializer = this.xmlSerializer;
                }

View Full Code Here

                // the content expires, so remove it               
                cache.remove(cacheKey);
               
                source = this.resolver.resolveURI(this.uri);

                XMLSerializer serializer = null;
                SAXParser parser = null;
                byte[] cachedResponse;
                byte[] content = null;
               
                try {
                    serializer = (XMLSerializer)this.manager.lookup(XMLSerializer.ROLE);
                    if ( source instanceof XMLizable ) {
                        ((XMLizable)source).toSAX(serializer);
                    } else {
                        // resd the content
                        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
                        final byte[] buffer = new byte[2048];
                        final InputStream inputStream = source.getInputStream();
                        int length;
       
                        while ((length = inputStream.read(buffer)) > -1) {
                            baos.write(buffer, 0, length);
                        }
                        baos.flush();
                        inputStream.close();
                       
                        content = baos.toByteArray();
                       
                        parser = (SAXParser)this.manager.lookup(SAXParser.ROLE);
                   
                        final InputSource inputSource = new InputSource(new ByteArrayInputStream(content));
                        inputSource.setSystemId(source.getURI());
                   
                        parser.parse( inputSource, serializer );
                    }
                    cachedResponse = (byte[])serializer.getSAXFragment();
                } finally {
                    this.manager.release(parser);
                    this.manager.release(serializer);
                }
               
View Full Code Here

                this.getLogger().debug("Starting parallel thread for loading " + uri);
            }
            // now we start a parallel thread, this thread gets all required avalon components
            // so it does not have to lookup them by itself
            try {
                XMLSerializer serializer = (XMLSerializer)this.manager.lookup(XMLSerializer.ROLE);
                Source source = session.resolveURI(uri, this.resolver);

                LoaderThread loader = new LoaderThread(source, serializer, this.manager);
                Thread thread = new Thread(loader);
                session.add(uri, loader);
View Full Code Here

                }
            }
        }

        // we are not processing in parallel and have no (valid) cached response
        XMLSerializer serializer = null;
        try {
            final Source source = session.resolveURI(uri, this.resolver);
           
            // stream directly (and cache the response)
            if (this.getLogger().isDebugEnabled()) {
                this.getLogger().debug("Streaming directly from source.");
            }
            if (session.getExpires() > 0) {
                serializer = (XMLSerializer)this.manager.lookup(XMLSerializer.ROLE);
                XMLTeePipe tee = new XMLTeePipe(handler, serializer);
               
                SourceUtil.toSAX(source, tee);
               
                SourceValidity[] validities = new SourceValidity[1];
                validities[0] = session.getExpiresValidity();
                CachedResponse response = new CachedResponse(validities,
                                                             (byte[])serializer.getSAXFragment());
                session.getCacheStorageProxy().put(uri, response);
            } else {
                SourceUtil.toSAX(source, handler);
            }
           
View Full Code Here

                source = SourceUtil.getSource(resource,
                                              this.configurationParameters,
                                              this.resourceParameters,
                                              this.resolver);
                                             
                XMLSerializer serializer = null;
                XMLDeserializer deserializer = null;
                try {
                    if ( ignoreErrors ) {
                        serializer = (XMLSerializer) this.manager.lookup(XMLSerializer.ROLE);
                        deserializer = (XMLDeserializer)this.manager.lookup(XMLDeserializer.ROLE);
                        SourceUtil.toSAX(source, serializer, this.configurationParameters, true);
                        deserializer.setConsumer( this.xmlConsumer );
                        deserializer.deserialize( serializer.getSAXFragment() );
                    } else {
                        SourceUtil.toSAX(source, this.xmlConsumer, this.configurationParameters, true);
                    }
                } catch (ProcessingException pe) {
                    if (!ignoreErrors) throw pe;
View Full Code Here

    throws SAXException {
        if (this.getLogger().isDebugEnabled()) {
            this.getLogger().debug("BEGIN endCompiledXMLRecording");
        }

        XMLSerializer recorder = (XMLSerializer)this.removeRecorder();
        Object text = (byte[])recorder.getSAXFragment();

        if (this.getLogger().isDebugEnabled()) {
            this.getLogger().debug("END endCompiledXMLRecording text="+text);
        }
        return text;
View Full Code Here

        if ("description".equals(name)) {
            final String text = this.endTextRecording();
            final String html = "<html><body>"+text+"</body></html>";
           
            Object parsed = null;           
            XMLSerializer serializer = null;
            try {
                serializer = (XMLSerializer)this.manager.lookup(XMLSerializer.ROLE);
                InputStream inputStream = new ByteArrayInputStream(html.getBytes());
                this.xmlizer.toSAX(inputStream,
                                    "text/html",
                                    null,
                                    serializer);
                // if no exception occurs, everything is fine!
                parsed = serializer.getSAXFragment();
            } catch (Exception ignore) {
            } finally {
                this.manager.release( serializer );
            }
            if ( parsed != null ) {
View Full Code Here

                                                             null);                                                           
        }
       
        // we cache both
        if ( alternative && this.cachedResponse.getAlternativeResponse() == null ) {
            XMLSerializer serializer = null;
            SAXParser parser = null;
            try {
                serializer = (XMLSerializer)this.manager.lookup(XMLSerializer.ROLE);
                if ( this.source instanceof XMLizable ) {
                    ((XMLizable)this.source).toSAX(serializer);
                } else {
                    parser = (SAXParser)this.manager.lookup(SAXParser.ROLE);
                   
                    final InputSource inputSource = new InputSource(new ByteArrayInputStream(this.cachedResponse.getResponse()));
                    inputSource.setSystemId(this.source.getURI());
                   
                    parser.parse( inputSource, serializer );
                }
               
                this.cachedResponse.setAlternativeResponse((byte[])serializer.getSAXFragment());
            } catch (ComponentException ce) {
                throw new CascadingIOException("Unable to lookup xml serializer.", ce);
            } finally {
                this.manager.release((Component)parser);
                this.manager.release(serializer);
View Full Code Here

TOP

Related Classes of org.apache.cocoon.components.sax.XMLSerializer

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.