Revision: 1075
          http://stripes.svn.sourceforge.net/stripes/?rev=1075&view=rev
Author:   bengunter
Date:     2009-02-28 22:52:24 +0000 (Sat, 28 Feb 2009)

Log Message:
-----------
Applied fix for STS-653 from trunk.

Modified Paths:
--------------
    
branches/1.5.x/stripes/src/net/sourceforge/stripes/controller/AnnotatedClassActionResolver.java
    
branches/1.5.x/stripes/src/net/sourceforge/stripes/controller/StripesRequestWrapper.java
    
branches/1.5.x/stripes/src/net/sourceforge/stripes/controller/UrlBindingFactory.java
    branches/1.5.x/stripes/src/net/sourceforge/stripes/util/UrlBuilder.java

Modified: 
branches/1.5.x/stripes/src/net/sourceforge/stripes/controller/AnnotatedClassActionResolver.java
===================================================================
--- 
branches/1.5.x/stripes/src/net/sourceforge/stripes/controller/AnnotatedClassActionResolver.java
     2009-02-28 22:45:56 UTC (rev 1074)
+++ 
branches/1.5.x/stripes/src/net/sourceforge/stripes/controller/AnnotatedClassActionResolver.java
     2009-02-28 22:52:24 UTC (rev 1075)
@@ -83,6 +83,9 @@
     /** Handle to the configuration. */
     private Configuration configuration;
 
+    /** Parses {...@link UrlBinding} values and maps request URLs to {...@link 
ActionBean}s. */
+    private UrlBindingFactory urlBindingFactory = new UrlBindingFactory();
+
     /**
      * Map used to resolve the methods handling events within form beans. Maps 
the class
      * representing a subclass of ActionBean to a Map of event names to Method 
objects.
@@ -116,6 +119,11 @@
         }
     }
 
+    /** Get the {...@link UrlBindingFactory} that is being used by this action 
resolver. */
+    public UrlBindingFactory getUrlBindingFactory() {
+        return urlBindingFactory;
+    }
+
     /**
      * Adds an ActionBean class to the set that this resolver can resolve. 
Identifies
      * the URL binding and the events managed by the class and stores them in 
Maps
@@ -133,9 +141,9 @@
             return;
 
         // make sure mapping exists in cache
-        UrlBinding proto = 
UrlBindingFactory.getInstance().getBindingPrototype(clazz);
+        UrlBinding proto = getUrlBindingFactory().getBindingPrototype(clazz);
         if (proto == null) {
-            UrlBindingFactory.getInstance().addBinding(clazz, new 
UrlBinding(clazz, binding));
+            getUrlBindingFactory().addBinding(clazz, new UrlBinding(clazz, 
binding));
         }
 
         // Only process the class if it's properly annotated
@@ -168,7 +176,7 @@
     protected void removeActionBean(Class<? extends ActionBean> clazz) {
         String binding = getUrlBinding(clazz);
         if (binding != null) {
-            UrlBindingFactory.getInstance().removeBinding(clazz);
+            getUrlBindingFactory().removeBinding(clazz);
         }
         eventMappings.remove(clazz);
     }
@@ -184,7 +192,7 @@
      *         supplied cannot be mapped to an ActionBean.
      */
     public String getUrlBindingFromPath(String path) {
-        UrlBinding mapping = 
UrlBindingFactory.getInstance().getBindingPrototype(path);
+        UrlBinding mapping = getUrlBindingFactory().getBindingPrototype(path);
         return mapping == null ? null : mapping.toString();
     }
 
@@ -198,7 +206,7 @@
      * @return the UrlBinding or null if none can be determined
      */
     public String getUrlBinding(Class<? extends ActionBean> clazz) {
-        UrlBinding mapping = 
UrlBindingFactory.getInstance().getBindingPrototype(clazz);
+        UrlBinding mapping = getUrlBindingFactory().getBindingPrototype(clazz);
         return mapping == null ? null : mapping.toString();
     }
 
@@ -274,7 +282,7 @@
      *         is made using the path specified or null if no ActionBean 
matches.
      */
     public Class<? extends ActionBean> getActionBeanType(String path) {
-        UrlBinding binding = 
UrlBindingFactory.getInstance().getBindingPrototype(path);
+        UrlBinding binding = getUrlBindingFactory().getBindingPrototype(path);
         return binding == null ? null : binding.getBeanType();
     }
 
@@ -337,8 +345,7 @@
         ActionBean bean;
 
         if (beanClass == null) {
-            throw new ActionBeanNotFoundException(
-                    path, UrlBindingFactory.getInstance().getPathMap());
+            throw new ActionBeanNotFoundException(path, 
getUrlBindingFactory().getPathMap());
         }
 
         String bindingPath = getUrlBinding(beanClass);
