You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by jd...@apache.org on 2008/04/09 13:55:07 UTC

svn commit: r646290 - in /wicket/trunk/jdk-1.4/wicket/src: main/java/org/apache/wicket/markup/resolver/ main/java/org/apache/wicket/resource/ main/java/org/apache/wicket/resource/loader/ main/java/org/apache/wicket/util/resource/locator/ test/java/org/...

Author: jdonnerstag
Date: Wed Apr  9 04:55:03 2008
New Revision: 646290

URL: http://svn.apache.org/viewvc?rev=646290&view=rev
Log:
fixed wicket-1436 Unable to use properties file when generating XML files

It is not yet fully fixed though. The component markup type should automatically be taken into account.

Added:
    wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/resource/loader/PackageStringResourceLoader.java
    wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/resource/loader/
    wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/resource/loader/ClassStringResourceLoaderTest$MyValidator.properties
    wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/resource/loader/ClassStringResourceLoaderTest$MyValidator_nl.properties
    wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/resource/loader/ClassStringResourceLoaderTest.java
    wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/resource/loader/ComponentStringResourceLoaderTest.java
    wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/resource/loader/PackageStringResourceLoaderTest.java
    wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/resource/loader/PackageTestPageExpectedResult_1.html
    wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/resource/loader/TestPageExpectedResult_1.xml
    wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/resource/loader/TestPage_1.java
    wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/resource/loader/TestPage_1.xml
    wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/resource/loader/XmlPage.java
    wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/resource/loader/XmlPage.properties
    wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/resource/loader/package.properties
    wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/resource/loader/pages/
    wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/resource/loader/pages/Test1.html
    wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/resource/loader/pages/Test1.java
    wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/resource/loader/pages/package.properties
Modified:
    wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/resolver/AutoLinkResolver.java
    wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/resource/IPropertiesFactory.java
    wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/resource/PropertiesFactory.java
    wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/resource/loader/ComponentStringResourceLoader.java
    wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/resource/locator/ExtensionResourceNameIterator.java
    wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/resource/locator/ResourceNameIterator.java
    wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/ApplicationSettingsTest.java
    wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/link/AutolinkPageExpectedResult_4.html

Modified: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/resolver/AutoLinkResolver.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/resolver/AutoLinkResolver.java?rev=646290&r1=646289&r2=646290&view=diff
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/resolver/AutoLinkResolver.java (original)
+++ wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/resolver/AutoLinkResolver.java Wed Apr  9 04:55:03 2008
@@ -66,8 +66,8 @@
 	 * Abstract implementation that has a helper method for creating a resource reference.
 	 */
 	public static abstract class AbstractAutolinkResolverDelegate
-			implements
-				IAutolinkResolverDelegate
+		implements
+			IAutolinkResolverDelegate
 	{
 		/**
 		 * Creates a new auto component that references a package resource.
@@ -83,10 +83,10 @@
 		 * @return a new auto component or null if the path was absolute
 		 */
 		protected final Component newPackageResourceReferenceAutoComponent(
-				final MarkupContainer container, final String autoId, final PathInfo pathInfo,
-				final String attribute)
+			final MarkupContainer container, final String autoId, final PathInfo pathInfo,
+			final String attribute)
 		{
-			if (!pathInfo.absolute)
+			if (!pathInfo.absolute && (pathInfo.path != null) && (pathInfo.path.length() > 0))
 			{
 				// Href is relative. Create a resource reference pointing at
 				// this file
@@ -109,7 +109,7 @@
 
 				// Create the component implementing the link
 				ResourceReferenceAutolink autoLink = new ResourceReferenceAutolink(autoId, clazz,
-						pathInfo.reference, attribute);
+					pathInfo.reference, attribute);
 				if (autoLink.resourceReference != null)
 				{
 					// if the resource reference is null, it means that it the
@@ -155,7 +155,7 @@
 		 * @param anchor
 		 */
 		public AutolinkBookmarkablePageLink(final String id, final Class pageClass,
-				final PageParameters parameters, final String anchor)
+			final PageParameters parameters, final String anchor)
 		{
 			super(id, pageClass, parameters);
 			this.anchor = anchor;
@@ -206,7 +206,7 @@
 		 *         auto component
 		 */
 		Component newAutoComponent(final MarkupContainer container, final String autoId,
-				final PathInfo pathInfo);
+			final PathInfo pathInfo);
 	}
 
 	/**
@@ -282,6 +282,17 @@
 				}
 			}
 
+			// Anchors without path, e.g. "#link"
+			if (anchor == null)
+			{
+				pos = infoPath.indexOf("#");
+				if (pos != -1)
+				{
+					anchor = infoPath.substring(pos);
+					infoPath = infoPath.substring(0, pos);
+				}
+			}
+
 			path = infoPath;
 			this.extension = extension;
 			this.anchor = anchor;
@@ -380,10 +391,10 @@
 		 *      java.lang.String, org.apache.wicket.markup.resolver.AutoLinkResolver.PathInfo)
 		 */
 		public Component newAutoComponent(final MarkupContainer container, final String autoId,
-				PathInfo pathInfo)
+			PathInfo pathInfo)
 		{
 			if ((pathInfo.extension != null) &&
-					supportedPageExtensions.contains(pathInfo.extension))
+				supportedPageExtensions.contains(pathInfo.extension))
 			{
 				// Obviously a href like href="myPkg.MyLabel.html" will do as
 				// well. Wicket will not throw an exception. It accepts it.
@@ -391,19 +402,20 @@
 
 				Page page = container.getPage();
 				final IClassResolver defaultClassResolver = page.getApplication()
-						.getApplicationSettings().getClassResolver();
-                String className = Packages.absolutePath(page.getClass(), pathInfo.path );
-                className = Strings.replaceAll(className, "/", ".").toString();
-                if(className.startsWith("."))
-                {
-                    className = className.substring(1);
-                }
-                
+					.getApplicationSettings()
+					.getClassResolver();
+				String className = Packages.absolutePath(page.getClass(), pathInfo.path);
+				className = Strings.replaceAll(className, "/", ".").toString();
+				if (className.startsWith("."))
+				{
+					className = className.substring(1);
+				}
+
 				try
 				{
 					final Class clazz = defaultClassResolver.resolveClass(className);
 					return new AutolinkBookmarkablePageLink(autoId, clazz, pathInfo.pageParameters,
-							pathInfo.anchor);
+						pathInfo.anchor);
 				}
 				catch (ClassNotFoundException ex)
 				{
@@ -418,7 +430,7 @@
 					parentWithContainer = container.findParentWithAssociatedMarkup();
 				}
 				if ((parentWithContainer instanceof Page) && !pathInfo.path.startsWith("/") &&
-						page.getMarkupStream().isMergedMarkup())
+					page.getMarkupStream().isMergedMarkup())
 				{
 					Class clazz = container.getMarkupStream().getTag().getMarkupClass();
 					if (clazz != null)
@@ -430,8 +442,8 @@
 						try
 						{
 							clazz = defaultClassResolver.resolveClass(className);
-							return new AutolinkBookmarkablePageLink(autoId, clazz, pathInfo
-									.getPageParameters(), pathInfo.anchor);
+							return new AutolinkBookmarkablePageLink(autoId, clazz,
+								pathInfo.getPageParameters(), pathInfo.anchor);
 						}
 						catch (ClassNotFoundException ex)
 						{
@@ -446,7 +458,7 @@
 				// not a registered type for bookmarkable pages; create a link
 				// to a resource instead
 				return newPackageResourceReferenceAutoComponent(container, autoId, pathInfo,
-						attribute);
+					attribute);
 			}
 
 			// fallthrough
