Package org.apache.cocoon.components.sax

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


                // use the response from the cache
                result = (byte[])object;
            }
           
            // stream the content
            XMLDeserializer deserializer = null;
            try {
                deserializer = (XMLDeserializer)this.manager.lookup( XMLDeserializer.ROLE );
                deserializer.setConsumer(handler);
                deserializer.deserialize(result);
            } catch (ServiceException ce) {
                throw new SAXException("Unable to lookup xml deserializer.", ce);
            } finally {
                this.manager.release( deserializer );
            }
            return;
           
        } else {
            // we are not processing parallel
           
            // first: test for a cached response
            IncludeCacheStorageProxy storage = session.getCacheStorageProxy();
            CachedResponse response = (CachedResponse)storage.get(uri);
            if ( null != response) {
                SourceValidity[] validities = response.getValidityObjects();
                // if purging is turned off and either the cached response is valid or
                // we are loading preemptive, then use the cached response
                if ( !session.isPurging()
                      && (session.isPreemptive() || validities[0].isValid() == SourceValidity.VALID)) {

                    // stream the content                   
                    if (this.getLogger().isDebugEnabled()) {
                        this.getLogger().debug("Streaming from cached response.");
                    }
                    XMLDeserializer deserializer = null;
                    try {
                        deserializer = (XMLDeserializer)this.manager.lookup( XMLDeserializer.ROLE );
                        deserializer.setConsumer(handler);
                        deserializer.deserialize(response.getResponse());
                    } catch (ServiceException ce) {
                        throw new SAXException("Unable to lookup xml deserializer.", ce);
                    } finally {
                        this.manager.release( deserializer );
                    }
View Full Code Here


                                              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

     * @see org.xml.sax.ContentHandler#endDocument()
     */
    public void endDocument() throws SAXException {
        if ( this.compiling ) {
            Object compiledXML = this.endCompiledXMLRecording();
            XMLDeserializer deserializer = null;
            try {
                deserializer = (XMLDeserializer)this.manager.lookup(XMLDeserializer.ROLE);
                deserializer.setConsumer(this.filter);
                deserializer.deserialize(compiledXML);
            } catch (ServiceException ce) {
                throw new SAXException("Unable to lookup xml deserializer.", ce);
            } finally {
                this.manager.release( deserializer );
            }
View Full Code Here

                }
            }
            byte[] content = (byte[])loadedSunlet[0];
            if (content != null) {
                if (content.length > 0) {
                    XMLDeserializer interpreter = null;
                    try {
                        interpreter = (XMLDeserializer)this.manager.lookup(XMLDeserializer.ROLE);
                        interpreter.setConsumer(new IncludeXMLConsumer(consumer, consumer));
                        interpreter.deserialize(content);
                    } catch (ComponentException e) {
                        throw new ProcessingException("Component for XMLDeserializer not found." + e, e);
                    } finally {
                        if (interpreter != null) this.manager.release((Component)interpreter);
                    }
View Full Code Here

                        while (this.firstNotCacheableTransformerIndex < transformerSize) {
                            this.notCacheableTransformers.add(this.transformers.get(this.firstNotCacheableTransformerIndex));
                            this.firstNotCacheableTransformerIndex++;
                        }

                        XMLDeserializer deserializer = null;
                        try {
                            deserializer = (XMLDeserializer)this.manager.lookup(XMLDeserializer.ROLE);
                            // connect the pipeline:
                            this.producer = deserializer;
                            this.connectPipeline(environment,
                                                 notCacheableTransformers,
                                                 null);
                            // execute the pipeline:
                            deserializer.deserialize(cachedObject.getSAXFragment());
                        } catch ( ProcessingException e ) {
                            throw e;
                        } catch ( Exception e ) {
                            throw new ProcessingException(
                                 "Failed to execute pipeline.",
View Full Code Here

                }
            }
            byte[] content = (byte[])loadedCoplet[0];
            if (content != null) {
                if (content.length > 0) {
                    XMLDeserializer interpreter = null;
                    try {
                        interpreter = (XMLDeserializer)this.manager.lookup(XMLDeserializer.ROLE);
                        interpreter.setConsumer(new IncludeXMLConsumer(consumer, consumer));
                        interpreter.deserialize(content);
                    } catch (ComponentException e) {
                        throw new ProcessingException("Component for XMLDeserializer not found." + e, e);
                    } finally {
                        if (interpreter != null) this.manager.release(interpreter);
                    }
View Full Code Here

        if (getLogger().isDebugEnabled()) {
            getLogger().debug("Retrieving fragment " + source + ".");
        }

        Store store = null;
        XMLDeserializer deserializer = null;
        Object fragment = null;
        try {
            store = (Store) this.manager.lookup(Store.TRANSIENT_STORE);
            fragment = store.get(source);
            if (fragment == null) {
                throw new ResourceNotFoundException("Could not find fragment " + source + " in store");
            }

            deserializer = (XMLDeserializer) this.manager.lookup(XMLDeserializer.ROLE);
            deserializer.setConsumer(this.xmlConsumer);
            deserializer.deserialize(fragment);

        } catch (ServiceException ce) {
            if (getLogger().isDebugEnabled()) {
                getLogger().debug("Could not lookup for component.", ce);
            }
View Full Code Here

            ComponentSelector tagSelector = (ComponentSelector)tagSelectorStack.pop();
            try {
                if (saxFragment != null) {
                    // Start Iteration
                    IterationTag iterTag = (IterationTag) tag;
                    XMLDeserializer xmlDeserializer = null;
                    try {
                        xmlDeserializer = (XMLDeserializer) manager.lookup(XMLDeserializer.ROLE);
                        xmlDeserializer.setConsumer(this);

                        // BodyTag Support
                        XMLConsumer backup = this.currentConsumer;
                        if (tag instanceof BodyTag) {
                            SaxBuffer content = new SaxBuffer();
                            this.currentConsumer = content;
                            ((BodyTag)tag).setBodyContent(new BodyContent(content, backup));
                            ((BodyTag)tag).doInitBody();
                        }

                        do {
                            xmlDeserializer.deserialize(saxFragment);
                        } while (iterTag.doAfterBody() != Tag.SKIP_BODY);

                        // BodyTag Support
                        if (tag instanceof BodyTag) {
                            this.currentConsumer = backup;
View Full Code Here

                    fragment = xmls.getSAXFragment();
                } finally {
                    this.manager.release(xmls);
                    CocoonComponentManager.leaveEnvironment();
                }
                XMLDeserializer xmld = (XMLDeserializer) this.manager.lookup(XMLDeserializer.ROLE);
                try {
                    xmld.setConsumer(consumer);
                    xmld.deserialize(fragment);
                } finally {
                    this.manager.release(xmld);
                }
            }
        } catch (SAXException e) {
View Full Code Here

    }

    public void generateSAXFragment(Object fragment, boolean embed) throws SAXException {

        if (fragment!=null) {
            XMLDeserializer deserializer = null;

            try {
                deserializer = (XMLDeserializer) this.manager.lookup(XMLDeserializer.ROLE);
                if (embed)
                    deserializer.setConsumer(new IncludeXMLConsumer(this.xmlConsumer));
                else
                    deserializer.setConsumer(this.xmlConsumer);
                deserializer.deserialize(fragment);
            } catch (ServiceException ce) {
                getLogger().debug("Could not retrieve XMLDeserializer component",
                                  ce);
                throw new SAXException("Could not retrieve XMLDeserializer component",
                                       ce);
View Full Code Here

TOP

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

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.