Author: jkuhnert
Date: Thu May 3 13:17:49 2007
New Revision: 534982
URL: http://svn.apache.org/viewvc?view=rev&rev=534982
Log:
Additional work for TAPESTRY-1437. Didn't do anything as drastic as catching
and ignoring exceptions but did add some logic to try and prevent them from
happing at all as well as moving the order of specless template resolution to
use context path checks first and then classpath.
Modified:
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/asset/ContextAssetFactory.java
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/TemplateSourceImpl.java
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/asset/ContextAssetFactoryTest.java
Modified:
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/asset/ContextAssetFactory.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/asset/ContextAssetFactory.java?view=diff&rev=534982&r1=534981&r2=534982
==============================================================================
---
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/asset/ContextAssetFactory.java
(original)
+++
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/asset/ContextAssetFactory.java
Thu May 3 13:17:49 2007
@@ -73,8 +73,14 @@
}
if (localized == null || localized.getResourceURL() == null) {
+
// try relative to context root
+ // paths must begin with "/" for context resolution
+
+ if (path != null && !path.startsWith("/"))
+ path = "/" + path;
+
Resource base = new WebContextResource(_webContext, path);
localized = _localizer.findLocalization(base, locale);
}
Modified:
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/TemplateSourceImpl.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/TemplateSourceImpl.java?view=diff&rev=534982&r1=534981&r2=534982
==============================================================================
---
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/TemplateSourceImpl.java
(original)
+++
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/TemplateSourceImpl.java
Thu May 3 13:17:49 2007
@@ -295,15 +295,10 @@
int index = className.lastIndexOf(packages[i]);
if (index < 0)
continue;
-
- String templateName = name + "." + templateExtension;
-
- if
(_classpathAssetFactory.assetExists(component.getSpecification(), base,
templateName, locale))
- return _classpathAssetFactory.createAsset(base,
component.getSpecification(), templateName, locale, component.getLocation());
- // else try various forms of context searches
+ // First try context
- templateName = className.substring((index + packages[i].length())
+ 1, className.length()).replaceAll("\\.", "/");
+ String templateName = className.substring((index +
packages[i].length()) + 1, className.length()).replaceAll("\\.", "/");
templateName = templateName + "." + templateExtension;
if (_contextAssetFactory.assetExists(component.getSpecification(),
_webInfAppLocation, templateName, locale)) {
@@ -313,6 +308,13 @@
return _contextAssetFactory.createAsset(_webInfLocation,
component.getSpecification(), templateName, locale, component.getLocation());
}
+
+ // else classpath
+
+ templateName = name + "." + templateExtension;
+
+ if
(_classpathAssetFactory.assetExists(component.getSpecification(), base,
templateName, locale))
+ return _classpathAssetFactory.createAsset(base,
component.getSpecification(), templateName, locale, component.getLocation());
}
return null;
Modified:
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/asset/ContextAssetFactoryTest.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/asset/ContextAssetFactoryTest.java?view=diff&rev=534982&r1=534981&r2=534982
==============================================================================
---
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/asset/ContextAssetFactoryTest.java
(original)
+++
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/asset/ContextAssetFactoryTest.java
Thu May 3 13:17:49 2007
@@ -115,8 +115,8 @@
expect(spec.getLocation()).andReturn(l);
expect(l.getResource()).andReturn(null);
- expect(context.getResource("asset_fr.png")).andReturn(null);
- expect(context.getResource("asset.png")).andReturn(null);
+ expect(context.getResource("/asset_fr.png")).andReturn(null);
+ expect(context.getResource("/asset.png")).andReturn(null);
replay();