tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hls...@apache.org
Subject svn commit: r1089575 - in /tapestry/tapestry5/trunk/plastic/src/main/java/org/apache/tapestry5/internal/plastic: AbstractMethodInvocation.java MethodInvocationBundle.java PlasticClassImpl.java
Date Wed, 06 Apr 2011 19:10:43 GMT
Author: hlship
Date: Wed Apr  6 19:10:42 2011
New Revision: 1089575

URL: http://svn.apache.org/viewvc?rev=1089575&view=rev
Log:
TAP5-853: Change the AbstractMethodInvocation constructor to take a MethodInvocationBundle,
not a MethodAdvice[]

This will make it easier to pass additional information into the invocation

Added:
    tapestry/tapestry5/trunk/plastic/src/main/java/org/apache/tapestry5/internal/plastic/MethodInvocationBundle.java
Modified:
    tapestry/tapestry5/trunk/plastic/src/main/java/org/apache/tapestry5/internal/plastic/AbstractMethodInvocation.java
    tapestry/tapestry5/trunk/plastic/src/main/java/org/apache/tapestry5/internal/plastic/PlasticClassImpl.java

Modified: tapestry/tapestry5/trunk/plastic/src/main/java/org/apache/tapestry5/internal/plastic/AbstractMethodInvocation.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/plastic/src/main/java/org/apache/tapestry5/internal/plastic/AbstractMethodInvocation.java?rev=1089575&r1=1089574&r2=1089575&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/plastic/src/main/java/org/apache/tapestry5/internal/plastic/AbstractMethodInvocation.java
(original)
+++ tapestry/tapestry5/trunk/plastic/src/main/java/org/apache/tapestry5/internal/plastic/AbstractMethodInvocation.java
Wed Apr  6 19:10:42 2011
@@ -15,7 +15,6 @@
 package org.apache.tapestry5.internal.plastic;
 
 import org.apache.tapestry5.plastic.InstanceContext;
-import org.apache.tapestry5.plastic.MethodAdvice;
 import org.apache.tapestry5.plastic.MethodInvocation;
 
 public abstract class AbstractMethodInvocation implements MethodInvocation
@@ -24,15 +23,15 @@ public abstract class AbstractMethodInvo
 
     private final InstanceContext instanceContext;
 
-    private final MethodAdvice[] advice;
+    private final MethodInvocationBundle bundle;
 
     private int adviceIndex;
 
-    protected AbstractMethodInvocation(Object instance, InstanceContext instanceContext,
MethodAdvice[] advice)
+    protected AbstractMethodInvocation(Object instance, InstanceContext instanceContext,
MethodInvocationBundle bundle)
     {
         this.instance = instance;
         this.instanceContext = instanceContext;
-        this.advice = advice;
+        this.bundle = bundle;
     }
 
     private Exception checkedException;
@@ -70,10 +69,10 @@ public abstract class AbstractMethodInvo
 
     public MethodInvocation proceed()
     {
-        if (adviceIndex == advice.length)
+        if (adviceIndex == bundle.advice.length)
             proceedToAdvisedMethod();
         else
-            advice[adviceIndex++].advise(this);
+            bundle.advice[adviceIndex++].advise(this);
 
         return this;
     }

Added: tapestry/tapestry5/trunk/plastic/src/main/java/org/apache/tapestry5/internal/plastic/MethodInvocationBundle.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/plastic/src/main/java/org/apache/tapestry5/internal/plastic/MethodInvocationBundle.java?rev=1089575&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/plastic/src/main/java/org/apache/tapestry5/internal/plastic/MethodInvocationBundle.java
(added)
+++ tapestry/tapestry5/trunk/plastic/src/main/java/org/apache/tapestry5/internal/plastic/MethodInvocationBundle.java
Wed Apr  6 19:10:42 2011
@@ -0,0 +1,30 @@
+// Copyright 2011 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package org.apache.tapestry5.internal.plastic;
+
+import org.apache.tapestry5.plastic.MethodAdvice;
+
+/**
+ * Bundles together the fixed (same for all instances) information needed by a {@link MethodInvocationBundle}.
+ */
+public class MethodInvocationBundle
+{
+    public final MethodAdvice[] advice;
+
+    public MethodInvocationBundle(MethodAdvice[] advice)
+    {
+        this.advice = advice;
+    }
+}

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=1089575&r1=1089574&r2=1089575&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
Wed Apr  6 19:10:42 2011
@@ -945,7 +945,7 @@ public class PlasticClassImpl extends Lo
             List<String> consTypes = new ArrayList<String>();
             consTypes.add(Object.class.getName());
             consTypes.add(InstanceContext.class.getName());
-            consTypes.add(MethodAdvice.class.getName() + "[]");
+            consTypes.add(MethodInvocationBundle.class.getName());
 
             for (int i = 0; i < description.argumentTypes.length; i++)
             {
@@ -970,7 +970,7 @@ public class PlasticClassImpl extends Lo
             builder.loadArgument(1);
             builder.loadArgument(2);
             builder.invokeConstructor(AbstractMethodInvocation.class, Object.class, InstanceContext.class,
-                    MethodAdvice[].class);
+                    MethodInvocationBundle.class);
 
             for (int i = 0; i < description.argumentTypes.length; i++)
             {
@@ -1207,12 +1207,13 @@ public class PlasticClassImpl extends Lo
         {
             pool.realize(invocationClassNode);
 
-            String fieldName = String.format("advice_%s_%s", description.methodName, PlasticUtils.nextUID());
+            String fieldName = String.format("methodinvocationbundle_%s_%s", description.methodName,
PlasticUtils.nextUID());
 
             MethodAdvice[] adviceArray = advice.toArray(new MethodAdvice[advice.size()]);
+            MethodInvocationBundle bundle = new MethodInvocationBundle(adviceArray);
 
             classNode.visitField(ACC_PRIVATE | ACC_FINAL, fieldName, nameCache.toDesc(constructorTypes[2]),
null, null);
-            initializeFieldFromStaticContext(fieldName, constructorTypes[2], adviceArray);
+            initializeFieldFromStaticContext(fieldName, constructorTypes[2], bundle);
 
             // Ok, here's the easy part: replace the method invocation with instantiating
the invocation class
 



Mime
View raw message