Author: hlship
Date: Thu Jul 21 21:53:26 2011
New Revision: 1149383

URL: http://svn.apache.org/viewvc?rev=1149383&view=rev
Log:
TAP5-1508: Add PlasticMethod.getMethodIdentifier()

Modified:
    
tapestry/tapestry5/trunk/plastic/src/main/java/org/apache/tapestry5/internal/plastic/PlasticClassImpl.java
    
tapestry/tapestry5/trunk/plastic/src/main/java/org/apache/tapestry5/plastic/PlasticMethod.java
    
tapestry/tapestry5/trunk/plastic/src/test/groovy/org/apache/tapestry5/plastic/MethodAdviceTests.groovy
    
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/BaseEventHandlerMethodInvoker.java
    
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/RenderPhaseMethodWorker.java

Modified: 
tapestry/tapestry5/trunk/plastic/src/main/java/org/apache/tapestry5/internal/plastic/PlasticClassImpl.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/plastic/src/main/java/org/apache/tapestry5/internal/plastic/PlasticClassImpl.java?rev=1149383&r1=1149382&r2=1149383&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/plastic/src/main/java/org/apache/tapestry5/internal/plastic/PlasticClassImpl.java
 (original)
+++ 
tapestry/tapestry5/trunk/plastic/src/main/java/org/apache/tapestry5/internal/plastic/PlasticClassImpl.java
 Thu Jul 21 21:53:26 2011
@@ -183,6 +183,13 @@ public class PlasticClassImpl extends Lo
             return parentMethodBundle.isImplemented(node.name, node.desc);
         }
 
