Author: jdonnerstag
Date: Sun Nov 14 08:56:07 2010
New Revision: 1034959

URL: http://svn.apache.org/viewvc?rev=1034959&view=rev
Log:
fixed WICKET-2713 Locate .properties files using the same convention as markup 
files

and some minor cleanup
Issue: WICKET-2713

Modified:
    
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/hangman/WordGenerator.java
    
wicket/trunk/wicket-util/src/main/java/org/apache/wicket/util/resource/IResourceStream.java
    
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/DefaultMarkupResourceStreamProvider.java
    
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/border/MarkupComponentBorder.java
    
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/transformer/XsltTransformer.java
    
wicket/trunk/wicket/src/main/java/org/apache/wicket/request/resource/PackageResource.java
    wicket/trunk/wicket/src/main/java/org/apache/wicket/resource/Properties.java
    
wicket/trunk/wicket/src/main/java/org/apache/wicket/resource/PropertiesFactory.java
    
wicket/trunk/wicket/src/main/java/org/apache/wicket/resource/loader/ComponentStringResourceLoader.java
    
wicket/trunk/wicket/src/main/java/org/apache/wicket/resource/loader/PackageStringResourceLoader.java
    
wicket/trunk/wicket/src/main/java/org/apache/wicket/util/resource/PackageResourceStream.java
    
wicket/trunk/wicket/src/main/java/org/apache/wicket/util/resource/locator/IResourceStreamLocator.java
    
wicket/trunk/wicket/src/main/java/org/apache/wicket/util/resource/locator/ResourceNameIterator.java
    
wicket/trunk/wicket/src/main/java/org/apache/wicket/util/resource/locator/ResourceStreamLocator.java
    
wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/MarkupParserTest.java
    
wicket/trunk/wicket/src/test/java/org/apache/wicket/resource/loader/ComponentStringResourceLoaderTest.java
    
wicket/trunk/wicket/src/test/java/org/apache/wicket/util/resource/ResourceTest.java

Modified: 
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/hangman/WordGenerator.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/hangman/WordGenerator.java?rev=1034959&r1=1034958&r2=1034959&view=diff
==============================================================================
--- 
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/hangman/WordGenerator.java
 (original)
+++ 
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/hangman/WordGenerator.java
 Sun Nov 14 08:56:07 2010
@@ -54,7 +54,7 @@ public class WordGenerator implements IC
                {
                        final IResourceStream resource = new 
ResourceStreamLocator().locate(null,
                                "org/apache/wicket/examples/hangman/WordList", 
null, null, Locale.getDefault(),
-                               ".txt");
+                               ".txt", false);
                        final String wordlist = 
Streams.readString(resource.getInputStream());
                        words = Arrays.asList(wordlist.split("\\s+"));
                        shuffle();

Modified: 
wicket/trunk/wicket-util/src/main/java/org/apache/wicket/util/resource/IResourceStream.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket-util/src/main/java/org/apache/wicket/util/resource/IResourceStream.java?rev=1034959&r1=1034958&r2=1034959&view=diff
==============================================================================
--- 
wicket/trunk/wicket-util/src/main/java/org/apache/wicket/util/resource/IResourceStream.java
 (original)
+++ 
wicket/trunk/wicket-util/src/main/java/org/apache/wicket/util/resource/IResourceStream.java
 Sun Nov 14 08:56:07 2010
