Package org.pentaho.reporting.libraries.resourceloader.cache

Examples of org.pentaho.reporting.libraries.resourceloader.cache.ResourceBundleDataCache


   * @return the resourceloader for that key, or null, if no resource-loader is able to process the key.
   * @throws ResourceLoadingException if an error occured.
   */
  public synchronized ResourceBundleData loadResourceBundle(final ResourceKey key) throws ResourceLoadingException
  {
    final ResourceBundleDataCache bundleCache = getBundleCache();
    final ResourceBundleDataCacheEntry cached = bundleCache.get(key);
    if (cached != null)
    {
      final ResourceBundleData data = cached.getData();
      // check, whether it is valid.

      final long version = data.getVersion(this);
      if ((cached.getStoredVersion() < 0) ||
          (version >= 0 && cached.getStoredVersion() == version))
      {
        // now also make sure that the underlying data has not changed.
        // This may look a bit superfluous, but the repository may not provide
        // sensible cacheable information.
        //
        // As condition of satisfaction, try to find the first piece of data that
        // is in the cache and see whether it has changed.
        ResourceKey bundleKey = data.getBundleKey();
        int counter = 1;
        while (bundleKey != null)
        {
          final ResourceDataCacheEntry bundleRawDataCacheEntry = getDataCache().get(bundleKey);
          if (bundleRawDataCacheEntry != null)
          {
            final ResourceData bundleRawData = bundleRawDataCacheEntry.getData();
            if (bundleRawData != null)
            {
              if (isValidData(bundleRawDataCacheEntry, bundleRawData))
              {
                logger.debug("Returning cached entry [" + counter + "]");
                return data;
              }
              getDataCache().remove(bundleRawData);
            }
          }
          bundleKey = bundleKey.getParent();
          counter += 1;
        }
      }
      bundleCache.remove(data);
    }

    final ResourceBundleData data = backend.loadResourceBundle(this, key);
    if (data != null && isResourceDataCacheable(data))
    {
      bundleCache.put(this, data);
    }
    return data;
  }
View Full Code Here


  {
    try
    {
      final ObjectFactory objectFactory = LibLoaderBoot.getInstance().getObjectFactory();
      final ResourceBundleDataCacheProvider maybeDataCacheProvider = objectFactory.get(ResourceBundleDataCacheProvider.class);
      final ResourceBundleDataCache cache = maybeDataCacheProvider.createBundleDataCache();
      if (cache != null)
      {
        setBundleCache(cache);
      }
    }
View Full Code Here

    }
   
    final ResourceBundleDataCacheProvider provider = (ResourceBundleDataCacheProvider) maybeDataCacheProvider;
    try
      {
        final ResourceBundleDataCache cache = provider.createBundleDataCache();
      if (cache != null)
      {
        setBundleCache(cache);
      }
    }
View Full Code Here

   * @return the resourceloader for that key, or null, if no resource-loader is able to process the key.
   * @throws ResourceLoadingException if an error occured.
   */
  public synchronized ResourceBundleData loadResourceBundle(final ResourceKey key) throws ResourceLoadingException
  {
    final ResourceBundleDataCache bundleCache = getBundleCache();
    final ResourceBundleDataCacheEntry cached = bundleCache.get(key);
    if (cached != null)
    {
      final ResourceBundleData data = cached.getData();
      // check, whether it is valid.

      final long version = data.getVersion(this);
      if ((cached.getStoredVersion() < 0) ||
          (version >= 0 && cached.getStoredVersion() == version))
      {
        // now also make sure that the underlying data has not changed.
        // This may look a bit superfluous, but the repository may not provide
        // sensible cacheable information.
        final ResourceDataCacheEntry bundleRawDataCacheEntry = getDataCache().get(data.getBundleKey());
        if (bundleRawDataCacheEntry != null)
        {
          final ResourceData bundleRawData = bundleRawDataCacheEntry.getData();
          if (bundleRawData != null)
          {
            if (isValidData(bundleRawDataCacheEntry, bundleRawData))
            {
              return data;
            }
            getDataCache().remove(bundleRawData);
          }
        }
      }
      bundleCache.remove(data);
    }

    final ResourceBundleData data = backend.loadResourceBundle(this, key);
    if (data != null)
    {
      bundleCache.put(this, data);
    }
    return data;
  }
View Full Code Here

TOP

Related Classes of org.pentaho.reporting.libraries.resourceloader.cache.ResourceBundleDataCache

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.