Package org.apache.excalibur.source

Examples of org.apache.excalibur.source.SourceValidity


      valid = sourceValidity.isValid();
      if (valid == SourceValidity.VALID)
        return new Object[]{Boolean.TRUE, null};
    }

    SourceValidity newValidity = adapter.getValidity(key);
   
    // source does not exist so it is valid
    if (newValidity == null)
      return new Object[]{Boolean.TRUE, null};
   
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 || i > this.fromCacheKey.size())) {
                            // shorten key
View Full Code Here

                int i = 0;
                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 ? validity.isValid() : -1;
                    if ( valid == 0) { // don't know if valid, make second test
                      
                        validity = this.getValidityForInternalPipeline(i);

                        if (validity != null) {
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 = (CachedResponse)this.cache.get( pcKey );

                if (cachedObject != null) {
                    if (this.getLogger().isDebugEnabled()) {
                        this.getLogger().debug(
                            "Found cached response for '" + environment.getURI() +
                            "' using key: " + pcKey
                        );
                    }
                    SourceValidity[] validities = cachedObject.getValidityObjects();
                    if (validities == null || validities.length != 1) {
                        throw new ProcessingException("Cached response is not correct.");
                    }
                    SourceValidity cachedValidity = validities[0];
                    int result = cachedValidity.isValid();
                    boolean valid = false;
                    if ( result == 0 ) {
                        // 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) {
                            result = cachedValidity.isValid(readerValidity);
                            if ( result == 0 ) {
                                readerValidity = null;
                            } else {
                                valid = (result == 1);
                            }
View Full Code Here

    /**
     *
     * @see org.apache.cocoon.components.pipeline.ProcessingPipeline#getValidityForInternalPipeline(int)
     */
    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

        return formDefinition;
    }

    private FormDefinition getStoredFormDefinition(Source source) {
        String key = "WoodyForm:" + source.getURI();
        SourceValidity newValidity = source.getValidity();

        if (newValidity == null) {
            store.remove(key);
            return null;
        }

        Object[] formDefinitionAndValidity = (Object[])store.get(key);
        if (formDefinitionAndValidity == null)
            return null;

        SourceValidity storedValidity = (SourceValidity)formDefinitionAndValidity[1];
        int valid = storedValidity.isValid();
        boolean isValid;
        if (valid == 0) {
            valid = storedValidity.isValid(newValidity);
            isValid = (valid == 1);
        } else {
            isValid = (valid == 1);
        }
View Full Code Here

        return (FormDefinition)formDefinitionAndValidity[0];
    }

    private void storeFormDefinition(FormDefinition formDefinition, Source source) throws IOException {
        String key = "WoodyForm:" + source.getURI();
        SourceValidity validity = source.getValidity();
        if (validity != null) {
            Object[] formDefinitionAndValidity = {formDefinition,  validity};
            store.store(key, formDefinitionAndValidity);
        }
    }
View Full Code Here

        try {
            AggregatedValidity v = new AggregatedValidity();
            Source current;
            for (int i = 0; i < this.parts.size(); i++) {
                current = ((Part)this.parts.get(i)).source;
                SourceValidity sv = current.getValidity();
                if (sv == null) {
                    return null;
                } else {
                    v.add(sv);
                }
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

                        m_lm.build(loadConfiguration(source));
                    }
                }
            }
            else {
                SourceValidity valid = source.getValidity();
                if (m_srcVal != null && m_srcVal.isValid(valid) != 1) {
                    synchronized (this) {
                        if (m_srcVal != null && m_srcVal.isValid(valid) != 1) {
                            if (getLogger().isDebugEnabled()) {
                                getLogger().debug("reloading location map at " + m_src);
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.