Examples of XMLByteStreamCompiler


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

            // 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 );

                    this.lastConsumer = old;
View Full Code Here

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

                synchronized (object[3]) {
                    ((List)object[3]).remove(uri);
                }
               
                Source source = null;
                XMLByteStreamCompiler serializer;

                try {
                    if (logger.isDebugEnabled()) {
                        logger.debug("PreemptiveLoader: Loading " + uri);
                    }

                    source = resolver.resolveURI(uri);
                    serializer = new XMLByteStreamCompiler();
               
                    SourceUtil.toSAX(source, serializer);
               
                    SourceValidity[] validities = new SourceValidity[1];
                    validities[0] = new ExpiresValidity(((Long)object[2]).longValue() * 1000); // milliseconds!
                    CachedResponse response = new CachedResponse(validities,
                                                                 (byte[])serializer.getSAXFragment());
                    ((IncludeCacheStorageProxy)object[0]).put(uri, response);
                    
                } catch (Exception ignore) {
                    // all exceptions are ignored!
                } finally {
View Full Code Here

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

    /**
     * Connect the pipeline.
     */
    protected void connectCachingPipeline(Environment   environment)
    throws ProcessingException {
        XMLByteStreamCompiler localXMLSerializer = null;
        if (!this.cacheCompleteResponse) {
            this.xmlSerializer = new XMLByteStreamCompiler();
            localXMLSerializer = this.xmlSerializer;
        }

        if (this.cachedResponse == null) {
            XMLProducer prev = super.generator;
View Full Code Here

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

     */
    protected byte[] readXMLResponse(Source source, byte[] binary, ServiceManager manager)
    throws SAXException, IOException {
        XMLizer xmlizer = null;
        try {
            XMLByteStreamCompiler serializer = new XMLByteStreamCompiler();

            if (source instanceof XMLizable) {
                ((XMLizable) source).toSAX(serializer);
            } else {
                final String mimeType = source.getMimeType();
                if (mimeType != null) {
                    xmlizer = (XMLizer) manager.lookup(XMLizer.ROLE);
                    xmlizer.toSAX(new ByteArrayInputStream(binary),
                                  mimeType,
                                  source.getURI(),
                                  serializer);
                }
            }

            return (byte[]) serializer.getSAXFragment();
        } catch (ServiceException e) {
            throw new CascadingIOException("Missing service dependency.", e);
        } finally {
            if (xmlizer != null) {
                manager.release(xmlizer);
View Full Code Here

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

     */
    protected byte[] readXMLResponse(Source source, byte[] binary, ServiceManager manager)
    throws SAXException, IOException, CascadingIOException {
        XMLizer xmlizer = null;
        try {
            XMLByteStreamCompiler serializer = new XMLByteStreamCompiler();

            if (source instanceof XMLizable) {
                ((XMLizable) source).toSAX(serializer);
            } else {
                final String mimeType = source.getMimeType();
                if (mimeType != null) {
                    xmlizer = (XMLizer) manager.lookup(XMLizer.ROLE);
                    xmlizer.toSAX(new ByteArrayInputStream(binary),
                                  mimeType,
                                  source.getURI(),
                                  serializer);
                }
            }

            return (byte[]) serializer.getSAXFragment();
        } catch (ServiceException e) {
            throw new CascadingIOException("Missing service dependency.", e);
        } finally {
            if (xmlizer != null) {
                manager.release(xmlizer);
View Full Code Here

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

        // Get a ServerPagesGenerator
        ServerPagesGenerator generator = (ServerPagesGenerator)this.generatorHandler.get();
       
        // Generator ouptut, if output-attribute was given
        XMLByteStreamCompiler compiler = null;
       
        try {
            generator.setLogger(getLogger());
            generator.compose(this.manager);       
            generator.setup(resolver, objectModel, source, parameters);
           
            // Setup generator output
            if (outputKey == null) {
                // discard output to a "black hole"
                generator.setConsumer(new AbstractXMLConsumer() { } ); // Make the abstract class instanciable
            } else {
                // store output in a byte stream
                compiler = new XMLByteStreamCompiler();
                generator.setConsumer(compiler);
            }
           
            // Augment the object model for the "action" logicsheet
            objectModel.put(REDIRECTOR_OBJECT, redirector);
            objectModel.put(ACTION_RESULT_OBJECT, resultMap);
       
            // Let the XSP do it's stuff
            generator.generate();
            success = objectModel.get(ACTION_SUCCESS_OBJECT);
           
        } catch (Exception e) {
            getLogger().warn("serverpage error", e);
            throw e;
           
        } finally {
            // Release generator
            generatorHandler.put(generator);
           
            // Clean up object model
            objectModel.remove(REDIRECTOR_OBJECT);
            objectModel.remove(ACTION_RESULT_OBJECT);
            objectModel.remove(ACTION_SUCCESS_OBJECT);
        }
       
        if (outputKey != null) {
            // Success defaults to true when the whole output is captured
            if (success == null) {
                success = Boolean.TRUE;
            }
           
            if (success == Boolean.TRUE) {
                // Store the XSP output in the request
                Request req = (Request)objectModel.get(Constants.REQUEST_OBJECT);
                req.setAttribute(outputKey, new XMLByteStreamFragment(compiler.getSAXFragment()));
            }
        }
       
        return (success == Boolean.TRUE) ? resultMap : null;
    }
View Full Code Here

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

                    coplet.removeTemporaryAttribute(CACHE);
                }
                super.streamContent(coplet, uri, contentHandler);               
            } else {

                XMLByteStreamCompiler bc = new XMLByteStreamCompiler();

                super.streamContent(coplet, uri, bc);
                data = bc.getSAXFragment();
                if (coplet.removeTemporaryAttribute(DO_NOT_CACHE) == null) {
                    if ( cacheGlobal ) {
                        CachedResponse response = new CachedResponse((SourceValidity[])null, (byte[])data);
                        try {
                            final String key = this.getCacheKey(coplet, uri);
View Full Code Here

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

        // Get a ServerPagesGenerator
        ServerPagesGenerator generator = (ServerPagesGenerator)this.generatorHandler.get();

        // Generator ouptut, if output-attribute was given
        XMLByteStreamCompiler compiler = null;

        try {
            generator.enableLogging(getLogger());
            generator.compose(this.manager);
            generator.setup(resolver, objectModel, source, parameters);

            // Setup generator output
            if (outputKey == null) {
                // discard output to a "black hole"
                generator.setConsumer(new AbstractXMLConsumer() { } ); // Make the abstract class instanciable
            } else {
                // store output in a byte stream
                compiler = new XMLByteStreamCompiler();
                generator.setConsumer(compiler);
            }

            // Augment the object model for the "action" logicsheet
            objectModel.put(REDIRECTOR_OBJECT, redirector);
            objectModel.put(ACTION_RESULT_OBJECT, resultMap);

            // Let the XSP do it's stuff
            generator.generate();
            success = objectModel.get(ACTION_SUCCESS_OBJECT);

        } finally {
            // Release generator
            generatorHandler.put(generator);

            // Clean up object model
            objectModel.remove(REDIRECTOR_OBJECT);
            objectModel.remove(ACTION_RESULT_OBJECT);
            objectModel.remove(ACTION_SUCCESS_OBJECT);
        }

        if (outputKey != null) {
            // Success defaults to true when the whole output is captured
            if (success == null) {
                success = Boolean.TRUE;
            }

            if (success == Boolean.TRUE) {
                // Store the XSP output in the request
                Request req = ObjectModelHelper.getRequest(objectModel);
                req.setAttribute(outputKey, new XMLByteStreamFragment(compiler.getSAXFragment()));
            }
        }

        return (success == Boolean.TRUE) ? resultMap : null;
    }
View Full Code Here

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

        this.index = index;
        this.data = data;

        // FIXME Retrieve components from the CM
        this.deserializer = new XMLByteStreamInterpreter();
        this.serializer = new XMLByteStreamCompiler();
    }
View Full Code Here

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

        // Strip off the XML Declaration if there is one!
        if (value.startsWith("<?xml ")) {
            value = value.substring(value.indexOf("?>") + 2);
        }

        final XMLByteStreamCompiler compiler = new XMLByteStreamCompiler();
        final XMLByteStreamInterpreter interpreter = new XMLByteStreamInterpreter();

        this.parser.parse(new InputSource(new StringReader("<root>" + value + "</root>")),
                          compiler);

        final IncludeXMLConsumer filter = new IncludeXMLConsumer(this, this);
        filter.setIgnoreRootElement(true);

        interpreter.setConsumer(filter);
        interpreter.deserialize(compiler.getSAXFragment());
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.