Title: [waffle-scm] [413] trunk/waffle-core/src/main/java/org/codehaus/waffle/action: WAFFLE-35: Added AbstractOgnlMethodDefinitionFinder as intermediate abstract class between AbstractMethodDefinitionFinder and its concrete implementation

Diff

Modified: trunk/waffle-core/src/main/java/org/codehaus/waffle/action/AbstractMethodDefinitionFinder.java (412 => 413)

--- trunk/waffle-core/src/main/java/org/codehaus/waffle/action/AbstractMethodDefinitionFinder.java	2007-11-23 08:35:14 UTC (rev 412)
+++ trunk/waffle-core/src/main/java/org/codehaus/waffle/action/AbstractMethodDefinitionFinder.java	2007-11-23 08:40:24 UTC (rev 413)
@@ -142,23 +142,6 @@
         return methodDefinition;
     }
 
-    /**
-     * Returns the methods matching the type and name
-     * 
-     * @param type the Class in which to look for the method
-     * @param methodName the method name
-     * @return A List of methods
-     * @throws NoMatchingActionMethodException if no methods match
-     */
-    @SuppressWarnings({"unchecked"})
-    private List<Method> findMethods(Class type, String methodName) {
-        List<Method> methods = OgnlRuntime.getMethods(type, methodName, false);
-        if (methods == null) {
-            throw new NoMatchingActionMethodException(methodName, type);
-        }
-        return methods;
-    }
-
     private List<MethodDefinition> findMethodDefinitions(HttpServletRequest request, HttpServletResponse response, List<Method> methods) {
         List<MethodDefinition> methodDefinitions = new ArrayList<MethodDefinition>();
     
@@ -298,18 +281,9 @@
         return isDefaultActionMethod(value) || value.length() == 0;
     }
     
-    // Protected methods, accessible by concrete subclasses
+    // Protected methods, accessible by  subclasses
 
     /**
-     * Returns the method arguments contained in the request
-     * 
-     * @param method the Method
-     * @param request the HttpServetRequest
-     * @return the list of arguments
-     */
-    protected abstract List<Object> getArguments(Method method, HttpServletRequest request);
-
-    /**
      * Wraps value in curly brackets to fit with default handling
      * 
      * @param value the argument value
@@ -338,4 +312,27 @@
         return resolvedArguments;
     }
 
+    // Abstract methods - implementable by subclasses 
+    
+    /**
+     * Returns the method arguments contained in the request
+     * 
+     * @param method the Method
+     * @param request the HttpServetRequest
+     * @return the list of arguments
+     */
+    protected abstract List<Object> getArguments(Method method, HttpServletRequest request);
+
+    /**
+     * Returns the methods matching the type and name
+     * 
+     * @param type the Class in which to look for the method
+     * @param methodName the method name
+     * @return A List of methods
+     * @throws NoMatchingActionMethodException if no methods match
+     */
+    protected abstract List<Method> findMethods(Class<?> type, String methodName);
+
+
+
 }

Added: trunk/waffle-core/src/main/java/org/codehaus/waffle/action/AbstractOgnlMethodDefinitionFinder.java (0 => 413)

