You are viewing a plain text version of this content. The canonical link for it is here.
Posted to adffaces-dev@incubator.apache.org by Jeanne Waldman <je...@oracle.com> on 2007/02/12 23:04:19 UTC

[Skinning] FileSystemStyleCache code - ok to delete?

I'm trying to figure out what's going on in FileSystemStyleCache 
regarding the caching code.

I noticed that this code is not called by anyone. Does anyone object to 
my deleting it? Or is there
some use for it so I should keep it around.


  /**
   * Returns a shared ImageProvider instance for the specified
   * XSS document and target cache directory.
   *
   * @param source The path of the source XSS document.  The
   *   specified file must be a valid XSS document.  If the specified
   *   file does not exists, an IllegalArgumentException is thrown.
   * @param target The path of the target directory.  Generated
   *   CSS files are stored in this directory.  If the directory
   *   does not exist and can not be created, an IllegalArgumentException
   *   is thrown.
   */
  public static StyleProvider getSharedCache(
    String source,
    String target
    )
  {
    // Make sure we have some source/target.
    if (source == null)
      throw new IllegalArgumentException("No source specified.");
    if (target == null)
      throw new IllegalArgumentException("No target specified.");

    // First, get the key to use to look up the cache
    String key = _getSharedCacheKey(source, target);

    // See if we've got a shared cache
    StyleProvider cache = _sSharedCaches.get(key);

    // If we didn't find a shared cache, create a new cache
    // and cache it in the shared cache cache.  :-)
    if (cache == null)
    {
      // Create the new cache
      cache = new FileSystemStyleCache(source, target);

      // Before we save the new cache, make sure another thread hasn't
      // already cached a different instance.  Synchronize to lock up
      // _sSharedCaches.
      synchronized (_sSharedCaches)
      {
        StyleProvider tmp = _sSharedCaches.get(key);
        if (tmp != null)
        {
          // Stick with tmp
          cache = tmp;
        }
        else
        {
          _sSharedCaches.put(key, cache);
        }
      }
    }

    return cache;
  }


Re: [Skinning] FileSystemStyleCache code - ok to delete?

Posted by Jeanne Waldman <je...@oracle.com>.
thanks. I'll kill it right now.

Adam Winer wrote:
> Die die die. :)
>
> Unused code should almost always go.  It can always
> be revived from source control, and if it's unused, the
> odds that it works steadily decreases as time goes on.
>
> -- Adam
>
>
> On 2/12/07, Jeanne Waldman <je...@oracle.com> wrote:
>>
>> I'm trying to figure out what's going on in FileSystemStyleCache
>> regarding the caching code.
>>
>> I noticed that this code is not called by anyone. Does anyone object to
>> my deleting it? Or is there
>> some use for it so I should keep it around.
>>
>>
>>   /**
>>    * Returns a shared ImageProvider instance for the specified
>>    * XSS document and target cache directory.
>>    *
>>    * @param source The path of the source XSS document.  The
>>    *   specified file must be a valid XSS document.  If the specified
>>    *   file does not exists, an IllegalArgumentException is thrown.
>>    * @param target The path of the target directory.  Generated
>>    *   CSS files are stored in this directory.  If the directory
>>    *   does not exist and can not be created, an 
>> IllegalArgumentException
>>    *   is thrown.
>>    */
>>   public static StyleProvider getSharedCache(
>>     String source,
>>     String target
>>     )
>>   {
>>     // Make sure we have some source/target.
>>     if (source == null)
>>       throw new IllegalArgumentException("No source specified.");
>>     if (target == null)
>>       throw new IllegalArgumentException("No target specified.");
>>
>>     // First, get the key to use to look up the cache
>>     String key = _getSharedCacheKey(source, target);
>>
>>     // See if we've got a shared cache
>>     StyleProvider cache = _sSharedCaches.get(key);
>>
>>     // If we didn't find a shared cache, create a new cache
>>     // and cache it in the shared cache cache.  :-)
>>     if (cache == null)
>>     {
>>       // Create the new cache
>>       cache = new FileSystemStyleCache(source, target);
>>
>>       // Before we save the new cache, make sure another thread hasn't
>>       // already cached a different instance.  Synchronize to lock up
>>       // _sSharedCaches.
>>       synchronized (_sSharedCaches)
>>       {
>>         StyleProvider tmp = _sSharedCaches.get(key);
>>         if (tmp != null)
>>         {
>>           // Stick with tmp
>>           cache = tmp;
>>         }
>>         else
>>         {
>>           _sSharedCaches.put(key, cache);
>>         }
>>       }
>>     }
>>
>>     return cache;
>>   }
>>
>>
>


Re: [Skinning] FileSystemStyleCache code - ok to delete?

Posted by Adam Winer <aw...@gmail.com>.
Die die die. :)

Unused code should almost always go.  It can always
be revived from source control, and if it's unused, the
odds that it works steadily decreases as time goes on.

-- Adam


On 2/12/07, Jeanne Waldman <je...@oracle.com> wrote:
>
> I'm trying to figure out what's going on in FileSystemStyleCache
> regarding the caching code.
>
> I noticed that this code is not called by anyone. Does anyone object to
> my deleting it? Or is there
> some use for it so I should keep it around.
>
>
>   /**
>    * Returns a shared ImageProvider instance for the specified
>    * XSS document and target cache directory.
>    *
>    * @param source The path of the source XSS document.  The
>    *   specified file must be a valid XSS document.  If the specified
>    *   file does not exists, an IllegalArgumentException is thrown.
>    * @param target The path of the target directory.  Generated
>    *   CSS files are stored in this directory.  If the directory
>    *   does not exist and can not be created, an IllegalArgumentException
>    *   is thrown.
>    */
>   public static StyleProvider getSharedCache(
>     String source,
>     String target
>     )
>   {
>     // Make sure we have some source/target.
>     if (source == null)
>       throw new IllegalArgumentException("No source specified.");
>     if (target == null)
>       throw new IllegalArgumentException("No target specified.");
>
>     // First, get the key to use to look up the cache
>     String key = _getSharedCacheKey(source, target);
>
>     // See if we've got a shared cache
>     StyleProvider cache = _sSharedCaches.get(key);
>
>     // If we didn't find a shared cache, create a new cache
>     // and cache it in the shared cache cache.  :-)
>     if (cache == null)
>     {
>       // Create the new cache
>       cache = new FileSystemStyleCache(source, target);
>
>       // Before we save the new cache, make sure another thread hasn't
>       // already cached a different instance.  Synchronize to lock up
>       // _sSharedCaches.
>       synchronized (_sSharedCaches)
>       {
>         StyleProvider tmp = _sSharedCaches.get(key);
>         if (tmp != null)
>         {
>           // Stick with tmp
>           cache = tmp;
>         }
>         else
>         {
>           _sSharedCaches.put(key, cache);
>         }
>       }
>     }
>
>     return cache;
>   }
>
>