@@ -523,7 +535,7 @@
 		 * @param attribute
 		 */
 		public ResourceReferenceAutolink(final String id, final Class clazz, final String href,
-				final String attribute)
+			final String attribute)
 		{
 			super(id);
 
@@ -578,9 +590,8 @@
 	 * Resolves to {@link ResourceReference} link components. Typically used for header
 	 * contributions like javascript and css files.
 	 */
-	private static final class ResourceReferenceResolverDelegate
-			extends
-				AbstractAutolinkResolverDelegate
+	private static final class ResourceReferenceResolverDelegate extends
+		AbstractAutolinkResolverDelegate
 	{
 		private final String attribute;
 
@@ -599,7 +610,7 @@
 		 *      java.lang.String, org.apache.wicket.markup.resolver.AutoLinkResolver.PathInfo)
 		 */
 		public Component newAutoComponent(final MarkupContainer container, final String autoId,
-				final PathInfo pathInfo)
+			final PathInfo pathInfo)
 		{
 			return newPackageResourceReferenceAutoComponent(container, autoId, pathInfo, attribute);
 		}
@@ -643,7 +654,7 @@
 	 * If no specific resolver is found, always use the href attribute for references.
 	 */
 	private static final TagReferenceResolver DEFAULT_ATTRIBUTE_RESOLVER = new TagReferenceResolver(
-			"href");
+		"href");
 
 	/** Logging */
 	private static final Logger log = LoggerFactory.getLogger(AutoLinkResolver.class);
@@ -678,9 +689,9 @@
 		// register autolink resolver delegates
 		tagNameToAutolinkResolverDelegates.put("a", new AnchorResolverDelegate());
 		tagNameToAutolinkResolverDelegates.put("link",
-				new ResourceReferenceResolverDelegate("href"));
+			new ResourceReferenceResolverDelegate("href"));
 		tagNameToAutolinkResolverDelegates.put("script", new ResourceReferenceResolverDelegate(
-				"src"));
+			"src"));
 		tagNameToAutolinkResolverDelegates.put("img", new ResourceReferenceResolverDelegate("src"));
 	}
 
@@ -696,7 +707,7 @@
 	 *            Implements what to do based on the tag and the attribute
 	 */
 	public final void addTagReferenceResolver(final String tagName, final String attributeName,
-			final IAutolinkResolverDelegate resolver)
+		final IAutolinkResolverDelegate resolver)
 	{
 		TagReferenceResolver tagReferenceResolver = new TagReferenceResolver(attributeName);
 		tagNameToTagReferenceResolvers.put(tagName, tagReferenceResolver);
@@ -731,7 +742,7 @@
 	 * @return true, if componentId was handle by the resolver. False, otherwise
 	 */
 	public final boolean resolve(final MarkupContainer container, final MarkupStream markupStream,
-			final ComponentTag tag)
+		final ComponentTag tag)
 	{
 		// Must be marked as autolink tag
 		if (tag.isAutolinkEnabled())
@@ -740,7 +751,7 @@
 			// Note: to not use tag.getId() because it will be modified while
 			// resolving the link and hence the 2nd render will fail.
 			final Component link = resolveAutomaticLink(container,
-					WicketLinkTagHandler.AUTOLINK_ID, tag);
+				WicketLinkTagHandler.AUTOLINK_ID, tag);
 
 			// Add the link to the container
 			container.autoAdd(link, markupStream);
@@ -773,7 +784,7 @@
 	 * @return A BookmarkablePageLink to handle the href
 	 */
 	private final Component resolveAutomaticLink(final MarkupContainer container, final String id,
-			final ComponentTag tag)
+		final ComponentTag tag)
 	{
 		final Page page = container.getPage();
 
@@ -792,8 +803,7 @@
 		}
 
 		// get the reference resolver