@@ -81,7 +81,7 @@ public interface IResourceStream extends
        Locale getLocale();
 
        /**
-        * This method shouldn't be used for the outside, It is used by the 
Loaders to set the resolved
+        * This method shouldn't be used from the outside. It is used by the 
Loaders to set the resolved
         * locale.
         * 
         * @param locale
@@ -95,7 +95,7 @@ public interface IResourceStream extends
        String getStyle();
 
        /**
-        * This method shouldn't be used for the outside, It is used by the 
Loaders to set the resolved
+        * This method shouldn't be used from the outside. It is used by the 
Loaders to set the resolved
         * Style.
         * 
         * @param style
@@ -109,7 +109,7 @@ public interface IResourceStream extends
        String getVariation();
 
        /**
-        * This method shouldn't be used for the outside, It is used by the 
Loaders to set the resolved
+        * This method shouldn't be used from the outside. It is used by the 
Loaders to set the resolved
         * variation.
         * 
         * @param variation

Modified: 
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/DefaultMarkupResourceStreamProvider.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/DefaultMarkupResourceStreamProvider.java?rev=1034959&r1=1034958&r2=1034959&view=diff
==============================================================================
--- 
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/DefaultMarkupResourceStreamProvider.java
 (original)
+++ 
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/DefaultMarkupResourceStreamProvider.java
 Sun Nov 14 08:56:07 2010
@@ -81,7 +81,7 @@ public class DefaultMarkupResourceStream
                {
                        String path = containerClass.getName().replace('.', 
'/');
                        IResourceStream resourceStream = 
locator.locate(container.getClass(), path, style,
-                               variation, locale, ext);
+                               variation, locale, ext, false);
 
                        // Did we find it already?
                        if (resourceStream != null)

Modified: 
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/border/MarkupComponentBorder.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/border/MarkupComponentBorder.java?rev=1034959&r1=1034958&r2=1034959&view=diff
==============================================================================
--- 
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/border/MarkupComponentBorder.java
 (original)
+++ 
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/border/MarkupComponentBorder.java
 Sun Nov 14 08:56:07 2010
@@ -195,7 +195,7 @@ public class MarkupComponentBorder exten
                {
                        String path = containerClass.getName().replace('.', 
'/');
                        IResourceStream resourceStream = 
locator.locate(containerClass, path, style, variation,
-                               locale, markupType);
+                               locale, markupType, false);
 
                        // Did we find it already?
                        if (resourceStream != null)

Modified: 
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/transformer/XsltTransformer.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/transformer/XsltTransformer.java?rev=1034959&r1=1034958&r2=1034959&view=diff
==============================================================================
--- 
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/transformer/XsltTransformer.java
 (original)
+++ 
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/transformer/XsltTransformer.java
 Sun Nov 14 08:56:07 2010
@@ -143,9 +143,11 @@ public class XsltTransformer implements 
                                "/" + component.getId();
                }
 
-               resourceStream = 
Application.get().getResourceSettings().getResourceStreamLocator().locate(
-                       getClass(), filePath, component.getStyle(), 
component.getVariation(),
-                       component.getLocale(), XsltTransformer.extension);
+               resourceStream = Application.get()
+                       .getResourceSettings()
+                       .getResourceStreamLocator()
+                       .locate(getClass(), filePath, component.getStyle(), 
component.getVariation(),
+                               component.getLocale(), 
XsltTransformer.extension, false);
 
                return resourceStream;
        }

Modified: 
wicket/trunk/wicket/src/main/java/org/apache/wicket/request/resource/PackageResource.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/request/resource/PackageResource.java?rev=1034959&r1=1034958&r2=1034959&view=diff
==============================================================================
--- 
wicket/trunk/wicket/src/main/java/org/apache/wicket/request/resource/PackageResource.java
 (original)
+++ 
wicket/trunk/wicket/src/main/java/org/apache/wicket/request/resource/PackageResource.java
 Sun Nov 14 08:56:07 2010
@@ -282,7 +282,7 @@ public class PackageResource extends Abs
                return ThreadContext.getApplication()
                        .getResourceSettings()
                        .getResourceStreamLocator()
-                       .locate(getScope(), absolutePath, style, variation, 
locale, null);
+                       .locate(getScope(), absolutePath, style, variation, 
locale, null, false);
        }
 
        /**
@@ -325,7 +325,7 @@ public class PackageResource extends Abs
                return ThreadContext.getApplication()
                        .getResourceSettings()
                        .getResourceStreamLocator()
-                       .locate(scope, absolutePath, style, variation, locale, 
null) != null;
+                       .locate(scope, absolutePath, style, variation, locale, 
null, false) != null;
        }
 
        @Override

Modified: 
wicket/trunk/wicket/src/main/java/org/apache/wicket/resource/Properties.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/resource/Properties.java?rev=1034959&r1=1034958&r2=1034959&view=diff
==============================================================================
--- 
wicket/trunk/wicket/src/main/java/org/apache/wicket/resource/Properties.java 
(original)
+++ 
wicket/trunk/wicket/src/main/java/org/apache/wicket/resource/Properties.java 
Sun Nov 14 08:56:07 2010
@@ -76,6 +76,6 @@ public final class Properties
        @Override
        public final String toString()
        {
-               return key;
+               return "unique key:" + key;
        }
 }
\ No newline at end of file

Modified: 
wicket/trunk/wicket/src/main/java/org/apache/wicket/resource/PropertiesFactory.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/resource/PropertiesFactory.java?rev=1034959&r1=1034958&r2=1034959&view=diff
==============================================================================
--- 
wicket/trunk/wicket/src/main/java/org/apache/wicket/resource/PropertiesFactory.java
 (original)
+++ 
wicket/trunk/wicket/src/main/java/org/apache/wicket/resource/PropertiesFactory.java
 Sun Nov 14 08:56:07 2010
@@ -57,7 +57,7 @@ public class PropertiesFactory implement
        private final List<IPropertiesChangeListener> afterReloadListeners = 
new ArrayList<IPropertiesChangeListener>();
 
        /** Cache for all property files loaded */
