You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by iv...@apache.org on 2008/06/25 23:12:05 UTC

svn commit: r671662 - /wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/template/PackagedTextTemplate.java

Author: ivaynberg
Date: Wed Jun 25 14:12:05 2008
New Revision: 671662

URL: http://svn.apache.org/viewvc?rev=671662&view=rev
Log:
WICKET-1714

Modified:
    wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/template/PackagedTextTemplate.java

Modified: wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/template/PackagedTextTemplate.java
URL: http://svn.apache.org/viewvc/wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/template/PackagedTextTemplate.java?rev=671662&r1=671661&r2=671662&view=diff
==============================================================================
--- wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/template/PackagedTextTemplate.java (original)
+++ wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/template/PackagedTextTemplate.java Wed Jun 25 14:12:05 2008
@@ -27,7 +27,6 @@
 import org.apache.wicket.util.lang.Packages;
 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.resource.locator.ResourceStreamLocator;
 import org.apache.wicket.util.string.JavascriptStripper;
 import org.apache.wicket.util.string.interpolator.MapVariableInterpolator;
@@ -88,11 +87,8 @@
 
 	private static final long serialVersionUID = 1L;
 
-	/** class loader stream locator. */
-	private static final IResourceStreamLocator streamLocator = new ResourceStreamLocator();
-
 	private static final MetaDataKey TEXT_TEMPLATE_CACHE_KEY = new MetaDataKey(
-			TextTemplateCache.class)
+		TextTemplateCache.class)
 	{
 		private static final long serialVersionUID = 1L;
 	};
@@ -123,7 +119,8 @@
 	 * @param fileName
 	 *            the name of the file, relative to the <code>clazz</code> position
 	 * @param contentType
-	 *            the mime type of this resource, such as "<code>image/jpeg</code>" or "<code>text/html</code>"
+	 *            the mime type of this resource, such as "<code>image/jpeg</code>" or "
+	 *            <code>text/html</code>"
 	 */
 	public PackagedTextTemplate(final Class clazz, final String fileName, final String contentType)
 	{
@@ -139,12 +136,13 @@
 	 * @param fileName
 	 *            the name of the file, relative to the <code>clazz</code> position
 	 * @param contentType
-	 *            the mime type of this resource, such as "<code>image/jpeg</code>" or "<code>text/html</code>"
+	 *            the mime type of this resource, such as "<code>image/jpeg</code>" or "
+	 *            <code>text/html</code>"
 	 * @param encoding
 	 *            the file's encoding, for example, "<code>UTF-8</code>"
 	 */
 	public PackagedTextTemplate(final Class clazz, final String fileName, final String contentType,
-			final String encoding)
+		final String encoding)
 	{
 		super(contentType);
 
@@ -154,12 +152,17 @@
 		TextTemplateCache cache = (TextTemplateCache)app.getMetaData(TEXT_TEMPLATE_CACHE_KEY);
 		// TODO implement cache
 
-		IResourceStream stream = streamLocator.locate(clazz, path);
+		// first try default class loading locator to find the resource
+		IResourceStream stream = new ResourceStreamLocator().locate(clazz, path);
+
+		// if default locator couldnt find the resource allow the application specific one to try
+		stream = Application.get().getResourceSettings().getResourceStreamLocator().locate(clazz,
+			path);
 
 		if (stream == null)
 		{
 			throw new IllegalArgumentException("resource " + fileName + " not found for scope " +
-					clazz + " (path = " + path + ")");
+				clazz + " (path = " + path + ")");
 		}
 
 		try
@@ -213,8 +216,8 @@
 	/**
 	 * Interpolates a <code>Map</code> of variables with the content and replaces the content with
 	 * the result. Variables are denoted in the <code>String</code> by the
-	 * <code>syntax ${variableName}</code>. The contents will be altered by replacing each
-	 * variable of the form <code>${variableName}</code> with the value returned by
+	 * <code>syntax ${variableName}</code>. The contents will be altered by replacing each variable
+	 * of the form <code>${variableName}</code> with the value returned by
 	 * <code>variables.getValue("variableName")</code>.
 	 * <p>
 	 * WARNING: there is no going back to the original contents after the interpolation is done. If