-		ITagReferenceResolver referenceResolver = (ITagReferenceResolver)tagNameToTagReferenceResolvers
-				.get(tagName);
+		ITagReferenceResolver referenceResolver = (ITagReferenceResolver)tagNameToTagReferenceResolvers.get(tagName);
 		if (referenceResolver == null)
 		{
 			// fallback on default
@@ -807,8 +817,7 @@
 		// create the path info object
 		PathInfo pathInfo = new PathInfo(reference);
 		// now get the resolver delegate
-		IAutolinkResolverDelegate autolinkResolverDelegate = (IAutolinkResolverDelegate)tagNameToAutolinkResolverDelegates
-				.get(tagName);
+		IAutolinkResolverDelegate autolinkResolverDelegate = (IAutolinkResolverDelegate)tagNameToAutolinkResolverDelegates.get(tagName);
 		Component autoComponent = null;
 		if (autolinkResolverDelegate != null)
 		{

Modified: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/resource/IPropertiesFactory.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/resource/IPropertiesFactory.java?rev=646290&r1=646289&r2=646290&view=diff
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/resource/IPropertiesFactory.java (original)
+++ wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/resource/IPropertiesFactory.java Wed Apr  9 04:55:03 2008
@@ -60,5 +60,5 @@
 	 *            The path to identify the resource
 	 * @return The properties
 	 */
-	Properties load(final Class clazz, final String path);
+	Properties load(final Class< ? > clazz, final String path);
 }

Modified: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/resource/PropertiesFactory.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/resource/PropertiesFactory.java?rev=646290&r1=646289&r2=646290&view=diff
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/resource/PropertiesFactory.java (original)
+++ wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/resource/PropertiesFactory.java Wed Apr  9 04:55:03 2008
@@ -29,11 +29,9 @@
 import org.apache.wicket.settings.IResourceSettings;
 import org.apache.wicket.util.io.Streams;
 import org.apache.wicket.util.listener.IChangeListener;
-import org.apache.wicket.util.resource.IFixedLocationResourceStream;
 import org.apache.wicket.util.resource.IResourceStream;
 import org.apache.wicket.util.resource.ResourceStreamNotFoundException;
 import org.apache.wicket.util.resource.locator.IResourceStreamLocator;
-import org.apache.wicket.util.string.Strings;
 import org.apache.wicket.util.value.ValueMap;
 import org.apache.wicket.util.watch.ModificationWatcher;
 import org.slf4j.Logger;
@@ -66,6 +64,9 @@
 	/** Application */
 	private final Application application;
 
+	/** LIst of Properties Loader */
+	private final List<IPropertiesLoader> propertiesLoader;
+
 	/**
 	 * Construct.
 	 * 
@@ -75,6 +76,20 @@
 	public PropertiesFactory(Application application)
 	{
 		this.application = application;
+
+		propertiesLoader = new ArrayList<IPropertiesLoader>();
+		propertiesLoader.add(new PropertiesFilePropertiesLoader());
+		propertiesLoader.add(new XmlFilePropertiesLoader());
+	}
+
+	/**
+	 * Gets the list of properties loader. You may add or remove properties loaders at your will.
+	 * 
+	 * @return
+	 */
+	public List<IPropertiesLoader> getPropertiesLoaders()
+	{
+		return propertiesLoader;
 	}
 
 	/**
@@ -95,30 +110,29 @@
 	public final void clearCache()
 	{
 		propertiesCache.clear();
+
+		// clear the localizer cache as well
+		application.getResourceSettings().getLocalizer().clearCache();
 	}
 
 	/**
 	 * 
 	 * @see org.apache.wicket.resource.IPropertiesFactory#load(java.lang.Class, java.lang.String)
 	 */
-	public Properties load(final Class clazz, final String path)
+	public Properties load(final Class< ? > clazz, final String path)
 	{
 		// Check the cache
 		Properties properties = propertiesCache.get(path);
 
 		if (properties == null)
 		{
-			// If not in the cache than try to load properties
-			IResourceStream stream = application.getResourceSettings()
-				.getResourceStreamLocator()
-				.locate(clazz, path);
-			if (stream != null)
+			Iterator<IPropertiesLoader> iter = propertiesLoader.iterator();
+			while ((properties == null) && iter.hasNext())
 			{
-				// Load the properties from the stream
-				properties = loadPropertiesFileAndWatchForChanges(path, stream);
+				IPropertiesLoader loader = iter.next();
+				properties = loader.load(clazz, path);
 			}
 
-
 			// Cache the lookup
 			if (properties == null)
 			{
@@ -129,7 +143,6 @@
 			{
 				propertiesCache.put(path, properties);
 			}
-
 		}
 
 		if (properties == Properties.EMPTY_PROPERTIES)
@@ -142,78 +155,141 @@
 	}
 
 	/**
-	 * Helper method to do the actual loading of resources if required.
+	 * For subclasses to get access to the cache
 	 * 
-	 * @param key
-	 *            The key for the resource
-	 * @param resourceStream
-	 *            The properties file stream to load and begin to watch
-	 * @return The map of loaded resources
+	 * @return Map
 	 */
-	private synchronized Properties loadPropertiesFile(final String key,
-		final IResourceStream resourceStream)
+	protected final Map<String, Properties> getCache()
 	{
-		// Make sure someone else didn't load our resources while we were
-		// waiting for the synchronized lock on the method
-		Properties props = propertiesCache.get(key);
-		if (props != null)
-		{
-			return props;
-		}
+		return propertiesCache;
+	}
+
+	/**
+	 * 
+	 */
+	public interface IPropertiesLoader
+	{
+		/**
+		 * 
+		 * @param clazz
+		 * @param path
+		 * @return
+		 */
+		Properties load(final Class< ? > clazz, final String path);
+	}
 
-		if (resourceStream == null)
+	/**
+	 * 
+	 */
+	public abstract class AbstractPropertiesLoader implements IPropertiesLoader
+	{
+		/**
+		 * Construct.
+		 */
+		public AbstractPropertiesLoader()
 		{
-			props = new Properties(key, ValueMap.EMPTY_MAP);
 		}
-		else
+
+		/**
+		 * 
+		 * @return
+		 */
+		abstract protected String getFileExtension();
+
+		/**
+		 * 
+		 * @param in
+		 * @return
+		 * @throws IOException
+		 */
+		abstract protected java.util.Properties loadProperties(BufferedInputStream in)
+			throws IOException;
+
+		/**
+		 * 
+		 * @see org.apache.wicket.resource.PropertiesFactory.IPropertiesLoader#load(java.lang.Class,
+		 *      java.lang.String)
+		 */
+		public Properties load(final Class< ? > clazz, final String path)
 		{
-			ValueMap strings = null;
+			String fullPath = path + getFileExtension();
 
-			try
+			// If not in the cache than try to load properties
+			final IResourceStream resourceStream = application.getResourceSettings()
+				.getResourceStreamLocator()
+				.locate(clazz, fullPath);
+
+			if (resourceStream == null)
 			{
-				try
-				{
-					// Get the InputStream
-					BufferedInputStream in = new BufferedInputStream(
-						resourceStream.getInputStream());
+				return null;
+			}
 
-					// Determine if resource is a XML File
-					boolean loadAsXml = false;
-					if (resourceStream instanceof IFixedLocationResourceStream)
+			// Watch file modifications
+			final ModificationWatcher watcher = application.getResourceSettings()
+				.getResourceWatcher(true);
+			if (watcher != null)
+			{
+				watcher.add(resourceStream, new IChangeListener()
+				{
+					public void onChange()
 					{
-						String location = ((IFixedLocationResourceStream)resourceStream).locationAsString();
-						if (location != null)
+						log.info("A properties files has changed. Removing all entries " +
+							"from the cache. Resource: " + resourceStream);
+
+						// Clear the whole cache as associated localized files may
+						// be affected and may need reloading as well.
+						clearCache();
+
+						// Inform all listeners
+						Iterator<IPropertiesChangeListener> iter = afterReloadListeners.iterator();
+						while (iter.hasNext())
 						{
-							String ext = Strings.lastPathComponent(location, '.').toLowerCase();
-							if ("xml".equals(ext))
+							IPropertiesChangeListener listener = iter.next();
+							try
+							{
+								listener.propertiesChanged(path);
+							}
+							catch (Throwable ex)
 							{
-								loadAsXml = true;
+								log.error("PropertiesReloadListener has thrown an exception: " +
+									ex.getMessage());
 							}
 						}
 					}
+				});
+			}
 
-					// Load the properties
-					java.util.Properties properties = new java.util.Properties();
-					if (loadAsXml)
-					{
-						Streams.loadFromXml(properties, in);
-					}
-					else
-					{
-						properties.load(in);
-					}
+			log.info("Loading properties files from " + resourceStream);
+			ValueMap strings = null;
+
+			try
+			{
+				BufferedInputStream in = null;
+
+				try
+				{
+					// Get the InputStream
+					in = new BufferedInputStream(resourceStream.getInputStream());
+
+					java.util.Properties properties = loadProperties(in);
 
 					// Copy the properties into the ValueMap
 					strings = new ValueMap();
-					Enumeration enumeration = properties.propertyNames();
+					Enumeration< ? > enumeration = properties.propertyNames();
 					while (enumeration.hasMoreElements())
 					{
 						String property = (String)enumeration.nextElement();
 						strings.put(property, properties.getProperty(property));
 					}
+
+					return new Properties(path, strings);
 				}
 				finally
 				{
+					if (in != null)
+					{
+						in.close();
+					}
 					resourceStream.close();
 				}
 			}
@@ -228,74 +304,81 @@
 				strings = ValueMap.EMPTY_MAP;
 			}
 
-			props = new Properties(key, strings);
+			return null;
 		}
-
-		return props;
 	}
 
 	/**
-	 * Load properties file from an IResourceStream and add an {@link IChangeListener}to the
-	 * {@link ModificationWatcher} so that if the resource changes, we can reload it automatically.
 	 * 
-	 * @param key
-	 *            The key for the resource
-	 * @param resourceStream
-	 *            The properties file stream to load and begin to watch
-	 * @return The map of loaded resources
 	 */
-	private final Properties loadPropertiesFileAndWatchForChanges(final String key,
-		final IResourceStream resourceStream)
+	public class PropertiesFilePropertiesLoader extends AbstractPropertiesLoader
 	{
-		// Watch file modifications
-		final ModificationWatcher watcher = application.getResourceSettings().getResourceWatcher(
-			true);
-		if (watcher != null)
+		/**
+		 * Construct.
+		 */
+		public PropertiesFilePropertiesLoader()
 		{
-			watcher.add(resourceStream, new IChangeListener()
-			{
-				public void onChange()
-				{
-					log.info("A properties files has changed. Removing all entries " +
-						"from the cache. Resource: " + resourceStream);
+		}
 
-					// Clear the whole cache as associated localized files may
-					// be affected and may need reloading as well.
-					clearCache();
-
-					// clear the localizer cache as well
-					application.getResourceSettings().getLocalizer().clearCache();
-
-					// Inform all listeners
-					Iterator<IPropertiesChangeListener> iter = afterReloadListeners.iterator();
-					while (iter.hasNext())
-					{
-						IPropertiesChangeListener listener = iter.next();
-						try
-						{
-							listener.propertiesChanged(key);
-						}
-						catch (Throwable ex)
-						{
-							log.error("PropertiesReloadListener has thrown an exception: " +
-								ex.getMessage());
-						}
-					}
-				}
-			});
+		/**
+		 * 
+		 * @see org.apache.wicket.resource.PropertiesFactory.AbstractPropertiesLoader#getFileExtension()
+		 */
+		@Override
+		protected String getFileExtension()
+		{
+			return "properties";
 		}
 
-		log.info("Loading properties files from " + resourceStream);
-		return loadPropertiesFile(key, resourceStream);
+		/**
+		 * 
+		 * @param in
+		 * @return
+		 * @throws IOException
+		 */
+		@Override
+		protected java.util.Properties loadProperties(BufferedInputStream in) throws IOException
+		{
+			java.util.Properties properties = new java.util.Properties();
+			properties.load(in);
+			return properties;
+		}
 	}
 
 	/**
-	 * For subclasses to get access to the cache
 	 * 
-	 * @return Map
 	 */
-	protected final Map<String, Properties> getCache()
+	public class XmlFilePropertiesLoader extends AbstractPropertiesLoader
 	{
-		return propertiesCache;
+		/**
+		 * Construct.
+		 */
+		public XmlFilePropertiesLoader()
+		{
+		}
+
+		/**
+		 * 
+		 * @see org.apache.wicket.resource.PropertiesFactory.AbstractPropertiesLoader#getFileExtension()
+		 */
+		@Override
+		protected String getFileExtension()
+		{
+			return "xml";
+		}
+
+		/**
+		 * 
+		 * @param in
+		 * @return
+		 * @throws IOException
+		 */
+		@Override
+		protected java.util.Properties loadProperties(BufferedInputStream in) throws IOException
+		{
+			java.util.Properties properties = new java.util.Properties();
+			Streams.loadFromXml(properties, in);
+			return properties;
+		}
 	}
 }

Modified: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/resource/loader/ComponentStringResourceLoader.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/resource/loader/ComponentStringResourceLoader.java?rev=646290&r1=646289&r2=646290&view=diff
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/resource/loader/ComponentStringResourceLoader.java (original)
+++ wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/resource/loader/ComponentStringResourceLoader.java Wed Apr  9 04:55:03 2008
@@ -36,7 +36,7 @@
 
 
 /**
- * This is Wicket's default string resource loader.
+ * This is one of Wicket's default string resource loaders.
  * <p>
  * The component based string resource loader attempts to find the resource from a bundle that
  * corresponds to the supplied component object or one of its parent containers.
@@ -106,23 +106,12 @@
 	}
 
 	/**
-	 * Get the string resource for the given combination of class, key, locale and style. The
-	 * information is obtained from a resource bundle associated with the provided Class (or one of
-	 * its super classes).
 	 * 
-	 * @param clazz
-	 *            The Class to find resources to be loaded
-	 * @param key
-	 *            The key to obtain the string for
-	 * @param locale
-	 *            The locale identifying the resource set to select the strings from
-	 * @param style
-	 *            The (optional) style identifying the resource set to select the strings from (see
-	 *            {@link org.apache.wicket.Session})
-	 * @return The string resource value or null if resource not found
+	 * @see org.apache.wicket.resource.loader.IStringResourceLoader#loadStringResource(java.lang.Class,
+	 *      java.lang.String, java.util.Locale, java.lang.String)
 	 */
 	public String loadStringResource(Class clazz, final String key, final Locale locale,
-			final String style)
+		final String style)
 	{
 		if (clazz == null)
 		{
@@ -130,8 +119,9 @@
 		}
 
 		// Load the properties associated with the path
-		IPropertiesFactory propertiesFactory = Application.get().getResourceSettings()
-				.getPropertiesFactory();
+		IPropertiesFactory propertiesFactory = Application.get()
+			.getResourceSettings()
+			.getPropertiesFactory();
 
 		while (true)
 		{
@@ -139,8 +129,7 @@
 			String path = clazz.getName().replace('.', '/');
 
 			// Iterator over all the combinations
-			ResourceNameIterator iter = new ResourceNameIterator(path, style, locale,
-					"properties,xml");
+			ResourceNameIterator iter = new ResourceNameIterator(path, style, locale, null);
 			while (iter.hasNext())
 			{
 				String newPath = (String)iter.next();
@@ -278,13 +267,13 @@
 
 		// Stop at all html markup base classes
 		if (clazz.equals(WebPage.class) || clazz.equals(WebMarkupContainer.class) ||
-				clazz.equals(WebComponent.class))
+			clazz.equals(WebComponent.class))
 		{
 			return true;
 		}
 
 		// Stop at all wicket base classes
 		return clazz.equals(Page.class) || clazz.equals(MarkupContainer.class) ||
-				clazz.equals(Component.class);
+			clazz.equals(Component.class);
 	}
 }