--- trunk/waffle-core/src/main/java/org/codehaus/waffle/action/AbstractOgnlMethodDefinitionFinder.java	                        (rev 0)
+++ trunk/waffle-core/src/main/java/org/codehaus/waffle/action/AbstractOgnlMethodDefinitionFinder.java	2007-11-23 08:40:24 UTC (rev 413)
@@ -0,0 +1,47 @@
+/*****************************************************************************
+ * Copyright (C) 2005,2006 Michael Ward                                      *
+ * All rights reserved.                                                      *
+ * ------------------------------------------------------------------------- *
+ * The software in this package is published under the terms of the BSD      *
+ * style license a copy of which has been included with this distribution in *
+ * the LICENSE.txt file.                                                     *
+ *                                                                           *
+ * Original code by: Michael Ward                                            *
+ *****************************************************************************/
+package org.codehaus.waffle.action;
+
+import static ognl.OgnlRuntime.getMethods;
+
+import java.lang.reflect.Method;
+import java.util.List;
+
+import javax.servlet.ServletContext;
+
+import org.codehaus.waffle.bind.ValueConverterFinder;
+import org.codehaus.waffle.monitor.ActionMonitor;
+
+/**
+ * Abstract method definition finder that uses Ognl to find methods
+ * 
+ * @author Mauro Talevi
+ */
+public abstract class AbstractOgnlMethodDefinitionFinder extends AbstractMethodDefinitionFinder {
+
+    public AbstractOgnlMethodDefinitionFinder(ServletContext servletContext,
+                                           ArgumentResolver argumentResolver,
+                                           MethodNameResolver methodNameResolver,
+                                           ValueConverterFinder valueConverterFinder, 
+                                           ActionMonitor actionMonitor) {
+        super(servletContext, argumentResolver, methodNameResolver, valueConverterFinder, actionMonitor);
+    }
+
+    @SuppressWarnings({"unchecked"})
+    protected List<Method> findMethods(Class<?> type, String methodName) {
+        List<Method> methods = getMethods(type, methodName, false);
+        if (methods == null) {
+            throw new NoMatchingActionMethodException(methodName, type);
+        }
+        return methods;
+    }
+    
+}

Modified: trunk/waffle-core/src/main/java/org/codehaus/waffle/action/AnnotatedMethodDefinitionFinder.java (412 => 413)

--- trunk/waffle-core/src/main/java/org/codehaus/waffle/action/AnnotatedMethodDefinitionFinder.java	2007-11-23 08:35:14 UTC (rev 412)
+++ trunk/waffle-core/src/main/java/org/codehaus/waffle/action/AnnotatedMethodDefinitionFinder.java	2007-11-23 08:40:24 UTC (rev 413)
@@ -23,15 +23,14 @@
 import org.codehaus.waffle.monitor.ActionMonitor;
 
 /**
- * Annotation-based method definition finder. 
+ * Annotation-based method definition finder.
+ * This is the default default definition finder used by Waffle.
  * <p/>
- * This is the default MethodDefinitionFinder used by Waffle.
- * <p/>
  * <b>Note</b>: Pragmatic method calls will always take precedence.
  * 
  * @author Michael Ward
  */
-public class AnnotatedMethodDefinitionFinder extends AbstractMethodDefinitionFinder {
+public class AnnotatedMethodDefinitionFinder extends AbstractOgnlMethodDefinitionFinder {
 
     public AnnotatedMethodDefinitionFinder(ServletContext servletContext,
                                            ArgumentResolver argumentResolver,

Modified: trunk/waffle-core/src/main/java/org/codehaus/waffle/action/ParanamerMethodDefinitionFinder.java (412 => 413)

--- trunk/waffle-core/src/main/java/org/codehaus/waffle/action/ParanamerMethodDefinitionFinder.java	2007-11-23 08:35:14 UTC (rev 412)
+++ trunk/waffle-core/src/main/java/org/codehaus/waffle/action/ParanamerMethodDefinitionFinder.java	2007-11-23 08:40:24 UTC (rev 413)
@@ -27,15 +27,15 @@
 import com.thoughtworks.paranamer.Paranamer;
 
 /**
- * Pananamer-based method definition finder.
+ * Pananamer-based method definition finder, which can be used in alternative to
+ * other definition finders, eg [EMAIL PROTECTED] AnnotatedMethodDefinitionFinder}.
  * <p/>
- * This MethodDefinitionFinder is not the default used by Waffle. 
- * <p/>
  * <b>Note</b>: Pragmatic method calls will always take precedence.
  * 
  * @author Paul Hammant 
+ * @see AnnotatedMethodDefinitionFinder
  */
-public class ParanamerMethodDefinitionFinder extends AbstractMethodDefinitionFinder {
+public class ParanamerMethodDefinitionFinder extends AbstractOgnlMethodDefinitionFinder {
     private final CachingParanamer paranamer = new CachingParanamer();
    
     public ParanamerMethodDefinitionFinder(ServletContext servletContext,


To unsubscribe from this list please visit:

http://xircles.codehaus.org/manage_email

Reply via email to