-       private final Map<String, Properties> propertiesCache = new 
ConcurrentHashMap<String, Properties>();
+       private final Map<String, Properties> propertiesCache = 
newPropertiesCache();
 
        /** This is necessary since the ModificationWatcher runs in a separate 
thread */
        private final Application application;
@@ -93,6 +93,14 @@ public class PropertiesFactory implement
        }
 
        /**
+        * @return new Cache implementation
+        */
+       protected Map<String, Properties> newPropertiesCache()
+       {
+               return new ConcurrentHashMap<String, Properties>();
+       }
+
+       /**
         * @see 
org.apache.wicket.resource.IPropertiesFactory#addListener(org.apache.wicket.resource.IPropertiesChangeListener)
         */
        public void addListener(final IPropertiesChangeListener listener)
@@ -109,7 +117,10 @@ public class PropertiesFactory implement
         */
        public final void clearCache()
        {
-               propertiesCache.clear();
+               if (propertiesCache != null)
+               {
+                       propertiesCache.clear();
+               }
 
                // clear the localizer cache as well
                application.getResourceSettings().getLocalizer().clearCache();
@@ -122,7 +133,12 @@ public class PropertiesFactory implement
        public Properties load(final Class<?> clazz, final String path)
        {
                // Check the cache
-               Properties properties = propertiesCache.get(path);
+               Properties properties = null;
+               if (propertiesCache != null)
+               {
+                       properties = propertiesCache.get(path);
+               }
+
                if (properties == null)
                {
                        IResourceSettings resourceSettings = 
Application.get().getResourceSettings();
@@ -134,9 +150,8 @@ public class PropertiesFactory implement
                                String fullPath = path + 
loader.getFileExtension();
 
                                // If not in the cache than try to load 
properties
-                               final IResourceStream resourceStream = 
resourceSettings.getResourceStreamLocator()
+                               IResourceStream resourceStream = 
resourceSettings.getResourceStreamLocator()
                                        .locate(clazz, fullPath);
-
                                if (resourceStream == null)
                                {
                                        continue;
@@ -157,14 +172,17 @@ public class PropertiesFactory implement
                        }
 
                        // Cache the lookup
-                       if (properties == null)
-                       {
-                               // Could not locate properties, store a 
placeholder
-                               propertiesCache.put(path, 
Properties.EMPTY_PROPERTIES);
-                       }
-                       else
+                       if (propertiesCache != null)
                        {
-                               propertiesCache.put(path, properties);
+                               if (properties == null)
+                               {
+                                       // Could not locate properties, store a 
placeholder
+                                       propertiesCache.put(path, 
Properties.EMPTY_PROPERTIES);
+                               }
+                               else
+                               {
+                                       propertiesCache.put(path, properties);
+                               }
                        }
                }
 

Modified: 
wicket/trunk/wicket/src/main/java/org/apache/wicket/resource/loader/ComponentStringResourceLoader.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/resource/loader/ComponentStringResourceLoader.java?rev=1034959&r1=1034958&r2=1034959&view=diff
==============================================================================
--- 
wicket/trunk/wicket/src/main/java/org/apache/wicket/resource/loader/ComponentStringResourceLoader.java
 (original)
+++ 
wicket/trunk/wicket/src/main/java/org/apache/wicket/resource/loader/ComponentStringResourceLoader.java
 Sun Nov 14 08:56:07 2010
@@ -29,6 +29,7 @@ import org.apache.wicket.markup.html.Web
 import org.apache.wicket.markup.html.WebPage;
 import org.apache.wicket.resource.IPropertiesFactory;
 import org.apache.wicket.resource.Properties;
+import org.apache.wicket.util.resource.locator.IResourceStreamLocator;
 import org.apache.wicket.util.resource.locator.ResourceNameIterator;
 import org.apache.wicket.util.string.Strings;
 import org.slf4j.Logger;
@@ -131,42 +132,20 @@ public class ComponentStringResourceLoad
                        String path = clazz.getName().replace('.', '/');
 
                        // Iterator over all the combinations
-                       ResourceNameIterator iter = new 
ResourceNameIterator(path, style, variation, locale,
-                               null, false);
+                       ResourceNameIterator iter = 
newResourceNameIterator(path, locale, style, variation);
                        while (iter.hasNext())
                        {
                                String newPath = iter.next();
 
-                               final Properties props = 
propertiesFactory.load(clazz, newPath);
+                               Properties props = 
propertiesFactory.load(clazz, newPath);
                                if (props != null)
                                {
                                        // Lookup the value
                                        String value = props.getString(key);
                                        if (value != null)
                                        {
-                                               if (log.isDebugEnabled())
-                                               {
-                                                       log.debug("Found 
property '" + key + "' in: '" + props + "'" +
-                                                               "; value: '" + 
value + "'");
-                                               }
-
                                                return value;
                                        }
-                                       else
-                                       {
-                                               if (log.isDebugEnabled())
-                                               {
-                                                       log.debug("Found 
properties file: '" + newPath +
-                                                               "' but it 
doesn't contain the property");
-                                               }
-                                       }
-                               }
-                               else
-                               {
-                                       if (log.isDebugEnabled())
-                                       {
-                                               log.debug("Properties file not 
found: '" + newPath + "'");
-                                       }
                                }
                        }
 
@@ -191,6 +170,25 @@ public class ComponentStringResourceLoad
        }
 
        /**
+        * @see IResourceStreamLocator#newResourceNameIterator(String, Locale, 
String, String, String,
+        *      boolean)
+        * 
+        * @param path
+        * @param locale
+        * @param style
+        * @param variation
+        * @return resource name iterator
+        */
+       protected ResourceNameIterator newResourceNameIterator(final String 
path, final Locale locale,
+               final String style, final String variation)
+       {
+               return Application.get()
+                       .getResourceSettings()
+                       .getResourceStreamLocator()
+                       .newResourceNameIterator(path, locale, style, 
variation, null, false);
+       }
+
+       /**
         * Get the properties file factory which loads the properties based on 
locale and style from
         * *.properties and *.xml files
         * 

Modified: 
wicket/trunk/wicket/src/main/java/org/apache/wicket/resource/loader/PackageStringResourceLoader.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/resource/loader/PackageStringResourceLoader.java?rev=1034959&r1=1034958&r2=1034959&view=diff
==============================================================================
--- 
wicket/trunk/wicket/src/main/java/org/apache/wicket/resource/loader/PackageStringResourceLoader.java
 (original)
+++ 
wicket/trunk/wicket/src/main/java/org/apache/wicket/resource/loader/PackageStringResourceLoader.java
 Sun Nov 14 08:56:07 2010
@@ -21,6 +21,7 @@ import java.util.Locale;
 import org.apache.wicket.Application;
 import org.apache.wicket.resource.IPropertiesFactory;
 import org.apache.wicket.resource.Properties;
+import org.apache.wicket.util.resource.locator.IResourceStreamLocator;
 import org.apache.wicket.util.resource.locator.ResourceNameIterator;
 import org.apache.wicket.util.string.Strings;
 import org.slf4j.Logger;
@@ -93,24 +94,18 @@ public class PackageStringResourceLoader
                                }
 
                                // Iterator over all the combinations
-                               ResourceNameIterator iter = new 
ResourceNameIterator(path, style, variation,
-                                       locale, null, false);
+                               ResourceNameIterator iter = 
newResourceNameIterator(path, locale, style, variation);
                                while (iter.hasNext())
                                {
                                        String newPath = iter.next();
 
-                                       final Properties props = 
propertiesFactory.load(clazz, newPath);
+                                       Properties props = 
propertiesFactory.load(clazz, newPath);
                                        if (props != null)
                                        {
                                                // Lookup the value
                                                String value = 
props.getString(key);
                                                if (value != null)
                                                {
-                                                       if 
(log.isDebugEnabled())
-                                                       {
-                                                               
log.debug("Found resource from: " + props + "; key: " + key);
-                                                       }
-
                                                        return value;
                                                }
                                        }
@@ -152,4 +147,24 @@ public class PackageStringResourceLoader
        {
                this.filename = filename;
        }
+
+       /**
+        * @see IResourceStreamLocator#newResourceNameIterator(String, Locale, 
String, String, String,
+        *      boolean)
+        * 
+        * @param locale
+        * @param style
+        * @param variation
+        * @param path
+        * @return resource name iterator
+        */
+       @Override
+       protected ResourceNameIterator newResourceNameIterator(final String 
path, final Locale locale,
+               final String style, final String variation)
+       {
+               return Application.get()
+                       .getResourceSettings()
+                       .getResourceStreamLocator()
+                       .newResourceNameIterator(path, locale, style, 
variation, null, false);
+       }
 }

Modified: 
wicket/trunk/wicket/src/main/java/org/apache/wicket/util/resource/PackageResourceStream.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/util/resource/PackageResourceStream.java?rev=1034959&r1=1034958&r2=1034959&view=diff
==============================================================================
--- 
wicket/trunk/wicket/src/main/java/org/apache/wicket/util/resource/PackageResourceStream.java
 (original)
+++ 
wicket/trunk/wicket/src/main/java/org/apache/wicket/util/resource/PackageResourceStream.java
 Sun Nov 14 08:56:07 2010
@@ -54,8 +54,10 @@ public class PackageResourceStream exten
        public PackageResourceStream(Class<?> scope, String path)
        {
                String absolutePath = Packages.absolutePath(scope, path);
-               resourceStream = 
Application.get().getResourceSettings().getResourceStreamLocator().locate(
-                       scope, absolutePath, null, null, null, null);
+               resourceStream = Application.get()
+                       .getResourceSettings()
+                       .getResourceStreamLocator()
+                       .locate(scope, absolutePath, null, null, null, null, 
false);
 
                if (resourceStream == null)
                {

Modified: 
wicket/trunk/wicket/src/main/java/org/apache/wicket/util/resource/locator/IResourceStreamLocator.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/util/resource/locator/IResourceStreamLocator.java?rev=1034959&r1=1034958&r2=1034959&view=diff
==============================================================================
--- 
wicket/trunk/wicket/src/main/java/org/apache/wicket/util/resource/locator/IResourceStreamLocator.java
 (original)
+++ 
wicket/trunk/wicket/src/main/java/org/apache/wicket/util/resource/locator/IResourceStreamLocator.java
 Sun Nov 14 08:56:07 2010
@@ -29,7 +29,7 @@ import org.apache.wicket.util.resource.I
 public interface IResourceStreamLocator
 {
        /**
-        * Loads a resource, given a path and class. Typically this method is 
either called by external
+        * Locate a resource, given a path and class. Typically this method is 
either called by external
         * clients if they are not interested in a lookup that takes the style 
and locale into account,
         * or it is called by the implementation of
         * {...@link #locate(Class, String, String, Locale, String)} where the 
latter just takes care of
@@ -43,10 +43,11 @@ public interface IResourceStreamLocator
         * 
         * @return The resource or null
         */
-       public IResourceStream locate(Class<?> clazz, String path);
+       IResourceStream locate(Class<?> clazz, String path);
 
        /**
-        * Loads a resource, given a path, style, variation, locale and 
extension.
+        * Locate a resource by combining the given path, style, variation, 
locale and extension
+        * parameters. The exact search order depends on the implementation.
         * 
         * @param clazz
         *            The class loader for delegating the loading of the 
resource
@@ -59,18 +60,19 @@ public interface IResourceStreamLocator
         * @param locale
         *            The locale of the resource to load
         * @param extension
-        *            The extension of the resource
-        * 
+        *            A comma separate list of extensions
+        * @param strict
+        *            whether the specified attributes must match exactly
         * @return The resource or null
         */
-       public IResourceStream locate(Class<?> clazz, String path, String 
style, String variation,
-               Locale locale, String extension);
+       IResourceStream locate(Class<?> clazz, String path, String style, 
String variation,
+               Locale locale, String extension, boolean strict);
 
        /**
-        * Loads a resource, given a path, style, variation, locale and 
extension.
+        * Markup resources and Properties files both need to iterate over 
different combinations of
+        * locale, style, etc.. And though no single locate(..) method exists 
which is used by both,
+        * they both use ResourceNameIterators.
         * 
-        * @param clazz
-        *            The class loader for delegating the loading of the 
resource
         * @param path
         *            The path of the resource
         * @param style
@@ -80,13 +82,11 @@ public interface IResourceStreamLocator
         * @param locale
         *            The locale of the resource to load
         * @param extension
-        *            The extension of the resource
-        * 
+        *            A comma separate list of extensions
         * @param strict
         *            whether the specified attributes must match exactly
-        * 
-        * @return The resource or null
+        * @return resource name iterator
         */
-       public IResourceStream locate(Class<?> clazz, String path, String 
style, String variation,
-               Locale locale, String extension, boolean strict);
+       ResourceNameIterator newResourceNameIterator(String path, Locale 
locale, String style,
+               String variation, String extension, boolean strict);
 }

Modified: 
wicket/trunk/wicket/src/main/java/org/apache/wicket/util/resource/locator/ResourceNameIterator.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/util/resource/locator/ResourceNameIterator.java?rev=1034959&r1=1034958&r2=1034959&view=diff
==============================================================================
--- 
wicket/trunk/wicket/src/main/java/org/apache/wicket/util/resource/locator/ResourceNameIterator.java
 (original)
+++ 
wicket/trunk/wicket/src/main/java/org/apache/wicket/util/resource/locator/ResourceNameIterator.java
 Sun Nov 14 08:56:07 2010
@@ -85,7 +85,7 @@ public class ResourceNameIterator implem
         * @param strict
         *            If false, weaker combinations of style, locale, etc. are 
tested as well
         */
-       public ResourceNameIterator(final String path, final String style, 
final String variation,
+       ResourceNameIterator(final String path, final String style, final 
String variation,
                final Locale locale, final String extensions, boolean strict)
        {
                this.locale = locale;

Modified: 
wicket/trunk/wicket/src/main/java/org/apache/wicket/util/resource/locator/ResourceStreamLocator.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/util/resource/locator/ResourceStreamLocator.java?rev=1034959&r1=1034958&r2=1034959&view=diff
==============================================================================
--- 
wicket/trunk/wicket/src/main/java/org/apache/wicket/util/resource/locator/ResourceStreamLocator.java
 (original)
+++ 
wicket/trunk/wicket/src/main/java/org/apache/wicket/util/resource/locator/ResourceStreamLocator.java
 Sun Nov 14 08:56:07 2010
@@ -23,8 +23,8 @@ import org.apache.wicket.Application;
 import org.apache.wicket.util.file.IResourceFinder;
 import org.apache.wicket.util.resource.IResourceStream;
 import org.apache.wicket.util.resource.ResourceUtils;
-import org.apache.wicket.util.resource.UrlResourceStream;
 import org.apache.wicket.util.resource.ResourceUtils.PathLocale;
+import org.apache.wicket.util.resource.UrlResourceStream;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -110,18 +110,6 @@ public class ResourceStreamLocator imple
         * 
         * @see 
org.apache.wicket.util.resource.locator.IResourceStreamLocator#locate(java.lang.Class,
         *      java.lang.String, java.lang.String, java.lang.String, 
java.util.Locale,
-        *      java.lang.String)
-        */
-       public IResourceStream locate(final Class<?> clazz, String path, final 
String style,
-               final String variation, final Locale locale, final String 
extension)
-       {
-               return locate(clazz, path, style, variation, locale, extension, 
false);
-       }
-
-       /**
-        * 
-        * @see 
org.apache.wicket.util.resource.locator.IResourceStreamLocator#locate(java.lang.Class,
-        *      java.lang.String, java.lang.String, java.lang.String, 
java.util.Locale,
         *      java.lang.String, boolean)
         */
        public IResourceStream locate(final Class<?> clazz, String path, final 
String style,
@@ -136,7 +124,7 @@ public class ResourceStreamLocator imple
                }
 
                // Try the various combinations of style, locale and extension 
to find the resource.
-               ResourceNameIterator iter = new ResourceNameIterator(path, 
style, variation, locale,
+               ResourceNameIterator iter = newResourceNameIterator(path, 
locale, style, variation,
                        extension, strict);
                while (iter.hasNext())
                {
@@ -244,4 +232,15 @@ public class ResourceStreamLocator imple
                // Try to find file resource on the path supplied
                return finder.find(clazz, path);
        }
+
+       /**
+        * 
+        * @see 
org.apache.wicket.util.resource.locator.IResourceStreamLocator#newResourceNameIterator(java.lang.String,
+        *      java.util.Locale, java.lang.String, java.lang.String, 
java.lang.String, boolean)
+        */
+       public ResourceNameIterator newResourceNameIterator(final String path, 
final Locale locale,
+               final String style, final String variation, final String 
extension, final boolean strict)
+       {
+               return new ResourceNameIterator(path, style, variation, locale, 
extension, strict);
+       }
 }

Modified: 
wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/MarkupParserTest.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/MarkupParserTest.java?rev=1034959&r1=1034958&r2=1034959&view=diff
==============================================================================
--- 
wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/MarkupParserTest.java
 (original)
+++ 
wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/MarkupParserTest.java
 Sun Nov 14 08:56:07 2010
@@ -182,7 +182,7 @@ public final class MarkupParserTest exte
                final String extension)
        {
                IResourceStream resource = locator.locate(c, 
c.getName().replace('.', '/'), style,
-                       variation, locale, extension);
+                       variation, locale, extension, false);
                MarkupResourceStream res = new MarkupResourceStream(resource, 
null, null);
                return res;
        }

Modified: 
wicket/trunk/wicket/src/test/java/org/apache/wicket/resource/loader/ComponentStringResourceLoaderTest.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/resource/loader/ComponentStringResourceLoaderTest.java?rev=1034959&r1=1034958&r2=1034959&view=diff
==============================================================================
--- 
wicket/trunk/wicket/src/test/java/org/apache/wicket/resource/loader/ComponentStringResourceLoaderTest.java
 (original)
+++ 
wicket/trunk/wicket/src/test/java/org/apache/wicket/resource/loader/ComponentStringResourceLoaderTest.java
 Sun Nov 14 08:56:07 2010
@@ -16,11 +16,14 @@
  */
 package org.apache.wicket.resource.loader;
 
+import java.util.Map;
+
 import org.apache.wicket.Application;
 import org.apache.wicket.WicketRuntimeException;
 import org.apache.wicket.WicketTestCase;
 import org.apache.wicket.resource.IPropertiesFactory;
 import org.apache.wicket.resource.IsoPropertiesFilePropertiesLoader;
+import org.apache.wicket.resource.Properties;
 import org.apache.wicket.resource.PropertiesFactory;
 
 /**
@@ -68,6 +71,19 @@ public class ComponentStringResourceLoad
        }
 
        /**
+        * @throws Exception
+        */
+       public void testDisabledCache() throws Exception
+       {
+               IPropertiesFactory myFac = new 
DisabledCachePropertiesFactory(tester.getApplication());
+               
tester.getApplication().getResourceSettings().setPropertiesFactory(myFac);
+
+               executeTest(TestPage_1.class, "TestPageExpectedResult_1.xml");
+
+               myFac.clearCache();
+       }
+
+       /**
         * 
         */
        private class MyPropertiesFactory extends PropertiesFactory
@@ -85,4 +101,29 @@ public class ComponentStringResourceLoad
                        getPropertiesLoaders().add(new 
IsoPropertiesFilePropertiesLoader("properties"));
                }
        }
+
+       /**
+        * 
+        */
+       private class DisabledCachePropertiesFactory extends PropertiesFactory
+       {
+               /**
+                * Construct.
+                * 
+                * @param application
+                */
+               public DisabledCachePropertiesFactory(Application application)
+               {
+                       super(application);
+               }
+
+               /**
+                * @see 
org.apache.wicket.resource.PropertiesFactory#newPropertiesCache()
+                */
+               @Override
+               protected Map<String, Properties> newPropertiesCache()
+               {
+                       return null;
+               }
+       }
 }