Added: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/resource/loader/PackageStringResourceLoader.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/resource/loader/PackageStringResourceLoader.java?rev=646290&view=auto
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/resource/loader/PackageStringResourceLoader.java (added)
+++ wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/resource/loader/PackageStringResourceLoader.java Wed Apr  9 04:55:03 2008
@@ -0,0 +1,156 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.resource.loader;
+
+import java.util.Locale;
+
+import org.apache.wicket.Application;
+import org.apache.wicket.Component;
+import org.apache.wicket.resource.IPropertiesFactory;
+import org.apache.wicket.resource.Properties;
+import org.apache.wicket.util.resource.locator.ResourceNameIterator;
+import org.apache.wicket.util.string.Strings;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * This is one of Wicket's default string resource loaders.
+ * <p>
+ * The package based string resource loader attempts to find the resource from a bundle that
+ * corresponds to the supplied component objects package or one of its parent packages.
+ * <p>
+ * The search order for resources is component object package towards root package.
+ * <p>
+ * This implementation is fully aware of both locale and style values when trying to obtain the
+ * appropriate resources.
+ * <p>
+ * 
+ * @author Juergen Donnerstag
+ */
+public class PackageStringResourceLoader implements IStringResourceLoader
+{
+	/** Log. */
+	private static final Logger log = LoggerFactory.getLogger(PackageStringResourceLoader.class);
+
+	/** The name (without extension) of the properties file */
+	private String filename = "package";
+
+	/**
+	 * Create and initialize the resource loader.
+	 */
+	public PackageStringResourceLoader()
+	{
+	}
+
+	/**
+	 * 
+	 * @see org.apache.wicket.resource.loader.IStringResourceLoader#loadStringResource(java.lang.Class,
+	 *      java.lang.String, java.util.Locale, java.lang.String)
+	 */
+	public String loadStringResource(final Class clazz, final String key, final Locale locale,
+		final String style)
+	{
+		if (clazz == null)
+		{
+			return null;
+		}
+
+		String packageName = clazz.getPackage().getName();
+		packageName = packageName.replace('.', '/');
+
+		// Load the properties associated with the path
+		IPropertiesFactory propertiesFactory = Application.get()
+			.getResourceSettings()
+			.getPropertiesFactory();
+
+		while (packageName.length() > 0)
+		{
+			// Create the base path
+			String path = packageName + "/" + filename;
+
+			// Iterator over all the combinations
+			ResourceNameIterator iter = new ResourceNameIterator(path, style, locale, null);
+			while (iter.hasNext())
+			{
+				String newPath = (String)iter.next();
+
+				final 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;
+					}
+				}
+			}
+
+			// Didn't find the key yet, continue searching if possible
+			packageName = Strings.beforeLast(packageName, '/');
+		}
+
+		// not found
+		return null;
+	}
+
+	/**
+	 * 
+	 * @see org.apache.wicket.resource.loader.IStringResourceLoader#loadStringResource(org.apache.wicket.Component,
+	 *      java.lang.String)
+	 */
+	public String loadStringResource(final Component component, final String key)
+	{
+		if (component == null)
+		{
+			return null;
+		}
+
+		// The return value
+		Locale locale = component.getLocale();
+		String style = component.getStyle();
+
+		return loadStringResource(component.getClass(), key, locale, style);
+	}
+
+	/**
+	 * Gets the properties file filename (without extension)
+	 * 
+	 * @return filename
+	 */
+	public String getFilename()
+	{
+		return filename;
+	}
+
+	/**
+	 * Sets the properties filename (without extension)
+	 * 
+	 * @param filename
+	 *            filename
+	 */
+	public void setFilename(String filename)
+	{
+		this.filename = filename;
+	}
+}

