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 2010/08/29 22:17:45 UTC

svn commit: r990642 - in /wicket/trunk/wicket/src: main/java/org/apache/wicket/request/resource/ test/java/org/apache/wicket/request/mapper/

Author: jdonnerstag
Date: Sun Aug 29 20:17:44 2010
New Revision: 990642

URL: http://svn.apache.org/viewvc?rev=990642&view=rev
Log:
improved ResourceReferenceRegistry "Key" usage
Issue: WICKET-1996

Modified:
    wicket/trunk/wicket/src/main/java/org/apache/wicket/request/resource/PackageResource.java
    wicket/trunk/wicket/src/main/java/org/apache/wicket/request/resource/PackageResourceReference.java
    wicket/trunk/wicket/src/main/java/org/apache/wicket/request/resource/ResourceReference.java
    wicket/trunk/wicket/src/main/java/org/apache/wicket/request/resource/ResourceReferenceRegistry.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/request/mapper/TestMapperContext.java

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=990642&r1=990641&r2=990642&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 Aug 29 20:17:44 2010
@@ -20,7 +20,7 @@ import java.util.Locale;
 
 import javax.servlet.http.HttpServletResponse;
 
-import org.apache.wicket.Application;
+import org.apache.wicket.ThreadContext;
 import org.apache.wicket.WicketRuntimeException;
 import org.apache.wicket.markup.html.IPackageResourceGuard;
 import org.apache.wicket.request.cycle.RequestCycle;
@@ -138,7 +138,7 @@ public class PackageResource implements 
 	public void respond(Attributes attributes)
 	{
 		// Locate resource
-		IResourceStream resourceStream = Application.get()
+		IResourceStream resourceStream = ThreadContext.getApplication()
 			.getResourceSettings()
 			.getResourceStreamLocator()
 			.locate(getScope(), absolutePath, style, variation, locale, null);
@@ -172,7 +172,7 @@ public class PackageResource implements 
 	 */
 	private boolean accept(Class<?> scope, String path)
 	{
-		IPackageResourceGuard guard = Application.get()
+		IPackageResourceGuard guard = ThreadContext.getApplication()
 			.getResourceSettings()
 			.getPackageResourceGuard();
 
@@ -200,8 +200,9 @@ public class PackageResource implements 
 		final String style, final String variation)
 	{
 		String absolutePath = Packages.absolutePath(scope, path);
-		return Application.get().getResourceSettings().getResourceStreamLocator().locate(scope,
-			absolutePath, style, variation, locale, null) != null;
+		return ThreadContext.getApplication()
+			.getResourceSettings()
+			.getResourceStreamLocator()
+			.locate(scope, absolutePath, style, variation, locale, null) != null;
 	}
-
 }

Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/request/resource/PackageResourceReference.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/request/resource/PackageResourceReference.java?rev=990642&r1=990641&r2=990642&view=diff
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/request/resource/PackageResourceReference.java (original)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/request/resource/PackageResourceReference.java Sun Aug 29 20:17:44 2010
@@ -17,11 +17,11 @@
 package org.apache.wicket.request.resource;
 
 import java.util.Locale;
-import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 
-import org.apache.wicket.Application;
 import org.apache.wicket.Session;
+import org.apache.wicket.ThreadContext;
+import org.apache.wicket.util.lang.Generics;
 import org.apache.wicket.util.lang.Packages;
 import org.apache.wicket.util.resource.locator.IResourceStreamLocator;
 
@@ -31,32 +31,74 @@ public class PackageResourceReference ex
 
 	private transient ConcurrentMap<UrlAttributes, UrlAttributes> urlAttributesCacheMap;
 
-	public PackageResourceReference(Class<?> scope, String name, Locale locale, String style,
-		String variation)
+	/**
+	 * Construct.
+	 * 
+	 * @param key
+	 */
+	public PackageResourceReference(final Key key)
+	{
+		super(key);
+	}
+
+	/**
+	 * Construct.
+	 * 
+	 * @param scope
+	 * @param name
+	 * @param locale
+	 * @param style
+	 * @param variation
+	 */
+	public PackageResourceReference(final Class<?> scope, final String name, final Locale locale,
+		final String style, String variation)
 	{
 		super(scope, name, locale, style, variation);
 	}
 
-	public PackageResourceReference(Class<?> scope, String name)
+	/**
+	 * Construct.
+	 * 
+	 * @param scope
+	 * @param name
+	 */
+	public PackageResourceReference(final Class<?> scope, final String name)
 	{
 		super(scope, name);
 	}
 
