Revision: 1076
http://stripes.svn.sourceforge.net/stripes/?rev=1076&view=rev
Author: bengunter
Date: 2009-03-01 02:25:44 +0000 (Sun, 01 Mar 2009)
Log Message:
-----------
Bug fix for STS-617. A static URL binding -- one that does not declare any
embedded parameters -- should supersede dynamic bindings that conflict with it.
For example, given bindings /foo, /foo/{a} and /foo/{a}/{b}, the conflicts
between the three at /foo and /foo/ should resolve in favor of the static
binding /foo since that is clearly the intention when using a static binding.
Modified Paths:
--------------
trunk/stripes/src/net/sourceforge/stripes/controller/UrlBindingFactory.java
Modified:
trunk/stripes/src/net/sourceforge/stripes/controller/UrlBindingFactory.java
===================================================================
--- trunk/stripes/src/net/sourceforge/stripes/controller/UrlBindingFactory.java
2009-02-28 22:52:24 UTC (rev 1075)
+++ trunk/stripes/src/net/sourceforge/stripes/controller/UrlBindingFactory.java
2009-03-01 02:25:44 UTC (rev 1076)
@@ -458,16 +458,40 @@
*/
protected void cachePath(String path, UrlBinding binding) {
if (pathCache.containsKey(path)) {
+ // Put a null value in the map to indicate a conflict
UrlBinding conflict = pathCache.put(path, null);
+
+ // Construct a list of conflicting bindings
List<String> list = pathConflicts.get(path);
if (list == null) {
list = new ArrayList<String>();
list.add(conflict.toString());
pathConflicts.put(path, list);
}
- log.warn("The path ", path, " for ",
binding.getBeanType().getName(), " @ ", binding,
- " conflicts with ", list);
list.add(binding.toString());
+
+ // If either the existing binding or the new binding (but not
both) declares no
+ // parameters, then it is a static binding and should take
precedence over dynamic ones.
+ UrlBinding statik = null;
+ if (conflict != null) {
+ if (conflict.getParameters().isEmpty() &&
!binding.getParameters().isEmpty()) {
+ statik = conflict;
+ }
+ else if (!conflict.getParameters().isEmpty() &&
binding.getParameters().isEmpty()) {
+ statik = binding;
+ }
+ }
+
+ // Replace the path cache entry if necessary and log a warning
+ if (statik == null) {
+ log.warn("The path ", path, " for ",
binding.getBeanType().getName(), " @ ",
+ binding, " conflicts with ", list);
+ }
+ else {
+ log.debug("For path ", path, ", static binding ", statik,
+ " supersedes conflicting bindings ", list);
+ pathCache.put(path, statik);
+ }
}
else {
log.debug("Wiring path ", path, " to ",
binding.getBeanType().getName(), " @ ", binding);
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Stripes-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-development