Package org.apache.cocoon.caching

Examples of org.apache.cocoon.caching.Cache


                    Map objectModel,
                    String src,
                    Parameters par
    ) throws Exception {
        final String cacheRole = par.getParameter("cache-role", Cache.ROLE + "/EventAware");
        Cache cache = (Cache)this.manager.lookup(cacheRole);
        try {
            // FIXME - This cast might not work with every container!
            if (cache instanceof EventAwareCacheImpl) {
                String eventName = par.getParameter("event");
                if (getLogger().isDebugEnabled()) {
View Full Code Here


            if ( this.getLogger().isInfoEnabled()) {
                this.getLogger().info("Refreshing " + this.uri);
            }

            Source source = null;
            Cache cache = null;
            try {
                cache = (Cache)this.manager.lookup(this.cacheRole);
                // 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);
                }
               
                SourceValidity val = new ExpiresValidity(this.expires);
                ExtendedCachedResponse response = new ExtendedCachedResponse(val, content);
                response.setAlternativeResponse(cachedResponse);
                cache.store(cacheKey, response);
           
            } catch (Exception ignore) {
                this.getLogger().error("Exception during updating " +this.uri, ignore);
            } finally {
                this.resolver.release(source);
View Full Code Here

            if ( this.getLogger().isInfoEnabled()) {
                this.getLogger().info("Refreshing " + this.uri);
            }

            Source source = null;
            Cache cache = null;
            try {
                cache = (Cache)this.manager.lookup(this.cacheRole);
                // 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((Component)parser);
                    this.manager.release(serializer);
                }
               
                SourceValidity val = new ExpiresValidity(this.expires);
                ExtendedCachedResponse response = new ExtendedCachedResponse(val, content);
                response.setAlternativeResponse(cachedResponse);
                cache.store(cacheKey, response);
           
            } catch (Exception ignore) {
                this.getLogger().error("Exception during updating " +this.uri, ignore);
            } finally {
                this.resolver.release(source);
View Full Code Here

TOP

Related Classes of org.apache.cocoon.caching.Cache

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.