-	public PackageResourceReference(String name)
+	/**
+	 * Construct.
+	 * 
+	 * @param name
+	 */
+	public PackageResourceReference(final String name)
 	{
 		super(name);
 	}
 
+	/**
+	 * @see org.apache.wicket.request.resource.ResourceReference#getResource()
+	 */
 	@Override
 	public IResource getResource()
 	{
 		return new PackageResource(getScope(), getName(), getLocale(), getStyle(), getVariation());
 	}
 
-	private UrlAttributes testResource(IResourceStreamLocator locator, Locale locale, String style,
-		String variation)
+	/**
+	 * 
+	 * @param locator
+	 * @param locale
+	 * @param style
+	 * @param variation
+	 * @return
+	 */
+	private UrlAttributes testResource(final IResourceStreamLocator locator, final Locale locale,
+		final String style, final String variation)
 	{
 		String absolutePath = Packages.absolutePath(getScope(), getName());
+
 		if (locator.locate(getScope(), absolutePath, style, variation, locale, null, true) != null)
 		{
 			return new UrlAttributes(locale, style, variation);
@@ -67,15 +109,21 @@ public class PackageResourceReference ex
 		}
 	}
 
-	private UrlAttributes getUrlAttributes(Locale locale, String style, String variation)
+	/**
+	 * 
+	 * @param locale
+	 * @param style
+	 * @param variation
+	 * @return
+	 */
+	private UrlAttributes getUrlAttributes(final Locale locale, final String style,
+		final String variation)
 	{
-		IResourceStreamLocator locator = Application.get()
+		IResourceStreamLocator locator = ThreadContext.getApplication()
 			.getResourceSettings()
 			.getResourceStreamLocator();
 
-		UrlAttributes res;
-
-		res = testResource(locator, locale, style, variation);
+		UrlAttributes res = testResource(locator, locale, style, variation);
 		if (res == null)
 		{
 			res = testResource(locator, locale, style, null);
@@ -107,6 +155,9 @@ public class PackageResourceReference ex
 		return res;
 	}
 
+	/**
+	 * @see org.apache.wicket.request.resource.ResourceReference#getUrlAttributes()
+	 */
 	@Override
 	public UrlAttributes getUrlAttributes()
 	{
@@ -114,12 +165,12 @@ public class PackageResourceReference ex
 		String style = getStyle() != null ? getStyle() : Session.get().getStyle();
 		String variation = getVariation();
 
-		UrlAttributes key = new UrlAttributes(locale, style, variation);
-
 		if (urlAttributesCacheMap == null)
 		{
-			urlAttributesCacheMap = new ConcurrentHashMap<UrlAttributes, UrlAttributes>();
+			urlAttributesCacheMap = Generics.newConcurrentHashMap();
 		}
+
+		UrlAttributes key = new UrlAttributes(locale, style, variation);
 		UrlAttributes value = urlAttributesCacheMap.get(key);
 		if (value == null)
 		{

Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/request/resource/ResourceReference.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/request/resource/ResourceReference.java?rev=990642&r1=990641&r2=990642&view=diff
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/request/resource/ResourceReference.java (original)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/request/resource/ResourceReference.java Sun Aug 29 20:17:44 2010
@@ -34,16 +34,26 @@ import org.apache.wicket.util.lang.Wicke
  * locales, styles and variations.
  * 
  * @author Matej Knopp
+ * @author Juergen Donnerstag
  */
 public abstract class ResourceReference implements Serializable
 {
 	private static final long serialVersionUID = 1L;
 
-	private final String scope;
-	private final String name;
-	private final Locale locale;
-	private final String style;
-	private final String variation;
+	private final Key data;
+
+	/**
+	 * Creates new {@link ResourceReference} instance.
+	 * 
+	 * @param key
+	 *            The data makeing up the resource reference
+	 */
+	public ResourceReference(final Key key)
+	{
+		Args.notNull(key, "key");
+
+		data = key;
+	}
 
 	/**
 	 * Creates new {@link ResourceReference} instance.
@@ -62,11 +72,7 @@ public abstract class ResourceReference 
 		Args.notNull(scope, "scope");
 		Args.notNull(name, "name");
 
-		this.scope = scope.getName();
-		this.name = name;
-		this.locale = locale;
-		this.style = style;
-		this.variation = variation;
+		data = new Key(scope.getName(), name, locale, style, variation);
 	}
 
 	/**
@@ -96,11 +102,21 @@ public abstract class ResourceReference 
 	}
 
 	/**
+	 * @return Gets the data making up the resource reference. They'll be use by
+	 *         ResourceReferenceRegistry to make up the key under which the resource reference gets
+	 *         stored.
+	 */
+	Key getKey()
+	{
+		return data;
+	}
+
+	/**
 	 * @return name
 	 */
 	public String getName()
 	{
-		return name;
+		return data.getName();
 	}
 
 	/**
@@ -108,7 +124,7 @@ public abstract class ResourceReference 
 	 */
 	public Class<?> getScope()
 	{
-		return WicketObjects.resolveClass(scope);
+		return WicketObjects.resolveClass(data.getScope());
 	}
 
 	/**
@@ -116,7 +132,7 @@ public abstract class ResourceReference 
 	 */
 	public Locale getLocale()
 	{
-		return locale;
+		return data.getLocale();
 	}
 
 	/**
@@ -124,7 +140,7 @@ public abstract class ResourceReference 
 	 */
 	public String getStyle()
 	{
-		return style;
+		return data.getStyle();
 	}
 
 	/**
@@ -132,7 +148,18 @@ public abstract class ResourceReference 
 	 */
 	public String getVariation()
 	{
-		return variation;
+		return data.getVariation();
+	}
+
+	/**
+	 * Can be used to disable registering certain resource references in
+	 * {@link ResourceReferenceRegistry}.
+	 * 
+	 * @return <code>true</code> if this reference can be registered, <code>false</code> otherwise.
+	 */
+	public boolean canBeRegistered()
+	{
+		return true;
 	}
 
 	/**
@@ -150,11 +177,7 @@ public abstract class ResourceReference 
 			return false;
 		}
 		ResourceReference that = (ResourceReference)obj;
-		return Objects.equal(scope, that.scope) && //
-			Objects.equal(name, that.name) && //
-			Objects.equal(locale, that.locale) && //
-			Objects.equal(style, that.style) && //
-			Objects.equal(variation, that.variation);
+		return Objects.equal(data, that.data);
 	}
 
 	/**
@@ -163,7 +186,7 @@ public abstract class ResourceReference 
 	@Override
 	public int hashCode()
 	{
-		return Objects.hashCode(scope, name, locale, style, variation);
+		return data.hashCode();
 	}
 
 	/**
@@ -233,6 +256,9 @@ public abstract class ResourceReference 
 			return variation;
 		}
 
+		/**
+		 * @see java.lang.Object#equals(java.lang.Object)
+		 */
 		@Override
 		public boolean equals(Object obj)
 		{
@@ -250,6 +276,9 @@ public abstract class ResourceReference 
 				Objects.equal(getVariation(), that.getVariation());
 		}
 
+		/**
+		 * @see java.lang.Object#hashCode()
+		 */
 		@Override
 		public int hashCode()
 		{
@@ -258,13 +287,146 @@ public abstract class ResourceReference 
 	}
 
 	/**
-	 * Can be used to disable registering certain resource references in
-	 * {@link ResourceReferenceRegistry}.
-	 * 
-	 * @return <code>true</code> if this reference can be registered, <code>false</code> otherwise.
+	 * A (re-usable) data store for all relevant ResourceReference data
 	 */
-	public boolean canBeRegistered()
+	public final static class Key
 	{
-		return true;
+		final String scope;
+		final String name;
+		final Locale locale;
+		final String style;
+		final String variation;
+
+		/**
+		 * Construct.
+		 * 
+		 * @param reference
+		 */
+		public Key(final ResourceReference reference)
+		{
+			this(reference.getScope().getName(), reference.getName(), reference.getLocale(),
+				reference.getStyle(), reference.getVariation());
+		}
+
+		/**
+		 * Construct.
+		 * 
+		 * @param scope
+		 * @param name
+		 * @param locale
+		 * @param style
+		 * @param variation
+		 */
+		public Key(final String scope, final String name, final Locale locale, final String style,
+			final String variation)
+		{
+			Args.notNull(scope, "scope");
+			Args.notNull(name, "name");
+
+			this.scope = scope.intern();
+			this.name = name.intern();
+			this.locale = locale;
+			this.style = style != null ? style.intern() : null;
+			this.variation = variation != null ? variation.intern() : null;
+		}
+
+		/**
+		 * @see java.lang.Object#equals(java.lang.Object)
+		 */
+		@Override
+		public boolean equals(final Object obj)
+		{
+			if (this == obj)
+			{
+				return true;
+			}
+			if (obj instanceof Key == false)
+			{
+				return false;
+			}
+			Key that = (Key)obj;
+			return Objects.equal(scope, that.scope) && //
+				Objects.equal(name, that.name) && //
+				Objects.equal(locale, that.locale) && //
+				Objects.equal(style, that.style) && //
+				Objects.equal(variation, that.variation);
+		}
+
+		/**
+		 * @see java.lang.Object#hashCode()
+		 */
+		@Override
+		public int hashCode()
+		{
+			return Objects.hashCode(scope, name, locale, style, variation);
+		}
+
+		/**
+		 * Gets scope.
+		 * 
+		 * @return scope
+		 */
+		public final String getScope()
+		{
+			return scope;
+		}
+
+		/**
+		 * @return Assuming scope ist a fully qualified class name, than get the associated class
+		 */
+		public final Class<?> getScopeClass()
+		{
+			return WicketObjects.resolveClass(scope);
+		}
+
+		/**
+		 * Gets name.
+		 * 
+		 * @return name
+		 */
+		public final String getName()
+		{
+			return name;
+		}
+
+		/**
+		 * Gets locale.
+		 * 
+		 * @return locale
+		 */
+		public final Locale getLocale()
+		{
+			return locale;
+		}
+
+		/**
+		 * Gets style.
+		 * 
+		 * @return style
+		 */
+		public final String getStyle()
+		{
+			return style;
+		}
+
+		/**
+		 * Gets variation.
+		 * 
+		 * @return variation
+		 */
+		public final String getVariation()
+		{
+			return variation;
+		}
+
+		/**
+		 * @see java.lang.Object#toString()
+		 */
+		@Override
+		public String toString()
+		{
+			return "scope: " + scope + "; name: " + name + "; locale: " + locale + "; style: " +
+				style + "; variation: " + variation;
+		}
 	}
 }

Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/request/resource/ResourceReferenceRegistry.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/request/resource/ResourceReferenceRegistry.java?rev=990642&r1=990641&r2=990642&view=diff
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/request/resource/ResourceReferenceRegistry.java (original)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/request/resource/ResourceReferenceRegistry.java Sun Aug 29 20:17:44 2010
@@ -21,14 +21,14 @@ import java.util.Queue;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentLinkedQueue;
 
+import org.apache.wicket.request.resource.ResourceReference.Key;
 import org.apache.wicket.util.lang.Args;
 import org.apache.wicket.util.lang.Generics;
-import org.apache.wicket.util.lang.Objects;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * Allows to register and lookup {@link ResourceReference}s.
+ * Allows to register and lookup {@link ResourceReference}s per Application.
  * 
  * @see org.apache.wicket.Application#getResourceReferenceRegistry()
  * @see org.apache.wicket.Application#newResourceReferenceRegistry()
@@ -44,7 +44,6 @@ public class ResourceReferenceRegistry
 	// Scan classes and its superclasses for static ResourceReference fields. For each
 	// RR field found, the callback method is called and the RR gets registered. It's kind of
 	// auto-register all RRs in your Component hierarchy.
-	// TODO wouldn't annotations be similar but more obvious to what happens?
 	private ClassScanner scanner = new ClassScanner()
 	{
 		@Override
@@ -107,7 +106,7 @@ public class ResourceReferenceRegistry
 
 		if (reference.canBeRegistered())
 		{
-			Key key = new Key(reference);
+			Key key = reference.getKey();
 			if (map.containsKey(key) == false)
 			{
 				map.put(key, reference);
@@ -130,7 +129,7 @@ public class ResourceReferenceRegistry
 	{
 		Args.notNull(reference, "reference");
 
-		Key key = new Key(reference);
+		Key key = reference.getKey();
 
 		// remove from registry
 		ResourceReference removed = map.remove(key);
@@ -178,8 +177,37 @@ public class ResourceReferenceRegistry
 		final Locale locale, final String style, final String variation, final boolean strict,
 		final boolean createIfNotFound)
 	{
-		ResourceReference resource = _getResourceReference(scope, name, locale, style, variation,
-			strict);
+		return getResourceReference(new Key(scope.getName(), name, locale, style, variation),
+			strict, createIfNotFound);
+	}
+
+	/**
+	 * Get a resource reference matching the parameters from the registry or if not found and
+	 * requested, create an default resource reference and add it to the registry.
+	 * <p>
+	 * Part of the search is scanning the class (scope) and it's superclass for static
+	 * ResourceReference fields. Found fields get registered automatically (but are different from
+	 * auto-generated ResourceReferences).
+	 * 
+	 * @see #createDefaultResourceReference(Class, String, Locale, String, String)
+	 * @see ClassScanner
+	 * 
+	 * @param key
+	 *            The data making up the resource reference
+	 * @param strict
+	 *            If true, "weaker" combination of scope, name, locale etc. are not tested
+	 * @param createIfNotFound
+	 *            If true a default resource reference is created if no entry can be found in the
+	 *            registry. The newly created resource reference will be added to the registry.
+	 * @return Either the resource reference found in the registry or, if requested, a resource
+	 *         reference automatically created based on the parameters provided. The automatically
+	 *         created resource reference will automatically be added to the registry.
+	 */
+	public final ResourceReference getResourceReference(final Key key, final boolean strict,
+		final boolean createIfNotFound)
+	{
+		ResourceReference resource = _getResourceReference(key.getScope(), key.getName(),
+			key.getLocale(), key.getStyle(), key.getVariation(), strict);
 
 		// Nothing found so far?
 		if (resource == null)
@@ -187,16 +215,17 @@ public class ResourceReferenceRegistry
 			// Scan the class (scope) and it's super classes for static fields containing resource
 			// references. Such resources are registered as normal resource reference (not
 			// auto-added).
-			if (scanner.scanClass(scope) > 0)
+			if (scanner.scanClass(key.getScopeClass()) > 0)
 			{
 				// At least one new resource reference got registered => Search the registry again
-				resource = _getResourceReference(scope, name, locale, style, variation, strict);
+				resource = _getResourceReference(key.getScope(), key.getName(), key.getLocale(),
+					key.getStyle(), key.getVariation(), strict);
 			}
 
 			// Still nothing found => Shall a new reference be auto-created?
 			if ((resource == null) && createIfNotFound)
 			{
-				resource = addDefaultResourceReference(scope, name, locale, style, variation);
+				resource = addDefaultResourceReference(key);
 			}
 		}
 
@@ -220,11 +249,11 @@ public class ResourceReferenceRegistry
 	 *            If true, "weaker" combination of scope, name, locale etc. are not tested
 	 * @return Either the resource reference found in the registry or null if not found
 	 */
-	private final ResourceReference _getResourceReference(final Class<?> scope, final String name,
+	private final ResourceReference _getResourceReference(final String scope, final String name,
 		final Locale locale, final String style, final String variation, final boolean strict)
 	{
 		// Create a registry key containing all of the relevant attributes
-		Key key = new Key(scope.getName(), name, locale, style, variation);
+		Key key = new Key(scope, name, locale, style, variation);
 
 		// Get resource reference matching exactly the attrs provided
 		ResourceReference res = map.get(key);
@@ -264,19 +293,13 @@ public class ResourceReferenceRegistry
 	/**
 	 * Creates a default resource reference and registers it.
 	 * 
-	 * @param scope
-	 * @param name
-	 * @param locale
-	 * @param style
-	 * @param variation
+	 * @param key
 	 * @return The default resource created
 	 */
-	private ResourceReference addDefaultResourceReference(Class<?> scope, String name,
-		Locale locale, String style, String variation)
+	private ResourceReference addDefaultResourceReference(final Key key)
 	{
 		// Can be subclassed to create other than PackagedResourceReference
-		ResourceReference reference = createDefaultResourceReference(scope, name, locale, style,
-			variation);
+		ResourceReference reference = createDefaultResourceReference(key);
 
 		if (reference != null)
 		{
@@ -285,7 +308,7 @@ public class ResourceReferenceRegistry
 			enforceAutoAddedCacheSize(getAutoAddedCapacity());
 
 			// Register the new RR
-			Key key = _registerResourceReference(reference);
+			_registerResourceReference(reference);
 
 			// Add it to the auto-added list
 			if (autoAddedQueue != null)
@@ -296,13 +319,7 @@ public class ResourceReferenceRegistry
 		else
 		{
 			log.warn("Asked to auto-create a ResourceReference, but ResourceReferenceRegistry.createDefaultResourceReference() return null. " +
-				" [scope: " +
-				scope.getName() +
-				"; name: " +
-				name +
-				"; locale: " +
-				locale +
-				"; style: " + style + "; variation: " + variation + "]");
+				" [" + key.toString() + "]");
 		}
 		return reference;
 	}
@@ -335,19 +352,15 @@ public class ResourceReferenceRegistry
 	 * <p>
 	 * A {@link PackageResourceReference} will be created by default
 	 * 
-	 * @param scope
-	 * @param name
-	 * @param locale
-	 * @param style
-	 * @param variation
+	 * @param key
 	 * @return The RR created or null if not successful
 	 */
-	protected ResourceReference createDefaultResourceReference(final Class<?> scope,
-		final String name, final Locale locale, final String style, final String variation)
+	protected ResourceReference createDefaultResourceReference(final Key key)
 	{
-		if (PackageResource.exists(scope, name, locale, style, variation))
+		if (PackageResource.exists(key.getScopeClass(), key.getName(), key.getLocale(),
+			key.getStyle(), key.getVariation()))
 		{
-			return new PackageResourceReference(scope, name, locale, style, variation);
+			return new PackageResourceReference(key);
 		}
 		else
 		{
@@ -423,80 +436,4 @@ public class ResourceReferenceRegistry
 	{
 		return map.size();
 	}
-
-	/**
-	 * The registry essentially is a Map and needs a Key to store, search and retrieve entries.
-	 */
-	private static class Key
-	{
-		private final String scope;
-		private final String name;
-		private final Locale locale;
-		private final String style;
-		private final String variation;
-
-		/**
-		 * Construct.
-		 * 
-		 * @param reference
-		 */
-		public Key(final ResourceReference reference)
-		{
-			this(reference.getScope().getName(), reference.getName(), reference.getLocale(),
-				reference.getStyle(), reference.getVariation());
-		}
-
-		/**
-		 * Construct.
-		 * 
-		 * @param scope
-		 * @param name
-		 * @param locale
-		 * @param style
-		 * @param variation
-		 */
-		public Key(final String scope, final String name, final Locale locale, final String style,
-			final String variation)
-		{
-			Args.notNull(scope, "scope");
-			Args.notNull(name, "name");
-
-			this.scope = scope.intern();
-			this.name = name.intern();
-			this.locale = locale;
-			this.style = style != null ? style.intern() : null;
-			this.variation = variation != null ? variation.intern() : null;
-		}
-
-		/**
-		 * @see java.lang.Object#equals(java.lang.Object)
-		 */
-		@Override
-		public boolean equals(final Object obj)
-		{
-			if (this == obj)
-			{
-				return true;
-			}
-			if (obj instanceof Key == false)
-			{
-				return false;
-			}
-			Key that = (Key)obj;
-			return Objects.equal(scope, that.scope) && //
-				Objects.equal(name, that.name) && //
-				Objects.equal(locale, that.locale) && //
-				Objects.equal(style, that.style) && //
-				Objects.equal(variation, that.variation);
-		}
-
-		/**
-		 * @see java.lang.Object#hashCode()
-		 */
-		@Override
-		public int hashCode()
-		{
-			return Objects.hashCode(scope, name, locale, style, variation);
-		}
-	}
 }

Modified: wicket/trunk/wicket/src/test/java/org/apache/wicket/request/mapper/TestMapperContext.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/request/mapper/TestMapperContext.java?rev=990642&r1=990641&r2=990642&view=diff
==============================================================================
--- wicket/trunk/wicket/src/test/java/org/apache/wicket/request/mapper/TestMapperContext.java (original)
+++ wicket/trunk/wicket/src/test/java/org/apache/wicket/request/mapper/TestMapperContext.java Sun Aug 29 20:17:44 2010
@@ -16,8 +16,6 @@
  */
 package org.apache.wicket.request.mapper;
 
-import java.util.Locale;
-
 import org.apache.wicket.MockPage;
 import org.apache.wicket.RequestListenerInterface;
 import org.apache.wicket.WicketRuntimeException;
@@ -26,6 +24,7 @@ import org.apache.wicket.request.compone
 import org.apache.wicket.request.mapper.parameter.PageParameters;
 import org.apache.wicket.request.resource.ResourceReference;
 import org.apache.wicket.request.resource.ResourceReferenceRegistry;
+import org.apache.wicket.request.resource.ResourceReference.Key;
 
 /**
  * Simple {@link EncoderContext} implementation for testing purposes
@@ -70,8 +69,7 @@ public class TestMapperContext implement
 	private final ResourceReferenceRegistry registry = new ResourceReferenceRegistry()
 	{
 		@Override
-		protected ResourceReference createDefaultResourceReference(Class<?> scope, String name,
-			Locale locale, String style, String variation)
+		protected ResourceReference createDefaultResourceReference(Key key)
 		{
 			// Do not create package resource here because it requires "real" application
 			return null;