Revision: 1012
          http://stripes.svn.sourceforge.net/stripes/?rev=1012&view=rev
Author:   bengunter
Date:     2008-11-25 21:01:05 +0000 (Tue, 25 Nov 2008)

Log Message:
-----------
STS-617: In addBinding(Class,UrlBinding) if there is are existing bindings for 
a class with the same name as the one being added, then remove the old one 
first to prevent interference with the new class. I know this is not 
technically correct, but it is valuable and highly unlikely to be a problem in 
practice.

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 
2008-11-25 20:06:56 UTC (rev 1011)
+++ trunk/stripes/src/net/sourceforge/stripes/controller/UrlBindingFactory.java 
2008-11-25 21:01:05 UTC (rev 1012)
@@ -340,6 +340,24 @@
      * @param binding the URL binding
      */
     public void addBinding(Class<? extends ActionBean> beanType, UrlBinding 
binding) {
+        /*
+         * Search for a class that has already been added with the same name 
as the class being
+         * added now. If one is found then remove its information first and 
then proceed with adding
+         * it. I know this is not technically correct because two classes from 
two different class
+         * loaders can have the same name, but this feature is valuable for 
extensions that reload
+         * classes and I consider it highly unlikely to be a problem in 
practice.
+         */
+        Class<? extends ActionBean> existing = null;
+        for (Class<? extends ActionBean> c : classCache.keySet()) {
+            if (c.getName().equals(beanType.getName())) {
+                existing = c;
+                break;
+            }
+        }
+        if (existing != null)
+            removeBinding(existing);
+
+        // And now we can safely add the class
         for (String path : getCachedPaths(binding)) {
             cachePath(path, binding);
         }


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Stripes-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-development

Reply via email to