Author: pete
Date: Thu Jun 30 10:38:05 2011
New Revision: 1141470

URL: http://svn.apache.org/viewvc?rev=1141470&view=rev
Log:
WICKET-3846 javadoc + minor changes

Modified:
    
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/request/resource/caching/FilenameWithVersionResourceCachingStrategy.java
    
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/request/resource/caching/NoOpResourceCachingStrategy.java
    
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/request/resource/caching/QueryStringWithVersionResourceCachingStrategy.java
    
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/request/resource/caching/version/CacheResourceVersionKey.java
    
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/request/resource/caching/version/CachingResourceVersion.java
    
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/request/resource/caching/version/LastModifiedResourceVersion.java
    
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/request/resource/caching/version/MessageDigestResourceVersion.java
    
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/request/resource/caching/version/RequestCycleCachedResourceVersion.java
    
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/request/resource/caching/version/StaticResourceVersion.java

Modified: 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/request/resource/caching/FilenameWithVersionResourceCachingStrategy.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/main/java/org/apache/wicket/request/resource/caching/FilenameWithVersionResourceCachingStrategy.java?rev=1141470&r1=1141469&r2=1141470&view=diff
==============================================================================
--- 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/request/resource/caching/FilenameWithVersionResourceCachingStrategy.java
 (original)
+++ 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/request/resource/caching/FilenameWithVersionResourceCachingStrategy.java
 Thu Jun 30 10:38:05 2011
@@ -23,18 +23,19 @@ import org.apache.wicket.request.resourc
 import org.apache.wicket.util.lang.Args;
 
 /**
- * resource caching strategy that adds a version string for the 
+ * resource caching strategy that adds a version for the 
  * requested resource to the filename.
  * <p/>
  * versioned_filename := [basename][version-prefix][version](.extension)
  * <p/>
  * the <code>version</code> must not contain the <code>version-prefix</code> so
- * please use an unambigous value for the <code>version-prefix</code>.
+ * please use an unambigous value for the <code>version-prefix</code>. The 
default
+ * <code>version-prefix</code> is <code>{@value 
#DEFAULT_VERSION_PREFIX}</code>.
  * <p/> 
- * Since browsers and proxies use the versioned filename of the resource url 
- * as a cache key a change to the version will cause a cache miss and 
subsequent 
- * reload of the updated version. This enables us to set the caching duration
- * of the resource to a maximum.
+ * Since browsers and proxies use the versioned filename of the resource 
+ * as a cache key a change to the version will also change the filename and 
+ * cause a reliable cache miss. This enables us to set the caching duration
+ * of the resource to a maximum and get best network performance.
  * <p/>
  * 
  * @author Peter Ertl
@@ -45,22 +46,20 @@ public class FilenameWithVersionResource
 {
        private static final String DEFAULT_VERSION_PREFIX = "-ver-";
        
-       /** 
-        * prefix that marks the beginning the of the version 
-        * string contained in the decorated resource filename 
-        * */
+       /** string that marks the beginning the of the version in the decorated 
filename */
        private final String versionPrefix;
 