@@ -536,7 +543,7 @@
                                           ActionBeanContext context) {
         Map<String,Method> mappings = this.eventMappings.get(bean);
         String path = HttpUtil.getRequestedPath(context.getRequest());
-        UrlBinding prototype = 
UrlBindingFactory.getInstance().getBindingPrototype(path);
+        UrlBinding prototype = 
getUrlBindingFactory().getBindingPrototype(path);
         String binding = prototype == null ? null : prototype.getPath();
 
         if (binding != null && path.length() != binding.length()) {
@@ -679,6 +686,6 @@
      * {...@link ActionResolver}.
      */
     public Collection<Class<? extends ActionBean>> getActionBeanClasses() {
-        return UrlBindingFactory.getInstance().getActionBeanClasses();
+        return getUrlBindingFactory().getActionBeanClasses();
     }
 }

Modified: 
branches/1.5.x/stripes/src/net/sourceforge/stripes/controller/StripesRequestWrapper.java
===================================================================
--- 
branches/1.5.x/stripes/src/net/sourceforge/stripes/controller/StripesRequestWrapper.java
    2009-02-28 22:45:56 UTC (rev 1074)
+++ 
branches/1.5.x/stripes/src/net/sourceforge/stripes/controller/StripesRequestWrapper.java
    2009-02-28 22:52:24 UTC (rev 1075)
@@ -467,9 +467,14 @@
      * {...@link Map}. If no parameters are present in the URI, then return 
null.
      */
     Map<String, String[]> getUriParameters(HttpServletRequest request) {
+        ActionResolver resolver = 
StripesFilter.getConfiguration().getActionResolver();
+        if (!(resolver instanceof AnnotatedClassActionResolver))
+            return null;
+
         UrlBinding binding = null;
         try {
-            binding = UrlBindingFactory.getInstance().getBinding(request);
+            binding = ((AnnotatedClassActionResolver) 
resolver).getUrlBindingFactory()
+                    .getBinding(request);
         }
         catch (UrlBindingConflictException e) {
             // This can be safely ignored

Modified: 
branches/1.5.x/stripes/src/net/sourceforge/stripes/controller/UrlBindingFactory.java
===================================================================
--- 
branches/1.5.x/stripes/src/net/sourceforge/stripes/controller/UrlBindingFactory.java
        2009-02-28 22:45:56 UTC (rev 1074)
+++ 
branches/1.5.x/stripes/src/net/sourceforge/stripes/controller/UrlBindingFactory.java
        2009-02-28 22:52:24 UTC (rev 1075)
@@ -61,18 +61,6 @@
 public class UrlBindingFactory {
     private static final Log log = Log.getInstance(UrlBindingFactory.class);
 
-    /** Singleton instance */
-    private static final UrlBindingFactory instance = new UrlBindingFactory();
-
-    /**
-     * Get the singleton instance.
-     * 
-     * @return an instance of this class
-     */
-    public static UrlBindingFactory getInstance() {
-        return instance;
-    }
-
     /** Maps {...@link ActionBean} classes to {...@link UrlBinding}s */
     private final Map<Class<? extends ActionBean>, UrlBinding> classCache = 
new HashMap<Class<? extends ActionBean>, UrlBinding>();
 
@@ -91,11 +79,6 @@
                 }
             });
 
-    /** Don't want the constructor to be public */
-    protected UrlBindingFactory() {
-        // do nothing
-    }
-
     /**
      * Get all the classes implementing {...@link ActionBean}
      */

Modified: 
branches/1.5.x/stripes/src/net/sourceforge/stripes/util/UrlBuilder.java
===================================================================
--- branches/1.5.x/stripes/src/net/sourceforge/stripes/util/UrlBuilder.java     
2009-02-28 22:45:56 UTC (rev 1074)
+++ branches/1.5.x/stripes/src/net/sourceforge/stripes/util/UrlBuilder.java     
2009-02-28 22:52:24 UTC (rev 1075)
@@ -25,9 +25,10 @@
 import net.sourceforge.stripes.action.ActionBean;
 import net.sourceforge.stripes.action.DefaultHandler;
 import net.sourceforge.stripes.config.Configuration;
+import net.sourceforge.stripes.controller.ActionResolver;
+import net.sourceforge.stripes.controller.AnnotatedClassActionResolver;
 import net.sourceforge.stripes.controller.StripesFilter;
 import net.sourceforge.stripes.controller.UrlBinding;
-import net.sourceforge.stripes.controller.UrlBindingFactory;
 import net.sourceforge.stripes.controller.UrlBindingParameter;
 import net.sourceforge.stripes.exception.StripesRuntimeException;
 import net.sourceforge.stripes.exception.UrlBindingConflictException;
@@ -450,9 +451,14 @@
      * @see #UrlBuilder(Locale, String, boolean)
      */
     protected String getBaseURL(String baseUrl, Collection<Parameter> 
parameters) {
+        ActionResolver resolver = 
StripesFilter.getConfiguration().getActionResolver();
+        if (!(resolver instanceof AnnotatedClassActionResolver))
+            return baseUrl;
+
         UrlBinding binding = null;
         try {
-            binding = 
UrlBindingFactory.getInstance().getBindingPrototype(baseUrl);
+            binding = ((AnnotatedClassActionResolver) 
resolver).getUrlBindingFactory()
+                    .getBindingPrototype(baseUrl);
         }
         catch (UrlBindingConflictException e) {
             // This can be safely ignored


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

Reply via email to