Revision: 1086
          http://stripes.svn.sourceforge.net/stripes/?rev=1086&view=rev
Author:   bengunter
Date:     2009-03-03 01:27:50 +0000 (Tue, 03 Mar 2009)

Log Message:
-----------
Rolled back the following commit because we no longer think it is appropriate
for release 1.5.1. Look for this change in release 1.6.
========================================================================
r1075 | bengunter | 2009-02-28 16:52:24 -0600 (Sat, 28 Feb 2009) | 2 lines

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-03-02 14:00:41 UTC (rev 1085)
+++ 
branches/1.5.x/stripes/src/net/sourceforge/stripes/controller/AnnotatedClassActionResolver.java
     2009-03-03 01:27:50 UTC (rev 1086)
@@ -84,9 +84,6 @@
     /** 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.
@@ -120,11 +117,6 @@
         }
     }
 
-    /** 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
@@ -142,9 +134,9 @@
             return;
 
         // make sure mapping exists in cache
-        UrlBinding proto = getUrlBindingFactory().getBindingPrototype(clazz);
+        UrlBinding proto = 
UrlBindingFactory.getInstance().getBindingPrototype(clazz);
         if (proto == null) {
-            getUrlBindingFactory().addBinding(clazz, new UrlBinding(clazz, 
binding));
+            UrlBindingFactory.getInstance().addBinding(clazz, new 
UrlBinding(clazz, binding));
         }
 
         // Only process the class if it's properly annotated
@@ -177,7 +169,7 @@
     protected void removeActionBean(Class<? extends ActionBean> clazz) {
         String binding = getUrlBinding(clazz);
         if (binding != null) {
-            getUrlBindingFactory().removeBinding(clazz);
+            UrlBindingFactory.getInstance().removeBinding(clazz);
         }
         eventMappings.remove(clazz);
     }
@@ -193,7 +185,7 @@
      *         supplied cannot be mapped to an ActionBean.
      */
     public String getUrlBindingFromPath(String path) {
-        UrlBinding mapping = getUrlBindingFactory().getBindingPrototype(path);
+        UrlBinding mapping = 
UrlBindingFactory.getInstance().getBindingPrototype(path);
         return mapping == null ? null : mapping.toString();
     }
 
@@ -207,7 +199,7 @@
      * @return the UrlBinding or null if none can be determined
      */
     public String getUrlBinding(Class<? extends ActionBean> clazz) {
-        UrlBinding mapping = getUrlBindingFactory().getBindingPrototype(clazz);
+        UrlBinding mapping = 
UrlBindingFactory.getInstance().getBindingPrototype(clazz);
         return mapping == null ? null : mapping.toString();
     }
 
@@ -283,7 +275,7 @@
      *         is made using the path specified or null if no ActionBean 
matches.
      */
     public Class<? extends ActionBean> getActionBeanType(String path) {
-        UrlBinding binding = getUrlBindingFactory().getBindingPrototype(path);
+        UrlBinding binding = 
UrlBindingFactory.getInstance().getBindingPrototype(path);
         return binding == null ? null : binding.getBeanType();
     }
 
@@ -346,7 +338,8 @@
         ActionBean bean;
 
         if (beanClass == null) {
-            throw new ActionBeanNotFoundException(path, 
getUrlBindingFactory().getPathMap());
+            throw new ActionBeanNotFoundException(
+                    path, UrlBindingFactory.getInstance().getPathMap());
         }
 
         String bindingPath = getUrlBinding(beanClass);
@@ -544,7 +537,7 @@
                                           ActionBeanContext context) {
         Map<String,Method> mappings = this.eventMappings.get(bean);
         String path = HttpUtil.getRequestedPath(context.getRequest());
-        UrlBinding prototype = 
getUrlBindingFactory().getBindingPrototype(path);
+        UrlBinding prototype = 
UrlBindingFactory.getInstance().getBindingPrototype(path);
         String binding = prototype == null ? null : prototype.getPath();
 
         if (binding != null && path.length() != binding.length()) {
@@ -687,6 +680,6 @@
      * {...@link ActionResolver}.
      */
     public Collection<Class<? extends ActionBean>> getActionBeanClasses() {
-        return getUrlBindingFactory().getActionBeanClasses();
+        return UrlBindingFactory.getInstance().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-03-02 14:00:41 UTC (rev 1085)
+++ 
branches/1.5.x/stripes/src/net/sourceforge/stripes/controller/StripesRequestWrapper.java
    2009-03-03 01:27:50 UTC (rev 1086)
@@ -467,14 +467,9 @@
      * {...@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 = ((AnnotatedClassActionResolver) 
resolver).getUrlBindingFactory()
-                    .getBinding(request);
+            binding = UrlBindingFactory.getInstance().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-03-02 14:00:41 UTC (rev 1085)
+++ 
branches/1.5.x/stripes/src/net/sourceforge/stripes/controller/UrlBindingFactory.java
        2009-03-03 01:27:50 UTC (rev 1086)
@@ -61,6 +61,18 @@
 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>();
 
@@ -79,6 +91,11 @@
                 }
             });
 
+    /** 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-03-02 14:00:41 UTC (rev 1085)
+++ branches/1.5.x/stripes/src/net/sourceforge/stripes/util/UrlBuilder.java     
2009-03-03 01:27:50 UTC (rev 1086)
@@ -25,10 +25,9 @@
 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;
@@ -451,14 +450,9 @@
      * @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 = ((AnnotatedClassActionResolver) 
resolver).getUrlBindingFactory()
-                    .getBindingPrototype(baseUrl);
+            binding = 
UrlBindingFactory.getInstance().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