Package org.apache.excalibur.source

Examples of org.apache.excalibur.source.SourceValidity


                while (responseIsValid && i < fromCacheValidityObjects.length) {
                    boolean isValid = false;

                    // BH Check if validities[i] is null, may happen
                    //    if exception was thrown due to malformed content
                    SourceValidity validity = fromCacheValidityObjects[i];
                    int valid = validity == null ? SourceValidity.INVALID : validity.isValid();
                    if (valid == SourceValidity.UNKNOWN) {
                        // Don't know if valid, make second test
                        validity = getValidityForInternalPipeline(i);
                        if (validity != null) {
                            valid = fromCacheValidityObjects[i].isValid(validity);
View Full Code Here


    protected boolean processReader(Environment  environment)
        throws ProcessingException {
        try {
            boolean usedCache = false;
            OutputStream outputStream = null;
            SourceValidity readerValidity = null;
            PipelineCacheKey pcKey = null;

            // test if reader is cacheable
            Serializable readerKey = null;
            boolean isCacheableProcessingComponent = false;
            if (super.reader instanceof CacheableProcessingComponent) {
                readerKey = ((CacheableProcessingComponent)super.reader).getKey();
                isCacheableProcessingComponent = true;
            } else if (super.reader instanceof Cacheable) {
                readerKey = new Long(((Cacheable)super.reader).generateKey());
            }

            boolean finished = false;

            if (readerKey != null) {
                // response is cacheable, build the key
                pcKey = new PipelineCacheKey();
                pcKey.addKey(new ComponentCacheKey(ComponentCacheKey.ComponentType_Reader,
                            this.readerRole,
                            readerKey)
                        );

                while(!finished) {
                    finished = true;
                    // now we have the key to get the cached object
                    CachedResponse cachedObject = this.cache.get(pcKey);
                    if (cachedObject != null) {
                        if (getLogger().isDebugEnabled()) {
                            getLogger().debug("Found cached response for '" +
                                    environment.getURI() + "' using key: " + pcKey);
                        }

                        SourceValidity[] validities = cachedObject.getValidityObjects();
                        if (validities == null || validities.length != 1) {
                            // to avoid getting here again and again, we delete it
                            this.cache.remove(pcKey);
                            if (getLogger().isDebugEnabled()) {
                                getLogger().debug("Cached response for '" + environment.getURI() +
                                        "' using key: " + pcKey + " is invalid.");
                            }
                            this.cachedResponse = null;
                        } else {
                            SourceValidity cachedValidity = validities[0];
                            boolean isValid = false;
                            int valid = cachedValidity.isValid();
                            if (valid == SourceValidity.UNKNOWN) {
                                // get reader validity and compare
                                if (isCacheableProcessingComponent) {
                                    readerValidity = ((CacheableProcessingComponent) super.reader).getValidity();
                                } else {
                                    CacheValidity cv = ((Cacheable) super.reader).generateValidity();
                                    if (cv != null) {
                                        readerValidity = CacheValidityToSourceValidity.createValidity(cv);
                                    }
                                }
                                if (readerValidity != null) {
                                    valid = cachedValidity.isValid(readerValidity);
                                    if (valid == SourceValidity.UNKNOWN) {
                                        readerValidity = null;
                                    } else {
                                        isValid = (valid == SourceValidity.VALID);
                                    }
View Full Code Here

        return null;
    }

    SourceValidity getValidityForInternalPipeline(int index) {
        final SourceValidity validity;

        // if debugging try to tell why something is not cacheable
        final boolean debug = this.getLogger().isDebugEnabled();
        String msg = null;
        if(debug) msg = "getValidityForInternalPipeline(" + index + "): ";
View Full Code Here

        // Source exists
        Object[] values = (Object[])this.mountTables.get(uri);
       
        if (values != null) {
            // Check validity
            SourceValidity oldValidity = (SourceValidity)values[1];
           
            int valid = oldValidity != null ? oldValidity.isValid() : SourceValidity.INVALID;
           
            if (valid == SourceValidity.VALID) {
                // Valid without needing the new validity
                return (Map)values[0];
            }
           
            if (valid == SourceValidity.UNKNOWN &&
                oldValidity.isValid(source.getValidity()) == SourceValidity.VALID) {
                // Valid after comparing with the new validity
                return (Map)values[0];
            }
           
            // Invalid: fallback below to read the mount table
View Full Code Here

            int valid = this.validity == null? SourceValidity.INVALID: this.validity.isValid();
            if (valid != SourceValidity.VALID) {
                // Saved validity is not valid, get new source and validity
                resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
                source = resolver.resolveURI(sourceURL);
                SourceValidity sourceValidity = source.getValidity();
                if (valid == SourceValidity.INVALID || this.validity.isValid(sourceValidity) != SourceValidity.VALID) {
                    HashMap values = new HashMap();
                    SourceUtil.toSAX(source, new SAXContentHandler(values));
                    this.validity = sourceValidity;
                    this.values = values;
View Full Code Here

                    int valid = this.validity == null? SourceValidity.INVALID: this.validity.isValid();
                    if (valid != SourceValidity.VALID) {
                        // Get new source and validity
                        src = resolver.resolveURI(this.uri);
                        SourceValidity newValidity = src.getValidity();
                        // If already invalid, or invalid after validities comparison, reload
                        if (valid == SourceValidity.INVALID || this.validity.isValid(newValidity) != SourceValidity.VALID) {
                            if (logger.isDebugEnabled()) {
                                logger.debug("Reloading document... uri " + this.uri);
                            }
View Full Code Here

                this.toCacheSourceValidities =
                    new SourceValidity[this.toCacheKey.size()];
                int len = this.toCacheSourceValidities.length;
                int i = 0;
                while (i < len) {
                    final SourceValidity validity =
                        this.getValidityForInternalPipeline(i);

                    if (validity == null) {
                        if (i > 0
                            && (this.fromCacheKey == null
View Full Code Here

                while (responseIsValid && i < fromCacheValidityObjects.length) {
                    boolean isValid = false;

                    // BH Check if validities[i] is null, may happen
                    //    if exception was thrown due to malformed content
                    SourceValidity validity = fromCacheValidityObjects[i];
                    int valid = validity == null ? SourceValidity.INVALID : validity.isValid();
                    if (valid == SourceValidity.UNKNOWN) {
                        // Don't know if valid, make second test
                        validity = getValidityForInternalPipeline(i);
                        if (validity != null) {
                            valid = fromCacheValidityObjects[i].isValid(validity);
View Full Code Here

    protected boolean processReader(Environment  environment)
    throws ProcessingException {
        try {
            boolean usedCache = false;
            OutputStream outputStream = null;
            SourceValidity readerValidity = null;
            PipelineCacheKey pcKey = null;

            // test if reader is cacheable
            Serializable readerKey = null;
            boolean isCacheableProcessingComponent = false;
            if (super.reader instanceof CacheableProcessingComponent) {
                readerKey = ((CacheableProcessingComponent)super.reader).getKey();
                isCacheableProcessingComponent = true;
            } else if (super.reader instanceof Cacheable) {
                readerKey = new Long(((Cacheable)super.reader).generateKey());
            }

            if (readerKey != null) {
                // response is cacheable, build the key
                pcKey = new PipelineCacheKey();
                pcKey.addKey(new ComponentCacheKey(ComponentCacheKey.ComponentType_Reader,
                                                   this.readerRole,
                                                   readerKey)
                            );

                // now we have the key to get the cached object
                CachedResponse cachedObject = this.cache.get(pcKey);
                if (cachedObject != null) {
                    if (getLogger().isDebugEnabled()) {
                        getLogger().debug("Found cached response for '" +
                                          environment.getURI() + "' using key: " + pcKey);
                    }

                    SourceValidity[] validities = cachedObject.getValidityObjects();
                    if (validities == null || validities.length != 1) {
                        // to avoid getting here again and again, we delete it
                        this.cache.remove(pcKey);
                        if (getLogger().isDebugEnabled()) {
                            getLogger().debug("Cached response for '" + environment.getURI() +
                                              "' using key: " + pcKey + " is invalid.");
                        }
                        this.cachedResponse = null;
                    } else {
                        SourceValidity cachedValidity = validities[0];
                        boolean isValid = false;
                        int valid = cachedValidity.isValid();
                        if (valid == SourceValidity.UNKNOWN) {
                            // get reader validity and compare
                            if (isCacheableProcessingComponent) {
                                readerValidity = ((CacheableProcessingComponent) super.reader).getValidity();
                            } else {
                                CacheValidity cv = ((Cacheable) super.reader).generateValidity();
                                if (cv != null) {
                                    readerValidity = CacheValidityToSourceValidity.createValidity(cv);
                                }
                            }
                            if (readerValidity != null) {
                                valid = cachedValidity.isValid(readerValidity);
                                if (valid == SourceValidity.UNKNOWN) {
                                    readerValidity = null;
                                } else {
                                    isValid = (valid == SourceValidity.VALID);
                                }
View Full Code Here

        return null;
    }

    SourceValidity getValidityForInternalPipeline(int index) {
        final SourceValidity validity;

        // if debugging try to tell why something is not cacheable
        final boolean debug = this.getLogger().isDebugEnabled();
        String msg = null;
        if(debug) msg = "getValidityForInternalPipeline(" + index + "): ";
View Full Code Here

TOP

Related Classes of org.apache.excalibur.source.SourceValidity

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.