Package org.apache.excalibur.source.impl.validity

Examples of org.apache.excalibur.source.impl.validity.ExpiresValidity


        // and now prepare the caching information
        this.cacheKey = new IdentifierCacheKey(key,
                                           this.serializer == this.lastConsumer);
        if ( this.cacheExpires > 0) {
            this.cacheValidity = new ExpiresValidity(this.cacheExpires*1000);                                              
        }
        final boolean purge = this.parameters.getParameterAsBoolean("purge-cache", false);
        
        this.cachedResponse = this.cache.get(this.cacheKey);
        if ( this.cachedResponse != null ) {
View Full Code Here


        return this.expires;
    }

    public SourceValidity getExpiresValidity() {
        if ( this.expires > 0 && this.validity == null) {
            this.validity = new ExpiresValidity( this.expires * 1000 ); // milliseconds
        }
        return this.validity;
    }
View Full Code Here

                    serializer = (XMLSerializer)manager.lookup(XMLSerializer.ROLE);
               
                    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) {
View Full Code Here

                    if (CachingSource.isValid(sourceValidity, source)) {
                        if (getLogger().isDebugEnabled()) {
                            getLogger().debug("Cached response is still valid " +
                                "for source " + this.uri + ".");
                        }
                        response.getValidityObjects()[0] = new ExpiresValidity(this.expires * 1000);
                        return;
                    }
                }
               
                if (source.exists()) {
                   
                    // what is in the cached response?
                    byte[] binary = null;
                    byte[] xml = null;
                    if (response != null) {
                        binary = response.getBinaryResponse();
                        xml = response.getXMLResponse();
                    }
                   
                    // create a new cached response
                    final ExpiresValidity cacheValidity = new ExpiresValidity(this.expires * 1000);
                    final SourceValidity sourceValidity = source.getValidity();
                    response = new CachedSourceResponse(new SourceValidity[] {cacheValidity, sourceValidity});
                   
                    // only create objects that have previously been used
                    if (binary != null) {
View Full Code Here

            checkValidity = false;
        }
       
        if (checkValidity) {
           
            final ExpiresValidity cacheValidity = (ExpiresValidity) this.response.getValidityObjects()[0];
            final SourceValidity sourceValidity = this.response.getValidityObjects()[1];
           
            boolean remove = false;
            if (this.expires == 0) {
                if (getLogger().isDebugEnabled()) {
                    getLogger().debug("Force invalidation of cached response" +
                        " of source " + getSourceURI());
                }
                remove = true;
            }
            else {
                boolean expired = cacheValidity.isValid() != SourceValidity.VALID;
                if (expired) {
                    if (getLogger().isDebugEnabled()) {
                        getLogger().debug("Cached response of source "
                            + getSourceURI() + " is expired.");
                    }
                    boolean invalid = !isValid(sourceValidity, this.source);
                    if (invalid) {
                        if (getLogger().isDebugEnabled()) {
                            getLogger().debug("Cached response of source "
                                + getSourceURI() + " is invalid.");
                        }
                        remove = true;
                    }
                    else {
                        if (getLogger().isDebugEnabled()) {
                            getLogger().debug("Cached response of source "
                                + getSourceURI() + " is still valid.");
                        }
                        // set new expiration period
                        this.response.getValidityObjects()[0] = new ExpiresValidity(getExpiration());
                    }
                }
            }
           
            if (remove) {
View Full Code Here

    protected void initMetaResponse() throws IOException {
        boolean storeResponse = false;
        CachedSourceResponse response = this.response;
        if (response == null) {
            if (this.expires != 0) {
                final SourceValidity cacheValidity = new ExpiresValidity(getExpiration());
                final SourceValidity sourceValidity = source.getValidity();
                response = new CachedSourceResponse(new SourceValidity[] {cacheValidity, sourceValidity});
                storeResponse = true;
            }
            else {
View Full Code Here

        boolean storeResponse = false;
        /* delay caching the response until we have a valid new one */
        CachedSourceResponse response = this.response;
        if (response == null) {
            if (this.expires != 0) {
                final SourceValidity cacheValidity = new ExpiresValidity(getExpiration());
                final SourceValidity sourceValidity = source.getValidity();
                response = new CachedSourceResponse(new SourceValidity[] {cacheValidity, sourceValidity});
                storeResponse = true;
            }
            else {
View Full Code Here

        boolean storeResponse = false;
        /* delay caching the response until we have a valid new one */
        CachedSourceResponse response = this.response;
        if (response == null) {
            if (this.expires != 0) {
                final SourceValidity cacheValidity = new ExpiresValidity(getExpiration());
                final SourceValidity sourceValidity = source.getValidity();
                response = new CachedSourceResponse(new SourceValidity[] {cacheValidity, sourceValidity});
                storeResponse = true;
            }
            else {
View Full Code Here

        // and now prepare the caching information
        this.cacheKey = new IdentifierCacheKey(key,
                                           this.serializer == this.lastConsumer);
        if ( this.cacheExpires > 0) {
            this.cacheValidity = new ExpiresValidity(this.cacheExpires*1000);
        } else if ( this.cacheExpires < 0 ) {
            this.cacheValidity = NOPValidity.SHARED_INSTANCE;
        }
        final boolean purge = this.parameters.getParameterAsBoolean("purge-cache", false);

View Full Code Here

                    serializer = (XMLSerializer)manager.lookup(XMLSerializer.ROLE);
               
                    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) {
View Full Code Here

TOP

Related Classes of org.apache.excalibur.source.impl.validity.ExpiresValidity

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.