Modified: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/resource/locator/ExtensionResourceNameIterator.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/resource/locator/ExtensionResourceNameIterator.java?rev=646290&r1=646289&r2=646290&view=diff
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/resource/locator/ExtensionResourceNameIterator.java (original)
+++ wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/resource/locator/ExtensionResourceNameIterator.java Wed Apr  9 04:55:03 2008
@@ -62,13 +62,13 @@
 	 */
 	public ExtensionResourceNameIterator(String path, final String extension)
 	{
-		if (extension == null)
+		if ((extension == null) && (path.indexOf('.') != -1))
 		{
 			// Get the extension from the path provided
 			extensions = new String[] { "." + Strings.lastPathComponent(path, '.') };
 			path = Strings.beforeLastPathComponent(path, '.');
 		}
-		else
+		else if (extension != null)
 		{
 			// Extension can be a comma separated list
 			extensions = Strings.split(extension, ',');
@@ -81,9 +81,14 @@
 				}
 			}
 		}
+		else
+		{
+			extensions = new String[1];
+			extensions[0] = ".";
+		}
 
 		this.path = path;
-		this.index = 0;
+		index = 0;
 	}
 
 	/**
@@ -92,7 +97,7 @@
 	 */
 	public boolean hasNext()
 	{
-		return (this.index < this.extensions.length);
+		return (index < extensions.length);
 	}
 
 	/**
@@ -101,7 +106,7 @@
 	 */
 	public Object next()
 	{
-		return path + this.extensions[this.index++];
+		return path + extensions[index++];
 	}
 
 	/**

Modified: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/resource/locator/ResourceNameIterator.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/resource/locator/ResourceNameIterator.java?rev=646290&r1=646289&r2=646290&view=diff
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/resource/locator/ResourceNameIterator.java (original)
+++ wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/resource/locator/ResourceNameIterator.java Wed Apr  9 04:55:03 2008
@@ -74,13 +74,13 @@
 	 * @param locale
 	 *            The Locale to apply
 	 * @param extensions
-	 *            the filname's extensions (comma separated)
+	 *            the filname's extensions (comma separated). Null permitted
 	 */
 	public ResourceNameIterator(String path, final String style, final Locale locale,
-			final String extensions)
+		final String extensions)
 	{
 		this.locale = locale;
-		if (extensions == null)
+		if ((extensions == null) && (path.indexOf('.') != -1))
 		{
 			this.extensions = Strings.afterLast(path, '.');
 			path = Strings.beforeLast(path, '.');
@@ -90,7 +90,7 @@
 			this.extensions = extensions;
 		}
 
-		this.styleIterator = new StyleAndVariationResourceNameIterator(path, style, null);
+		styleIterator = new StyleAndVariationResourceNameIterator(path, style, null);
 	}
 
 	/**
@@ -100,7 +100,7 @@
 	 */
 	public final Locale getLocale()
 	{
-		return this.currentLocale;
+		return currentLocale;
 	}
 
 	/**
@@ -109,9 +109,9 @@
 	public boolean hasNext()
 	{
 		// Most inner loop. Loop through all extensions provided
-		if (this.extenstionsIterator != null)
+		if (extenstionsIterator != null)
 		{
-			if (this.extenstionsIterator.hasNext() == true)
+			if (extenstionsIterator.hasNext() == true)
 			{
 				return true;
 			}
@@ -123,38 +123,36 @@
 		}
 
 		// 2nd inner loop: Loop through all Locale combinations
-		if (this.localeIterator != null)
+		if (localeIterator != null)
 		{
-			while (this.localeIterator.hasNext())
+			while (localeIterator.hasNext())
 			{
 				// Get the next Locale from the iterator and start the next
 				// inner iterator over again.
-				String newPath = (String)this.localeIterator.next();
-				this.currentLocale = this.localeIterator.getLocale();
-				this.extenstionsIterator = new ExtensionResourceNameIterator(newPath,
-						this.extensions);
-				if (this.extenstionsIterator.hasNext() == true)
+				String newPath = (String)localeIterator.next();
+				currentLocale = localeIterator.getLocale();
+				extenstionsIterator = new ExtensionResourceNameIterator(newPath, extensions);
+				if (extenstionsIterator.hasNext() == true)
 				{
 					return true;
 				}
 			}
-			this.localeIterator = null;
+			localeIterator = null;
 		}
 
 		// Most outer loop: Loop through all combinations of styles and
 		// variations
-		while (this.styleIterator.hasNext())
+		while (styleIterator.hasNext())
 		{
-			String newPath = (String)this.styleIterator.next();
+			String newPath = (String)styleIterator.next();
 
-			this.localeIterator = new LocaleResourceNameIterator(newPath, this.locale);
-			while (this.localeIterator.hasNext())
+			localeIterator = new LocaleResourceNameIterator(newPath, locale);
+			while (localeIterator.hasNext())
 			{
-				newPath = (String)this.localeIterator.next();
-				this.currentLocale = this.localeIterator.getLocale();
-				this.extenstionsIterator = new ExtensionResourceNameIterator(newPath,
-						this.extensions);
-				if (this.extenstionsIterator.hasNext() == true)
+				newPath = (String)localeIterator.next();
+				currentLocale = localeIterator.getLocale();
+				extenstionsIterator = new ExtensionResourceNameIterator(newPath, extensions);
+				if (extenstionsIterator.hasNext() == true)
 				{
 					return true;
 				}
@@ -175,7 +173,7 @@
 			return extenstionsIterator.next();
 		}
 		throw new WicketRuntimeException(
-				"Illegal call of next(). Iterator not properly initialized");
+			"Illegal call of next(). Iterator not properly initialized");
 	}
 
 	/**

Modified: wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/ApplicationSettingsTest.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/ApplicationSettingsTest.java?rev=646290&r1=646289&r2=646290&view=diff
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/ApplicationSettingsTest.java (original)
+++ wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/ApplicationSettingsTest.java Wed Apr  9 04:55:03 2008
@@ -24,6 +24,7 @@
 import org.apache.wicket.resource.loader.BundleStringResourceLoader;
 import org.apache.wicket.resource.loader.ClassStringResourceLoader;
 import org.apache.wicket.resource.loader.ComponentStringResourceLoader;
+import org.apache.wicket.resource.loader.PackageStringResourceLoader;
 import org.apache.wicket.settings.Settings;
 import org.apache.wicket.util.tester.WicketTester;
 
@@ -61,8 +62,8 @@
 	public void testExceptionOnMissingResourceDefaultValue() throws Exception
 	{
 		Settings settings = new Settings(tester.getApplication());
-		Assert.assertTrue("exceptionOnMissingResource should default to true", settings
-				.getThrowExceptionOnMissingResource());
+		Assert.assertTrue("exceptionOnMissingResource should default to true",
+			settings.getThrowExceptionOnMissingResource());
 	}
 
 	/**
@@ -72,8 +73,8 @@
 	{
 		Settings settings = new Settings(tester.getApplication());
 		settings.setThrowExceptionOnMissingResource(false);
-		Assert.assertFalse("exceptionOnMissingResource should have been set to false", settings
-				.getThrowExceptionOnMissingResource());
+		Assert.assertFalse("exceptionOnMissingResource should have been set to false",
+			settings.getThrowExceptionOnMissingResource());
 	}
 
 	/**
@@ -82,8 +83,8 @@
 	public void testUseDefaultOnMissingResourceDefaultValue() throws Exception
 	{
 		Settings settings = new Settings(tester.getApplication());
-		Assert.assertTrue("useDefaultOnMissingResource should default to true", settings
-				.getUseDefaultOnMissingResource());
+		Assert.assertTrue("useDefaultOnMissingResource should default to true",
+			settings.getUseDefaultOnMissingResource());
 	}
 
 	/**
@@ -93,8 +94,8 @@
 	{
 		Settings settings = new Settings(tester.getApplication());
 		settings.setUseDefaultOnMissingResource(false);
-		Assert.assertFalse("useDefaultOnMissingResource should have been set to false", settings
-				.getUseDefaultOnMissingResource());
+		Assert.assertFalse("useDefaultOnMissingResource should have been set to false",
+			settings.getUseDefaultOnMissingResource());
 	}
 
 	/**
@@ -104,11 +105,13 @@
 	{
 		Settings settings = new Settings(tester.getApplication());
 		List loaders = settings.getStringResourceLoaders();
-		Assert.assertEquals("There should be 2 default loaders", 2, loaders.size());
+		Assert.assertEquals("There should be 3 default loaders", 3, loaders.size());
 		Assert.assertTrue("First loader one should be the component one",
-				loaders.get(0) instanceof ComponentStringResourceLoader);
+			loaders.get(0) instanceof ComponentStringResourceLoader);
 		Assert.assertTrue("Second loader should be the application one",
-				loaders.get(1) instanceof ClassStringResourceLoader);
+			loaders.get(1) instanceof PackageStringResourceLoader);
+		Assert.assertTrue("Third loader should be the application one",
+			loaders.get(2) instanceof ClassStringResourceLoader);
 	}
 
 	/**
@@ -118,15 +121,16 @@
 	{
 		Application dummy = tester.getApplication();
 		Settings settings = new Settings(dummy);
+		settings.getStringResourceLoaders().clear();
 		settings.addStringResourceLoader(new BundleStringResourceLoader(
-				"org.apache.wicket.resource.DummyResources"));
+			"org.apache.wicket.resource.DummyResources"));
 		settings.addStringResourceLoader(new ComponentStringResourceLoader());
 		List loaders = settings.getStringResourceLoaders();
 		Assert.assertEquals("There should be 2 overridden loaders", 2, loaders.size());
 		Assert.assertTrue("First loader one should be the bundle one",
-				loaders.get(0) instanceof BundleStringResourceLoader);
+			loaders.get(0) instanceof BundleStringResourceLoader);
 		Assert.assertTrue("Second loader should be the component one",
-				loaders.get(1) instanceof ComponentStringResourceLoader);
+			loaders.get(1) instanceof ComponentStringResourceLoader);
 	}
 
 	/**
@@ -136,6 +140,6 @@
 	{
 		Application dummy = tester.getApplication();
 		Assert.assertNotNull("Localizer should be available", dummy.getResourceSettings()
-				.getLocalizer());
+			.getLocalizer());
 	}
 }

Modified: wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/link/AutolinkPageExpectedResult_4.html
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/link/AutolinkPageExpectedResult_4.html?rev=646290&r1=646289&r2=646290&view=diff
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/link/AutolinkPageExpectedResult_4.html (original)
+++ wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/link/AutolinkPageExpectedResult_4.html Wed Apr  9 04:55:03 2008
@@ -4,8 +4,8 @@
   <!-- File/page does not exist => Do not change href at all -->
   <a href="PageDoesNotExist.html">Home</a>
   <!-- Reference an internal target => Do not change href at all -->
-  <a href="resources/org.apache.wicket.markup.html.link.AutolinkPage_4/#link1">Link 1</a>
-  <a href="resources/org.apache.wicket.markup.html.link.AutolinkPage_4/">Link 1</a>
+  <a href="#link1">Link 1</a>
+  <a href="">Link 1</a>
   <!-- Supported since 1.2 -->
   <a href="?wicket:bookmarkablePage=%3Aorg.apache.wicket.markup.html.link.Page1#link1">Link 1</a>
 </wicket:link>

Added: wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/resource/loader/ClassStringResourceLoaderTest$MyValidator.properties
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/resource/loader/ClassStringResourceLoaderTest%24MyValidator.properties?rev=646290&view=auto
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/resource/loader/ClassStringResourceLoaderTest$MyValidator.properties (added)
+++ wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/resource/loader/ClassStringResourceLoaderTest$MyValidator.properties Wed Apr  9 04:55:03 2008
@@ -0,0 +1,2 @@
+
+error=${label} is invalid

Added: wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/resource/loader/ClassStringResourceLoaderTest$MyValidator_nl.properties
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/resource/loader/ClassStringResourceLoaderTest%24MyValidator_nl.properties?rev=646290&view=auto
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/resource/loader/ClassStringResourceLoaderTest$MyValidator_nl.properties (added)
+++ wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/resource/loader/ClassStringResourceLoaderTest$MyValidator_nl.properties Wed Apr  9 04:55:03 2008
@@ -0,0 +1,2 @@
+
+error=${label} is niet goed

Added: wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/resource/loader/ClassStringResourceLoaderTest.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/resource/loader/ClassStringResourceLoaderTest.java?rev=646290&view=auto
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/resource/loader/ClassStringResourceLoaderTest.java (added)
+++ wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/resource/loader/ClassStringResourceLoaderTest.java Wed Apr  9 04:55:03 2008
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.resource.loader;
+
+import org.apache.wicket.WicketTestCase;
+import org.apache.wicket.validation.IValidatable;
+import org.apache.wicket.validation.validator.AbstractValidator;
+
+/**
+ * 
+ */
+public class ClassStringResourceLoaderTest extends WicketTestCase
+{
+
+	/**
+	 * Construct.
+	 * 
+	 * @param name
+	 */
+	public ClassStringResourceLoaderTest(String name)
+	{
+		super(name);
+	}
+
+	/**
+	 * 
+	 */
+	public void testValidator1()
+	{
+		ClassStringResourceLoader loader = new ClassStringResourceLoader(MyValidator.class);
+		tester.getApplication().getResourceSettings().addStringResourceLoader(loader);
+
+		assertEquals("${label} is invalid", loader.loadStringResource(null, "error"));
+	}
+
+	/**
+	 * 
+	 */
+	public class MyValidator extends AbstractValidator
+	{
+		private static final long serialVersionUID = 1L;
+
+		/**
+		 * 
+		 * @see org.apache.wicket.validation.validator.AbstractValidator#onValidate(org.apache.wicket.validation.IValidatable)
+		 */
+		protected void onValidate(IValidatable v)
+		{
+			error(v);
+		}
+	}
+}