-       /**
-        * resource version provider
-        */
+       /** resource version provider */
        private final IResourceVersion resourceVersion;
 
        /**
-        * Constructor
+        * create filename caching strategy with given version provider and 
+        * <code>version-prefix = '{@value #DEFAULT_VERSION_PREFIX}'</code>
         * 
         * @param resourceVersion
-        *            resource version object
+        *            version provider
+        *            
+        * @see #FilenameWithVersionResourceCachingStrategy(String, 
org.apache.wicket.request.resource.caching.version.IResourceVersion) 
         */
        public FilenameWithVersionResourceCachingStrategy(IResourceVersion 
resourceVersion)
        {
@@ -71,10 +70,11 @@ public class FilenameWithVersionResource
         * Constructor
         * 
         * @param versionPrefix
-        *            string appended after the base filename before the 
version string
-        *            and followed by the extension            
+        *            string that marks the beginning the of the version in the 
decorated filename 
         * @param resourceVersion
         *            resource version object
+        * 
+        * @see 
#FilenameWithVersionResourceCachingStrategy(org.apache.wicket.request.resource.caching.version.IResourceVersion)
 
         */
        public FilenameWithVersionResourceCachingStrategy(String versionPrefix,
                                                          IResourceVersion 
resourceVersion)

Modified: 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/request/resource/caching/NoOpResourceCachingStrategy.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/main/java/org/apache/wicket/request/resource/caching/NoOpResourceCachingStrategy.java?rev=1141470&r1=1141469&r2=1141470&view=diff
==============================================================================
--- 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/request/resource/caching/NoOpResourceCachingStrategy.java
 (original)
+++ 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/request/resource/caching/NoOpResourceCachingStrategy.java
 Thu Jun 30 10:38:05 2011
@@ -20,9 +20,9 @@ import org.apache.wicket.request.resourc
 import org.apache.wicket.request.resource.PackageResourceReference;
 
 /**
- * resource caching strategy that does nothing
+ * resource caching strategy that does nothing at all
  * <p/>
- * caching will resources will effectively be disabled
+ * when using this strategy caching of resources will effectively be disabled
  * 
  * @author Peter Ertl
  * 

Modified: 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/request/resource/caching/QueryStringWithVersionResourceCachingStrategy.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/main/java/org/apache/wicket/request/resource/caching/QueryStringWithVersionResourceCachingStrategy.java?rev=1141470&r1=1141469&r2=1141470&view=diff
==============================================================================
--- 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/request/resource/caching/QueryStringWithVersionResourceCachingStrategy.java
 (original)
+++ 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/request/resource/caching/QueryStringWithVersionResourceCachingStrategy.java
 Thu Jun 30 10:38:05 2011
@@ -24,15 +24,21 @@ import org.apache.wicket.request.resourc
 import org.apache.wicket.util.lang.Args;
 
 /**
- * resource caching strategy that adds a last-modified timestamp to the query 
string of the resource
- * (this is similar to how wicket 1.4 does it when enabling timestamps on 
resources).
+ * resource caching strategy that adds a version string to the query 
parameters of the resource
+ * (this is similar to how wicket 1.4 does it when enabling timestamps on 
resources). You should
+ * preferably use {@link FilenameWithVersionResourceCachingStrategy} since it 
is more reliable. 
  * 
  * @author Peter Ertl
+ *
+ * @see FilenameWithVersionResourceCachingStrategy
  * 
  * @since 1.5
  */
 public class QueryStringWithVersionResourceCachingStrategy implements 
IResourceCachingStrategy
 {
+       /**
+        * default query parameter for version information
+        */
        private static final String DEFAULT_VERSION_PARAMETER = "ver";
 
        /**
@@ -46,7 +52,10 @@ public class QueryStringWithVersionResou
        private final IResourceVersion resourceVersion;
 
        /**
-        * Constructor
+        * create query string resource caching strategy
+        * <p/>
+        * it will use a query parameter named <code>{@value 
#DEFAULT_VERSION_PARAMETER}</code>
+        * for storing the version information.
         * 
         * @param resourceVersion
         *                resource version provider
@@ -57,23 +66,26 @@ public class QueryStringWithVersionResou
        }
 
        /**
-        * Constructor
+        * create query string resource caching strategy
+        * <p/>
+        * it will use a query parameter with name specified by 
+        * parameter <code>resourceVersion</code> for storing the version 
information.
         *
         * @param versionParameter
-        *            name of timestamp parameter which will be added to query 
string
-        *            and contain the resource version string
+        *            name of version parameter which will be added to query 
string
+        *            containing the resource version
         * @param resourceVersion
         *                resource version provider
         */
        public QueryStringWithVersionResourceCachingStrategy(String 
versionParameter, 
                                                             IResourceVersion 
resourceVersion)
        {
-               this.versionParameter = Args.notEmpty(versionParameter, 
"timestampParameter");
+               this.versionParameter = Args.notEmpty(versionParameter, 
"versionParameter");
                this.resourceVersion = Args.notNull(resourceVersion, 
"resourceVersion");
        }
 
        /**
-        * @return name of timestamp parameter which will be added to query 
string
+        * @return name of version parameter which will be added to query string
         */
        public final String getVersionParameter()
        {

Modified: 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/request/resource/caching/version/CacheResourceVersionKey.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/main/java/org/apache/wicket/request/resource/caching/version/CacheResourceVersionKey.java?rev=1141470&r1=1141469&r2=1141470&view=diff
==============================================================================
--- 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/request/resource/caching/version/CacheResourceVersionKey.java
 (original)
+++ 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/request/resource/caching/version/CacheResourceVersionKey.java
 Thu Jun 30 10:38:05 2011
@@ -22,21 +22,48 @@ import java.util.Locale;
 import org.apache.wicket.request.resource.PackageResourceReference;
 import org.apache.wicket.util.lang.Args;
 
+/**
+ * cache key for resource lookup
+ * <p/>
+ * this key will take the localized version of the resource as a key
+ *
+ * @author Peter Ertl
+ * 
+ * @since 1.5
+ */
 public class CacheResourceVersionKey implements Serializable
 {
+       /** resource scope */
        private final Class<?> scope;
+       
+       /** resource name */
        private final String name;
+       
+       /** current locale */
        private final Locale locale;
+
+       /** current style */
        private final String style;
+       
+       /** current variation */
        private final String variation;
 
+       /**
+        * create cache key from localized resource information 
+        * 
+        * @param resourceReference
+        *           base package resource reference
+        * @param streamInfo
+        *           current localized stream information     
+        */
        public CacheResourceVersionKey(PackageResourceReference 
resourceReference,
                                       PackageResourceReference.StreamInfo 
streamInfo)
        {
                Args.notNull(resourceReference, "resourceReference");
                Args.notNull(streamInfo, "streamInfo");
-               this.scope = resourceReference.getScope();
-               this.name = resourceReference.getName();
+               
+               this.scope = Args.notNull(resourceReference.getScope(), 
"resource scope");
+               this.name = Args.notEmpty(resourceReference.getName(), 
"resource name");
                this.locale = streamInfo.locale;
                this.style = streamInfo.style;
                this.variation = streamInfo.variation;
@@ -51,16 +78,20 @@ public class CacheResourceVersionKey imp
                if (!(o instanceof CacheResourceVersionKey))
                        return false;
 
-               CacheResourceVersionKey that = (CacheResourceVersionKey)o;
+               final CacheResourceVersionKey that = (CacheResourceVersionKey)o;
 
                if (locale != null? !locale.equals(that.locale) : that.locale 
!= null)
                        return false;
+               
                if (!name.equals(that.name))
                        return false;
+               
                if (!scope.equals(that.scope))
                        return false;
+               
                if (style != null? !style.equals(that.style) : that.style != 
null)
                        return false;
+               
                if (variation != null? !variation.equals(that.variation) : 
that.variation != null)
                        return false;
 

Modified: 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/request/resource/caching/version/CachingResourceVersion.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/main/java/org/apache/wicket/request/resource/caching/version/CachingResourceVersion.java?rev=1141470&r1=1141469&r2=1141470&view=diff
==============================================================================
--- 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/request/resource/caching/version/CachingResourceVersion.java
 (original)
+++ 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/request/resource/caching/version/CachingResourceVersion.java
 Thu Jun 30 10:38:05 2011
@@ -28,6 +28,9 @@ import org.apache.wicket.util.lang.Args;
 
 /**
  * Caches the results of a delegating {@link IResourceVersion} instance
+ * in a member variable. The cache will be valid for the lifetime of 
+ * this instance. It will expire the oldest entries if the maximum number 
+ * of entries is exceeded.
  * 
  * @autor Peter Ertl
  * 
@@ -35,19 +38,45 @@ import org.apache.wicket.util.lang.Args;
  */
 public class CachingResourceVersion implements IResourceVersion
 {
+       /**
+        * default maximum entries in cache
+        */
        private static final int DEFAULT_MAX_CACHE_ENTRIES = 5000;
+
+       /**
+        * null value replacement holder for storing <code>null</code> in the 
map 
+        */
        private static final String NULL_VALUE = "null";
 
+       /**
+        * delegating resource version provider
+        */
        private final IResourceVersion delegate;
+
+       /**
+        * cache for resource versions
+        */
        private final Map<CacheResourceVersionKey, String> cache;
 
+       /**
+        * create version cache
+        * <p/>
+        * the cache will accept up to {@value #DEFAULT_MAX_CACHE_ENTRIES} 
before 
+        * evicting the oldest entries.
+        * 
+        * @param delegate
+        *           delegating resource version provider
+        */
        public CachingResourceVersion(IResourceVersion delegate)
        {
                this(delegate, DEFAULT_MAX_CACHE_ENTRIES);
        }
 
        /**
-        * constructor
+        * create version cache
+        * <p/>
+        * the cache will accept a maximum number of entries specified
+        * by <code>maxEntries</code> before evicting the oldest entries.
         * 
         * @param delegate
         *          resource version provider
@@ -63,33 +92,44 @@ public class CachingResourceVersion impl
 
        public String getVersion(PackageResourceReference resourceReference)
        {
+               // get current stream information for package resource
                PackageResourceReference.StreamInfo streamInfo = 
resourceReference.getCurrentStreamInfo();
                
+               // if no stream info is available we can not provide a version
                if(streamInfo == null)
                {
                        return null;
                }
 
+               // cache key
                final CacheResourceVersionKey key = new 
CacheResourceVersionKey(resourceReference, streamInfo);
 
+               // lookup version in cache
                String version = cache.get(key);
 
+               // if not found
                if (version == null)
                {
+                       // get version from delegate
                        version = delegate.getVersion(resourceReference);
 
+                       // replace null values with holder
                        if (version == null)
                        {
                                version = NULL_VALUE;
                        }
+                       // update cache
                        cache.put(key, version);
                }
 
                //noinspection StringEquality
                if (version == NULL_VALUE)
                {
+                       // replace holder with null value
                        return null;
                }
+               
+               // return version string
                return version;
        }
 }

Modified: 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/request/resource/caching/version/LastModifiedResourceVersion.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/main/java/org/apache/wicket/request/resource/caching/version/LastModifiedResourceVersion.java?rev=1141470&r1=1141469&r2=1141470&view=diff
==============================================================================
--- 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/request/resource/caching/version/LastModifiedResourceVersion.java
 (original)
+++ 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/request/resource/caching/version/LastModifiedResourceVersion.java
 Thu Jun 30 10:38:05 2011
@@ -21,8 +21,8 @@ import org.apache.wicket.request.resourc
 import org.apache.wicket.util.time.Time;
 
 /**
- * Uses the last modified timestamp of a {@link ResourceReference} 
- * in milliseconds as a version string.
+ * Uses the last modified timestamp of a {@link PackageResourceReference} 
+ * converted to milliseconds as a version string.
  *
  * @author Peter Ertl
  *
@@ -32,12 +32,15 @@ public class LastModifiedResourceVersion
 {
        public String getVersion(PackageResourceReference resourceReference)
        {
+               // get last modified timestamp of resource
                final Time lastModified = resourceReference.getLastModified();
 
+               // if no timestamp is available we can not provide a version
                if (lastModified == null)
                {
                        return null;
                }
+               // version string = last modified timestamp converted to 
milliseconds
                return String.valueOf(lastModified.getMilliseconds());
        }
 }

Modified: 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/request/resource/caching/version/MessageDigestResourceVersion.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/main/java/org/apache/wicket/request/resource/caching/version/MessageDigestResourceVersion.java?rev=1141470&r1=1141469&r2=1141470&view=diff
==============================================================================
--- 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/request/resource/caching/version/MessageDigestResourceVersion.java
 (original)
+++ 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/request/resource/caching/version/MessageDigestResourceVersion.java
 Thu Jun 30 10:38:05 2011
@@ -34,7 +34,13 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * uses the message digest of a {@link PackageResource} as a version string
+ * computes the message digest of a {@link PackageResource} 
+ * and uses it as a version string
+ * <p/>
+ * you can use any message digest algorithm that can be retrieved 
+ * by Java Cryptography Architecture (JCA) on your current platform.
+ * Check <a 
href="http://download.oracle.com/javase/1.5.0/docs/guide/security/CryptoSpec.html#AppA";>here</a>
+ * for more information on possible algorithms.
  * 
  * @author Peter Ertl
  * 
@@ -45,16 +51,25 @@ public class MessageDigestResourceVersio
        private static final Logger log = 
LoggerFactory.getLogger(MessageDigestResourceVersion.class);
 
        private static final String DEFAULT_ALGORITHM = "MD5";
-       private static final Bytes DEFAULT_BUFFER_SIZE = Bytes.bytes(8192);
+       private static final int DEFAULT_BUFFER_BYTES = 8192; // needed for 
javadoc {@value ..}
+       private static final Bytes DEFAULT_BUFFER_SIZE = 
Bytes.bytes(DEFAULT_BUFFER_BYTES);
 
-       /** message digest algorithm for computing hashes */
+       /** 
+        * message digest algorithm for computing hashes 
+        */
        private final String algorithm;
 
-       /** buffer size for computing the digest */
+       /** 
+        * buffer size for computing the digest 
+        */
        private final Bytes bufferSize;
 
        /**
-        * create an instance using {@value #DEFAULT_ALGORITHM}
+        * create an instance of the message digest 
+        * resource version provider using algorithm {@value #DEFAULT_ALGORITHM}
+        * 
+        * @see #MessageDigestResourceVersion(String) 
+        * @see #MessageDigestResourceVersion(String, 
org.apache.wicket.util.lang.Bytes)
         */
        public MessageDigestResourceVersion()
        {
@@ -62,12 +77,18 @@ public class MessageDigestResourceVersio
        }
 
        /**
-        * create an instance using an algorithm that can be retrieved by Java 
Cryptography Architecture
-        * (JCA) using {@link MessageDigest#getInstance(String)} and using an 
fixed-size internal buffer
-        * for digest computation of {@value #DEFAULT_BUFFER_SIZE} bytes.
-        * 
+        * create an instance of the message digest resource version provider 
+        * using the specified algorithm. The algorithm name must be one
+        * that can be retrieved by Java Cryptography Architecture (JCA) 
+        * using {@link MessageDigest#getInstance(String)}. For digest 
computation
+        * an internal buffer of up to {@value #DEFAULT_BUFFER_BYTES}
+        * bytes will be used.
+        *
         * @param algorithm
         *            digest algorithm
+        *
+        * @see #MessageDigestResourceVersion()
+        * @see #MessageDigestResourceVersion(String, 
org.apache.wicket.util.lang.Bytes)
         */
        public MessageDigestResourceVersion(String algorithm)
        {
@@ -75,14 +96,17 @@ public class MessageDigestResourceVersio
        }
 
        /**
-        * create an instance using an algorithm that can be retrieved by Java 
Cryptography Architecture
-        * (JCA) using {@link MessageDigest#getInstance(String)} and using an 
specified internal buffer
-        * for digest computation.
-        * 
+        * create an instance of the message digest resource version provider 
+        * using the specified algorithm. The algorithm name must be one
+        * that can be retrieved by Java Cryptography Architecture (JCA) 
+        * using {@link MessageDigest#getInstance(String)}. For digest 
computation
+        * an internal buffer with a maximum size specified by parameter 
+        * <code>bufferSize</code> will be used. 
+        *
         * @param algorithm
         *            digest algorithm
         * @param bufferSize
-        *            internal buffer size for digest computation
+        *            maximum size for internal buffer            
         */
        public MessageDigestResourceVersion(String algorithm, Bytes bufferSize)
        {
@@ -92,11 +116,12 @@ public class MessageDigestResourceVersio
 
        public String getVersion(PackageResourceReference resourceReference)
        {
+               // get current stream information for package resource
                final PackageResourceReference.StreamInfo streamInfo = 
resourceReference.getCurrentStreamInfo();
 
+               // if no stream info is available we can not provide a version
                if (streamInfo == null)
                {
-                       log.debug("could not get stream info for '{}'", 
resourceReference);
                        return null;
                }
 
@@ -156,19 +181,24 @@ public class MessageDigestResourceVersio
 
                try
                {
-                       int bufferLen = (int)Math.min(Integer.MAX_VALUE, 
bufferSize.bytes());
+                       // get actual buffer size
+                       final int bufferLen = (int)Math.min(Integer.MAX_VALUE, 
bufferSize.bytes());
+
+                       // allocate read buffer
                        final byte[] buf = new byte[bufferLen];
                        int len;
 
+                       // read stream and update message digest
                        while ((len = inputStream.read(buf)) != -1)
                        {
                                digest.update(buf, 0, len);
                        }
+                       // finish message digest and return hash
                        return digest.digest();
                }
                finally
                {
-                       IOUtils.closeQuietly(inputStream);
+                       IOUtils.close(inputStream);
                }
        }
 }

Modified: 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/request/resource/caching/version/RequestCycleCachedResourceVersion.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/main/java/org/apache/wicket/request/resource/caching/version/RequestCycleCachedResourceVersion.java?rev=1141470&r1=1141469&r2=1141470&view=diff
==============================================================================
--- 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/request/resource/caching/version/RequestCycleCachedResourceVersion.java
 (original)
+++ 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/request/resource/caching/version/RequestCycleCachedResourceVersion.java
 Thu Jun 30 10:38:05 2011
@@ -27,8 +27,7 @@ import org.apache.wicket.util.lang.Gener
 
 /**
  * Caches the results of a delegating {@link IResourceVersion} instance
- * in the current request meta data. It will be cached for the lifetime
- * of the current http request.
+ * for the lifetime of the current http request.
  *
  * @author Peter Ertl
  *
@@ -44,12 +43,12 @@ public class RequestCycleCachedResourceV
 
        /**
         * resource version provider which will actually do 
-        * the work and retrieve the version
+        * the hard work and retrieve the version
         */
        private final IResourceVersion delegate;
 
        /**
-        * Constructor
+        * create request-scoped resource provider cache
         * 
         * @param delegate
         *           resource version provider to cache
@@ -64,16 +63,20 @@ public class RequestCycleCachedResourceV
                // get current request cycle
                final RequestCycle requestCycle = 
ThreadContext.getRequestCycle();
 
-               Map<CacheResourceVersionKey, String> cache = null;
-
-               PackageResourceReference.StreamInfo streamInfo = 
resourceReference.getCurrentStreamInfo();
+               // get current stream information for package resource
+               final PackageResourceReference.StreamInfo streamInfo = 
resourceReference.getCurrentStreamInfo();
                
+               // if no stream info is available we can not provide a version
                if(streamInfo == null)
                {
                        return null;
                }
                
-               final CacheResourceVersionKey key = new 
CacheResourceVersionKey(resourceReference, streamInfo);
+               // cache instance
+               Map<CacheResourceVersionKey, String> cache = null;
+
+               // cache key
+               CacheResourceVersionKey key = null;
 
                // is request cycle available?
                if (requestCycle != null)
@@ -92,13 +95,15 @@ public class RequestCycleCachedResourceV
                                // lookup timestamp from cache (may contain 
NULL values which are valid)
                                return cache.get(key);
                        }
+                       // create caching key
+                       key = new CacheResourceVersionKey(resourceReference, 
streamInfo);
                }
                
                // no cache entry found, query version from delegate
                final String version = delegate.getVersion(resourceReference);
 
                // store value in cache (if it is available)
-               if (cache != null)
+               if (cache != null && key != null)
                {
                        cache.put(key, version);
                }

Modified: 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/request/resource/caching/version/StaticResourceVersion.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/main/java/org/apache/wicket/request/resource/caching/version/StaticResourceVersion.java?rev=1141470&r1=1141469&r2=1141470&view=diff
==============================================================================
--- 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/request/resource/caching/version/StaticResourceVersion.java
 (original)
+++ 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/request/resource/caching/version/StaticResourceVersion.java
 Thu Jun 30 10:38:05 2011
@@ -21,7 +21,7 @@ import org.apache.wicket.request.resourc
 import org.apache.wicket.util.lang.Args;
 
 /**
- * provides a static version string for all queries resources 
+ * provides a static version string for all package resources 
  *
  * @author Peter Ertl
  *
@@ -32,7 +32,7 @@ public class StaticResourceVersion imple
        private final String version;
 
        /**
-        * Constructor
+        * create static version provider
         *
         * @param version
         *             static version string to deliver for all queries 
resources


Reply via email to