+        public String getMethodIdentifier()
+        {
+            return String.format("%s.%s",
+                    className,
+                    description.toShortString());
+        }
+
         public MethodHandle getHandle()
         {
             check();

Modified: 
tapestry/tapestry5/trunk/plastic/src/main/java/org/apache/tapestry5/plastic/PlasticMethod.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/plastic/src/main/java/org/apache/tapestry5/plastic/PlasticMethod.java?rev=1149383&r1=1149382&r2=1149383&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/plastic/src/main/java/org/apache/tapestry5/plastic/PlasticMethod.java
 (original)
+++ 
tapestry/tapestry5/trunk/plastic/src/main/java/org/apache/tapestry5/plastic/PlasticMethod.java
 Thu Jul 21 21:53:26 2011
@@ -18,13 +18,15 @@ import java.util.List;
 
 /**
  * A method of a {@linkplain PlasticClass transformed class}.
- * <p>
+ * <p/>
  * No methods of this object should be invoked after the class transformation 
is
  * {@linkplain PlasticClassTransformation#createInstantiator() completed}.
  */
 public interface PlasticMethod extends AnnotationAccess
 {
-    /** Returns the PlasticClass containing this method. */
+    /**
+     * Returns the PlasticClass containing this method.
+     */
     PlasticClass getPlasticClass();
 
     /**
@@ -40,15 +42,14 @@ public interface PlasticMethod extends A
     /**
      * Clears the instructions for this method, and creates a new empty 
InstructionBuilder so that the implementation of
      * the method can be specified. This may be considered a kind of last 
resort when no other approach is sufficient.
-     * <p>
+     * <p/>
      * If the method is currently abstract, it will have its abstract flag 
cleared.
-     * <p>
+     * <p/>
      * If the method has advice, the advice is <em>not</em> lost but will 
instead wrap around the new method
      * implementation.
-     * 
+     *
+     * @param callback passed the InstructionBuilder so that an implementation 
of the method can be created
      * @return this method, for further configuration
-     * @param callback
-     *            passed the InstructionBuilder so that an implementation of 
the method can be created
      */
     PlasticMethod changeImplementation(InstructionBuilderCallback callback);
 
@@ -58,17 +59,16 @@ public interface PlasticMethod extends A
      * through the MethodAdvice <em>in the order they are added</em>. Each 
piece of advice will receive the
      * {@link MethodInvocation} and should invoke {@link 
MethodInvocation#proceed()} to pass control to the next piece
      * of advice (and ultimately, to the actual method invocation).
-     * <p>
+     * <p/>
      * If a method implementation is changed, using {@link 
#changeImplementation(InstructionBuilderCallback)}, that
      * change will be honored, but the logic will only be invoked at the end 
of the chain of MethodAdvice. Internally, a
      * new method is created with the same parameters, exceptions, return type 
and implementation (bytecode) as the
      * advised method, <em>then</em> the advised method's implementation is 
changed.
-     * <p>
+     * <p/>
      * Note additionally that a recursive method invocation will still invoke 
the MethodAdvice chain on each recursive
      * call (this is an intended side-effect of copying the exact bytecode of 
the method implementation.
-     * 
-     * @param advice
-     *            advice to add to the method
+     *
+     * @param advice advice to add to the method
      * @return this method, for further configuration
      */
     PlasticMethod addAdvice(MethodAdvice advice);
@@ -77,9 +77,8 @@ public interface PlasticMethod extends A
      * Changes the implementation of the method to delegate to the provided 
field. The field must implement the
      * correct interface (or extend the correct class). The original 
implementation of the method is lost,
      * though (as with {@link 
#changeImplementation(InstructionBuilderCallback)}), method advice is retained.
-     * 
-     * @param field
-     *            to delegate to
+     *
+     * @param field to delegate to
      * @return this method, for further configuration
      */
     PlasticMethod delegateTo(PlasticField field);
@@ -88,9 +87,8 @@ public interface PlasticMethod extends A
      * Much like {@link #delegateTo(PlasticField)}, but the object to delegate 
to
      * is dynamically computed by another method of the class. The method 
should take no parameters
      * and must not return null, or throw any exceptions not compatible with 
the method being proxied.
-     * 
-     * @param method
-     *            to provide the dynamic delegate
+     *
+     * @param method to provide the dynamic delegate
      * @return this method, for further configuration
      */
     PlasticMethod delegateTo(PlasticMethod method);
@@ -103,8 +101,18 @@ public interface PlasticMethod extends A
 
     /**
      * Returns true if the method is an override of a method from the parent 
class.
-     * 
+     *
      * @return true if the parent class contains a method with the name 
signature
      */
     boolean isOverride();
+
+    /**
+     * Returns a short identifier for the method that includes the class name, 
the method name,
+     * and the types of all parameters. This is often used when producing 
debugging output
+     * about the method.
+     *
+     * @return short identifier
+     * @see org.apache.tapestry5.plastic.MethodDescription#toShortString()
+     */
+    String getMethodIdentifier();
 }

Modified: 
tapestry/tapestry5/trunk/plastic/src/test/groovy/org/apache/tapestry5/plastic/MethodAdviceTests.groovy
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/plastic/src/test/groovy/org/apache/tapestry5/plastic/MethodAdviceTests.groovy?rev=1149383&r1=1149382&r2=1149383&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/plastic/src/test/groovy/org/apache/tapestry5/plastic/MethodAdviceTests.groovy
 (original)
+++ 
tapestry/tapestry5/trunk/plastic/src/test/groovy/org/apache/tapestry5/plastic/MethodAdviceTests.groovy
 Thu Jul 21 21:53:26 2011
@@ -12,9 +12,14 @@ class MethodAdviceTests extends Abstract
         setup:
 
         def didInvoke = false
+        def methodId;
 
         def mgr = createMgr( { PlasticClass pc ->
 
+            def method = findMethod(pc, "aSingleMethod")
+
+            methodId = method.methodIdentifier
+
             findMethod(pc, "aSingleMethod").addAdvice ({
                 didInvoke = true
 
@@ -39,6 +44,8 @@ class MethodAdviceTests extends Abstract
 
         didInvoke == false
 
+        methodId == "testsubjects.SingleMethod.aSingleMethod(int)"
+
         when:
 
         o.aSingleMethod(123)

Modified: 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/BaseEventHandlerMethodInvoker.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/BaseEventHandlerMethodInvoker.java?rev=1149383&r1=1149382&r2=1149383&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/BaseEventHandlerMethodInvoker.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/BaseEventHandlerMethodInvoker.java
 Thu Jul 21 21:53:26 2011
@@ -42,8 +42,7 @@ public class BaseEventHandlerMethodInvok
         this.componentId = componentId;
 
         handle = method.getHandle();
-        identifier = String.format("%s.%s", 
method.getPlasticClass().getClassName(), method.getDescription()
-                .toShortString());
+        identifier = method.getMethodIdentifier();
     }
 
     public void invokeEventHandlerMethod(ComponentEvent event, Object instance)

Modified: 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/RenderPhaseMethodWorker.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/RenderPhaseMethodWorker.java?rev=1149383&r1=1149382&r2=1149383&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/RenderPhaseMethodWorker.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/RenderPhaseMethodWorker.java
 Thu Jul 21 21:53:26 2011
@@ -122,9 +122,7 @@ public class RenderPhaseMethodWorker imp
                 // First, tell the Event object what method is being invoked.
 
                 builder.loadArgument(1);
-                builder.loadConstant(
-                        String.format("%s.%s", plasticClass.getClassName(),
-                                method.getDescription().toShortString()));
+                builder.loadConstant( method.getMethodIdentifier());
                 builder.invoke(Event.class, void.class, 
"setMethodDescription", String.class);
 
                 builder.loadThis();


Reply via email to