Added: wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/resource/loader/ComponentStringResourceLoaderTest.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/resource/loader/ComponentStringResourceLoaderTest.java?rev=646290&view=auto
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/resource/loader/ComponentStringResourceLoaderTest.java (added)
+++ wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/resource/loader/ComponentStringResourceLoaderTest.java Wed Apr  9 04:55:03 2008
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.resource.loader;
+
+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.PropertiesFactory;
+
+/**
+ * 
+ */
+public class ComponentStringResourceLoaderTest extends WicketTestCase
+{
+	/**
+	 * Construct.
+	 * 
+	 * @param name
+	 */
+	public ComponentStringResourceLoaderTest(String name)
+	{
+		super(name);
+	}
+
+	/**
+	 * @throws Exception
+	 */
+	public void testRenderHomePage_1() throws Exception
+	{
+		try
+		{
+			// The xml markup file and the search for an xml properties
+			// file get in the way
+			executeTest(TestPage_1.class, "TestPageExpectedResult_1.xml");
+		}
+		catch (WicketRuntimeException ex)
+		{
+		}
+	}
+
+	/**
+	 * @throws Exception
+	 */
+	public void testRenderHomePage_2() throws Exception
+	{
+		// Avoid the conflict by limiting the search for properties files
+		// to *.properties
+		IPropertiesFactory myFac = new MyPropertiesFactory(tester.getApplication());
+		tester.getApplication().getResourceSettings().setPropertiesFactory(myFac);
+
+		executeTest(TestPage_1.class, "TestPageExpectedResult_1.xml");
+	}
+
+	/**
+	 * 
+	 */
+	private class MyPropertiesFactory extends PropertiesFactory
+	{
+		/**
+		 * Construct.
+		 * 
+		 * @param application
+		 */
+		public MyPropertiesFactory(Application application)
+		{
+			super(application);
+
+			getPropertiesLoaders().clear();
+			getPropertiesLoaders().add(new PropertiesFilePropertiesLoader());
+		}
+	}
+}