Modified: 
wicket/trunk/wicket/src/test/java/org/apache/wicket/util/resource/ResourceTest.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/util/resource/ResourceTest.java?rev=1034959&r1=1034958&r2=1034959&view=diff
==============================================================================
--- 
wicket/trunk/wicket/src/test/java/org/apache/wicket/util/resource/ResourceTest.java
 (original)
+++ 
wicket/trunk/wicket/src/test/java/org/apache/wicket/util/resource/ResourceTest.java
 Sun Nov 14 08:56:07 2010
@@ -67,7 +67,7 @@ public class ResourceTest extends Wicket
                IResourceStreamLocator locator = new 
ResourceStreamLocator(sourcePath);
                IResourceStream resource = locator.locate(this.getClass(), 
this.getClass()
                        .getName()
-                       .replace('.', '/'), style, variation, locale, "txt");
+                       .replace('.', '/'), style, variation, locale, "txt", 
false);
                compareFilename(resource, extension);
        }
 
@@ -115,8 +115,8 @@ public class ResourceTest extends Wicket
 
                // Determine source path
                IResourceStreamLocator locator = new ResourceStreamLocator();
-               IResourceStream resource = locator.locate(getClass(), 
this.getClass().getName().replace(
-                       '.', '/'), null, null, null, "txt");
+               IResourceStream resource = locator.locate(getClass(),
+                       this.getClass().getName().replace('.', '/'), null, 
null, null, "txt", false);
                String path = getPath(resource);
                path = Strings.beforeLastPathComponent(path, '/') + 
"/sourcePath";
 


Reply via email to