Package org.apache.cocoon.caching

Examples of org.apache.cocoon.caching.CacheValidity


     *
     * @return The generated validity object or <code>null</code> if the
     *         component is currently not cachable.
     */
    public CacheValidity generateValidity() {
        CacheValidity genValidity = generator.generateValidity();
        if (genValidity != null) {
            HashMap map = new HashMap(1);
            map.put("source", this.inputSource.getSystemId());
            ParametersCacheValidity pcv = new ParametersCacheValidity(map);
            return new CompositeCacheValidity(genValidity, pcv);
View Full Code Here


   *
   * @return The generated validity object or <code>null</code> if the
   *         component is currently not cachable.
   */
  public CacheValidity generateValidity() {
    CacheValidity genValidity = generator.generateValidity();
    if (genValidity != null) {
        HashMap map = new HashMap (1);
        map.put("source", this.inputSource.getSystemId());
        ParametersCacheValidity pcv = new ParametersCacheValidity(map);
        return new CompositeCacheValidity(genValidity, pcv);
View Full Code Here

                            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);
                                    }
                                }
                            } else {
                                isValid = (valid == SourceValidity.VALID);
                            }

                            if (isValid) {
                                if (getLogger().isDebugEnabled()) {
                                    getLogger().debug("processReader: using valid cached content for '" +
                                            environment.getURI() + "'.");
                                }
                                byte[] response = cachedObject.getResponse();
                                if (response.length > 0) {
                                    usedCache = true;
                                    if (cachedObject.getContentType() != null) {
                                        environment.setContentType(cachedObject.getContentType());
                                    } else {
                                        setMimeTypeForReader(environment);
                                    }
                                    outputStream = environment.getOutputStream(0);
                                    environment.setContentLength(response.length);
                                    outputStream.write(response);
                                }
                            } else {
                                if (getLogger().isDebugEnabled()) {
                                    getLogger().debug("processReader: cached content is invalid for '" +
                                            environment.getURI() + "'.");
                                }
                                // remove invalid cached object
                                this.cache.remove(pcKey);
                            }
                        }
                    } else {
                        // check if something is being generated right now
                        if (!waitForLock(environment, pcKey)) {
                            finished = false;
                            continue;
                        }
                    }
                }
            }

            if (!usedCache) {
                // make sure lock will be released
                try {
                    if (pcKey != null) {
                        if (getLogger().isDebugEnabled()) {
                            getLogger().debug("processReader: caching content for further requests of '" +
                                    environment.getURI() + "'.");
                        }
                        generateLock(environment, pcKey);

                        if (readerValidity == null) {
                            if (isCacheableProcessingComponent) {
                                readerValidity = ((CacheableProcessingComponent)super.reader).getValidity();
                            } else {
                                CacheValidity cv = ((Cacheable)super.reader).generateValidity();
                                if ( cv != null ) {
                                    readerValidity = CacheValidityToSourceValidity.createValidity( cv );
                                }
                            }
                        }
View Full Code Here

                        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);
                                }
                            }
                        } else {
                            isValid = (valid == SourceValidity.VALID);
                        }

                        if (isValid) {
                            if (getLogger().isDebugEnabled()) {
                                getLogger().debug("processReader: using valid cached content for '" +
                                                  environment.getURI() + "'.");
                            }
                            byte[] response = cachedObject.getResponse();
                            if (response.length > 0) {
                                usedCache = true;
                                if (cachedObject.getContentType() != null) {
                                    environment.setContentType(cachedObject.getContentType());
                                } else {
                                    setMimeTypeForReader(environment);
                                }
                                outputStream = environment.getOutputStream(0);
                                environment.setContentLength(response.length);
                                outputStream.write(response);
                            }
                        } else {
                            if (getLogger().isDebugEnabled()) {
                                getLogger().debug("processReader: cached content is invalid for '" +
                                                  environment.getURI() + "'.");
                            }
                            // remove invalid cached object
                            this.cache.remove(pcKey);
                        }
                    }
                }
            }

            if (!usedCache) {
                if (pcKey != null) {
                    if (getLogger().isDebugEnabled()) {
                        getLogger().debug("processReader: caching content for further requests of '" +
                                          environment.getURI() + "'.");
                    }

                    if (readerValidity == null) {
                        if (isCacheableProcessingComponent) {
                            readerValidity = ((CacheableProcessingComponent)super.reader).getValidity();
                        } else {
                            CacheValidity cv = ((Cacheable)super.reader).generateValidity();
                            if ( cv != null ) {
                                readerValidity = CacheValidityToSourceValidity.createValidity( cv );
                            }
                        }
                    }
View Full Code Here

                        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);
                                }
                            }
                        } else {
                            valid = (result > 0);
                        }

                        if (valid) {
                            if (this.getLogger().isDebugEnabled()) {
                                this.getLogger().debug("processReader: using valid cached content for '" + environment.getURI() + "'.");
                            }
                            byte[] response = cachedObject.getResponse();
                            if (response.length > 0) {
                                usedCache = true;
                                outputStream = environment.getOutputStream(0);
                                environment.setContentLength(response.length);
                                outputStream.write(response);
                            }
                        } else {
                            if (this.getLogger().isDebugEnabled()) {
                                this.getLogger().debug("processReader: cached content is invalid for '" + environment.getURI() + "'.");
                            }
                            // remove invalid cached object
                            this.cache.remove(pcKey);
                        }
                    }
                }
            }

            if (!usedCache) {

                if ( pcKey != null ) {
                    if (this.getLogger().isDebugEnabled()) {
                        this.getLogger().debug("processReader: caching content for further requests of '" + environment.getURI() + "'.");
                    }
                    if (readerValidity == null) {
                        if (isCacheableProcessingComponent) {
                            readerValidity = ((CacheableProcessingComponent)super.reader).getValidity();
                        } else {
                            CacheValidity cv = ((Cacheable)super.reader).generateValidity();
                            if ( cv != null ) {
                                readerValidity = CacheValidityToSourceValidity.createValidity( cv );
                            }
                        }
                    }
View Full Code Here

                            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);
                                    }
                                }
                            } else {
                                isValid = (valid == SourceValidity.VALID);
                            }

                            if (isValid) {
                                if (getLogger().isDebugEnabled()) {
                                    getLogger().debug("processReader: using valid cached content for '" +
                                            environment.getURI() + "'.");
                                }
                                byte[] response = cachedObject.getResponse();
                                if (response.length > 0) {
                                    usedCache = true;
                                    if (cachedObject.getContentType() != null) {
                                        environment.setContentType(cachedObject.getContentType());
                                    } else {
                                        setMimeTypeForReader(environment);
                                    }
                                    outputStream = environment.getOutputStream(0);
                                    environment.setContentLength(response.length);
                                    outputStream.write(response);
                                }
                            } else {
                                if (getLogger().isDebugEnabled()) {
                                    getLogger().debug("processReader: cached content is invalid for '" +
                                            environment.getURI() + "'.");
                                }
                                // remove invalid cached object
                                this.cache.remove(pcKey);
                            }
                        }
                    } else {
                        // check if something is being generated right now
                        if (!waitForLock(environment, pcKey)) {
                            finished = false;
                            continue;
                        }
                    }
                }
            }

            if (!usedCache) {
                // make sure lock will be released
                try {
                    if (pcKey != null) {
                        if (getLogger().isDebugEnabled()) {
                            getLogger().debug("processReader: caching content for further requests of '" +
                                    environment.getURI() + "'.");
                        }
                        generateLock(environment, pcKey);

                        if (readerValidity == null) {
                            if (isCacheableProcessingComponent) {
                                readerValidity = ((CacheableProcessingComponent)super.reader).getValidity();
                            } else {
                                CacheValidity cv = ((Cacheable)super.reader).generateValidity();
                                if ( cv != null ) {
                                    readerValidity = CacheValidityToSourceValidity.createValidity( cv );
                                }
                            }
                        }
View Full Code Here

                            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);
                                    }
                                }
                            } else {
                                isValid = (valid == SourceValidity.VALID);
                            }

                            if (isValid) {
                                if (getLogger().isDebugEnabled()) {
                                    getLogger().debug("processReader: using valid cached content for '" +
                                            environment.getURI() + "'.");
                                }
                                byte[] response = cachedObject.getResponse();
                                if (response.length > 0) {
                                    usedCache = true;
                                    if (cachedObject.getContentType() != null) {
                                        environment.setContentType(cachedObject.getContentType());
                                    } else {
                                        setMimeTypeForReader(environment);
                                    }
                                    outputStream = environment.getOutputStream(0);
                                    environment.setContentLength(response.length);
                                    outputStream.write(response);
                                }
                            } else {
                                if (getLogger().isDebugEnabled()) {
                                    getLogger().debug("processReader: cached content is invalid for '" +
                                            environment.getURI() + "'.");
                                }
                                // remove invalid cached object
                                this.cache.remove(pcKey);
                            }
                        }
                    } else {
                        // check if something is being generated right now
                        if(!waitForLock(pcKey)) {
                            finished = false;
                            continue;
                        }
                    }
                }
            }

            if (!usedCache) {
                // make sure lock will be released
                try {
                    if (pcKey != null) {
                        if (getLogger().isDebugEnabled()) {
                            getLogger().debug("processReader: caching content for further requests of '" +
                                    environment.getURI() + "'.");
                        }
                        generateLock(pcKey);

                        if (readerValidity == null) {
                            if (isCacheableProcessingComponent) {
                                readerValidity = ((CacheableProcessingComponent)super.reader).getValidity();
                            } else {
                                CacheValidity cv = ((Cacheable)super.reader).generateValidity();
                                if ( cv != null ) {
                                    readerValidity = CacheValidityToSourceValidity.createValidity( cv );
                                }
                            }
                        }
View Full Code Here

     *
     * @return The generated validity object or <code>null</code> if the
     *         component is currently not cachable.
     */
    public CacheValidity generateValidity() {
        CacheValidity genValidity = generator.generateValidity();
        if (genValidity != null) {
            HashMap map = new HashMap (1);
            map.put("source", this.inputSource.getSystemId());
            ParametersCacheValidity pcv = new ParametersCacheValidity(map);
            return new CompositeCacheValidity(genValidity, pcv);
View Full Code Here

                          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);
                                  }
                              }
                          } else {
                              isValid = (valid == SourceValidity.VALID);
                          }
 
                          if (isValid) {
                              if (getLogger().isDebugEnabled()) {
                                  getLogger().debug("processReader: using valid cached content for '" +
                                                    environment.getURI() + "'.");
                              }
                              byte[] response = cachedObject.getResponse();
                              if (response.length > 0) {
                                  usedCache = true;
                                  if (cachedObject.getContentType() != null) {
                                      environment.setContentType(cachedObject.getContentType());
                                  } else {
                                      setMimeTypeForReader(environment);
                                  }
                                  outputStream = environment.getOutputStream(0);
                                  environment.setContentLength(response.length);
                                  outputStream.write(response);
                              }
                          } else {
                              if (getLogger().isDebugEnabled()) {
                                  getLogger().debug("processReader: cached content is invalid for '" +
                                                    environment.getURI() + "'.");
                              }
                              // remove invalid cached object
                              this.cache.remove(pcKey);
                          }
                      }
                  } else {
                    // check if something is being generated right now
                    if(!waitForLock(pcKey)) {
                      finished = false;
                      continue;
                    }
                  }
              }
            }

            if (!usedCache) {
              // make sure lock will be released
              try {
                  if (pcKey != null) {
                      if (getLogger().isDebugEnabled()) {
                          getLogger().debug("processReader: caching content for further requests of '" +
                                            environment.getURI() + "'.");
                      }
                      generateLock(pcKey);
                     
                      if (readerValidity == null) {
                          if (isCacheableProcessingComponent) {
                              readerValidity = ((CacheableProcessingComponent)super.reader).getValidity();
                          } else {
                              CacheValidity cv = ((Cacheable)super.reader).generateValidity();
                              if ( cv != null ) {
                                  readerValidity = CacheValidityToSourceValidity.createValidity( cv );
                              }
                          }
                      }
View Full Code Here

                        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);
                                }
                            }
                        } else {
                            isValid = (valid == SourceValidity.VALID);
                        }

                        if (isValid) {
                            if (getLogger().isDebugEnabled()) {
                                getLogger().debug("processReader: using valid cached content for '" +
                                                  environment.getURI() + "'.");
                            }
                            byte[] response = cachedObject.getResponse();
                            if (response.length > 0) {
                                usedCache = true;
                                if (cachedObject.getContentType() != null) {
                                    environment.setContentType(cachedObject.getContentType());
                                } else {
                                    setMimeTypeForReader(environment);
                                }
                                outputStream = environment.getOutputStream(0);
                                environment.setContentLength(response.length);
                                outputStream.write(response);
                            }
                        } else {
                            if (getLogger().isDebugEnabled()) {
                                getLogger().debug("processReader: cached content is invalid for '" +
                                                  environment.getURI() + "'.");
                            }
                            // remove invalid cached object
                            this.cache.remove(pcKey);
                        }
                    }
                }
            }

            if (!usedCache) {
                if (pcKey != null) {
                    if (getLogger().isDebugEnabled()) {
                        getLogger().debug("processReader: caching content for further requests of '" +
                                          environment.getURI() + "'.");
                    }

                    if (readerValidity == null) {
                        if (isCacheableProcessingComponent) {
                            readerValidity = ((CacheableProcessingComponent)super.reader).getValidity();
                        } else {
                            CacheValidity cv = ((Cacheable)super.reader).generateValidity();
                            if ( cv != null ) {
                                readerValidity = CacheValidityToSourceValidity.createValidity( cv );
                            }
                        }
                    }
View Full Code Here

TOP

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

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.