Added: wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/resource/loader/PackageStringResourceLoaderTest.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/resource/loader/PackageStringResourceLoaderTest.java?rev=646290&view=auto
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/resource/loader/PackageStringResourceLoaderTest.java (added)
+++ wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/resource/loader/PackageStringResourceLoaderTest.java Wed Apr  9 04:55:03 2008
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.resource.loader;
+
+import org.apache.wicket.Page;
+import org.apache.wicket.WicketTestCase;
+import org.apache.wicket.resource.loader.pages.Test1;
+
+/**
+ * 
+ */
+public class PackageStringResourceLoaderTest extends WicketTestCase
+{
+	/**
+	 * Construct.
+	 * 
+	 * @param name
+	 */
+	public PackageStringResourceLoaderTest(String name)
+	{
+		super(name);
+	}
+
+	/**
+	 * 
+	 */
+	public void testPackageFileInComponentPackage()
+	{
+		Page page = new Test1();
+		PackageStringResourceLoader loader = new PackageStringResourceLoader();
+		assertEquals("test successful", loader.loadStringResource(page, "my_package_test_1"));
+	}
+
+	/**
+	 * 
+	 */
+	public void testPackageFileInParentPackage()
+	{
+		Page page = new Test1();
+		PackageStringResourceLoader loader = new PackageStringResourceLoader();
+		assertEquals("test 222", loader.loadStringResource(page, "my_package_test_2"));
+	}
+
+	/**
+	 * 
+	 */
+	public void testNotFound()
+	{
+		Page page = new Test1();
+		PackageStringResourceLoader loader = new PackageStringResourceLoader();
+		assertNull(loader.loadStringResource(page, "abcdefgh"));
+	}
+
+	/**
+	 * @throws Exception
+	 */
+	public void test_1() throws Exception
+	{
+		executeTest(Test1.class, "PackageTestPageExpectedResult_1.html");
+	}
+}

Added: wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/resource/loader/PackageTestPageExpectedResult_1.html
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/resource/loader/PackageTestPageExpectedResult_1.html?rev=646290&view=auto
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/resource/loader/PackageTestPageExpectedResult_1.html (added)
+++ wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/resource/loader/PackageTestPageExpectedResult_1.html Wed Apr  9 04:55:03 2008
@@ -0,0 +1,21 @@
+<!--
+    ====================================================================
+    Licensed under the Apache License, Version 2.0 (the "License");
+    you may not use this file except in compliance with the License.
+    You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+<html xmlns:wicket>
+<body>
+  <span wicket:id="label1">test successful</span>
+  <span wicket:id="label2">test 222</span>
+  <span wicket:id="label3">not found</span>
+</body>
+</html>

Added: wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/resource/loader/TestPageExpectedResult_1.xml
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/resource/loader/TestPageExpectedResult_1.xml?rev=646290&view=auto
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/resource/loader/TestPageExpectedResult_1.xml (added)
+++ wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/resource/loader/TestPageExpectedResult_1.xml Wed Apr  9 04:55:03 2008
@@ -0,0 +1,23 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+        http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+-->
+ 
+<root>
+  <order>
+     <item wicket:id="item">data from my properties file</item>
+  </order>
+</root>

Added: wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/resource/loader/TestPage_1.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/resource/loader/TestPage_1.java?rev=646290&view=auto
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/resource/loader/TestPage_1.java (added)
+++ wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/resource/loader/TestPage_1.java Wed Apr  9 04:55:03 2008
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.resource.loader;
+
+import org.apache.wicket.markup.html.basic.Label;
+
+/**
+ * Mock page for testing.
+ * 
+ */
+public class TestPage_1 extends XmlPage
+{
+	private static final long serialVersionUID = 1L;
+
+	/**
+	 * Construct.
+	 */
+	public TestPage_1()
+	{
+		add(new Label("item", getString("myTest")));
+	}
+}

Added: wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/resource/loader/TestPage_1.xml
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/resource/loader/TestPage_1.xml?rev=646290&view=auto
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/resource/loader/TestPage_1.xml (added)
+++ wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/resource/loader/TestPage_1.xml Wed Apr  9 04:55:03 2008
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+        http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+-->
+ 
+<root>
+  <order>
+     <item wicket:id="item">test</item>
+  </order>
+</root>

Added: wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/resource/loader/XmlPage.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/resource/loader/XmlPage.java?rev=646290&view=auto
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/resource/loader/XmlPage.java (added)
+++ wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/resource/loader/XmlPage.java Wed Apr  9 04:55:03 2008
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.resource.loader;
+
+import org.apache.wicket.markup.html.WebPage;
+
+/**
+ * Mock page for testing.
+ * 
+ */
+public class XmlPage extends WebPage
+{
+	private static final long serialVersionUID = 1L;
+
+	/**
+	 * Construct.
+	 */
+	public XmlPage()
+	{
+	}
+
+	/**
+	 * @see org.apache.wicket.markup.html.WebPage#getMarkupType()
+	 */
+	public String getMarkupType()
+	{
+		return "xml";
+	}
+}

Added: wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/resource/loader/XmlPage.properties
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/resource/loader/XmlPage.properties?rev=646290&view=auto
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/resource/loader/XmlPage.properties (added)
+++ wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/resource/loader/XmlPage.properties Wed Apr  9 04:55:03 2008
@@ -0,0 +1 @@
+myTest=data from my properties file
\ No newline at end of file

Added: wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/resource/loader/package.properties
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/resource/loader/package.properties?rev=646290&view=auto
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/resource/loader/package.properties (added)
+++ wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/resource/loader/package.properties Wed Apr  9 04:55:03 2008
@@ -0,0 +1,2 @@
+# Package level properties file
+my_package_test_2 = test 222
\ No newline at end of file

Added: wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/resource/loader/pages/Test1.html
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/resource/loader/pages/Test1.html?rev=646290&view=auto
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/resource/loader/pages/Test1.html (added)
+++ wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/resource/loader/pages/Test1.html Wed Apr  9 04:55:03 2008
@@ -0,0 +1,21 @@
+<!--
+    ====================================================================
+    Licensed under the Apache License, Version 2.0 (the "License");
+    you may not use this file except in compliance with the License.
+    You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+<html xmlns:wicket>
+<body>
+  <span wicket:id="label1">test</span>
+  <span wicket:id="label2">test</span>
+  <span wicket:id="label3">test</span>
+</body>
+</html>

Added: wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/resource/loader/pages/Test1.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/resource/loader/pages/Test1.java?rev=646290&view=auto
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/resource/loader/pages/Test1.java (added)
+++ wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/resource/loader/pages/Test1.java Wed Apr  9 04:55:03 2008
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.resource.loader.pages;
+
+import org.apache.wicket.markup.html.WebPage;
+import org.apache.wicket.markup.html.basic.Label;
+
+/**
+ * 
+ */
+public class Test1 extends WebPage
+{
+	/**
+	 * Construct.
+	 */
+	public Test1()
+	{
+		String value1 = getString("my_package_test_1");
+		add(new Label("label1", value1));
+
+		String value2 = getString("my_package_test_2");
+		add(new Label("label2", value2));
+
+		String value3 = getString("abcdefgh", null, "not found");
+		add(new Label("label3", value3));
+	}
+}

Added: wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/resource/loader/pages/package.properties
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/resource/loader/pages/package.properties?rev=646290&view=auto
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/resource/loader/pages/package.properties (added)
+++ wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/resource/loader/pages/package.properties Wed Apr  9 04:55:03 2008
@@ -0,0 +1,2 @@
+# Package level properties file
+my_package_test_1 = test successful
\ No newline at end of file