You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by hl...@apache.org on 2011/07/24 04:17:28 UTC

svn commit: r1150250 - in /tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5: internal/transform/DiscardAfterWorker.java services/TapestryModule.java

Author: hlship
Date: Sun Jul 24 02:17:26 2011
New Revision: 1150250

URL: http://svn.apache.org/viewvc?rev=1150250&view=rev
Log:
TAP5-1508: Record DiscardAfterWorker to new CCTW2 interface

Modified:
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/DiscardAfterWorker.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/DiscardAfterWorker.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/DiscardAfterWorker.java?rev=1150250&r1=1150249&r2=1150250&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/DiscardAfterWorker.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/DiscardAfterWorker.java Sun Jul 24 02:17:26 2011
@@ -1,4 +1,4 @@
-// Copyright 2010 The Apache Software Foundation
+// Copyright 2010, 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.
@@ -13,48 +13,38 @@
 
 package org.apache.tapestry5.internal.transform;
 
-import java.util.List;
-
 import org.apache.tapestry5.ComponentResources;
 import org.apache.tapestry5.annotations.DiscardAfter;
 import org.apache.tapestry5.model.MutableComponentModel;
-import org.apache.tapestry5.services.ClassTransformation;
-import org.apache.tapestry5.services.ComponentClassTransformWorker;
-import org.apache.tapestry5.services.ComponentMethodAdvice;
-import org.apache.tapestry5.services.ComponentMethodInvocation;
-import org.apache.tapestry5.services.TransformMethod;
+import org.apache.tapestry5.plastic.MethodAdvice;
+import org.apache.tapestry5.plastic.MethodInvocation;
+import org.apache.tapestry5.plastic.PlasticClass;
+import org.apache.tapestry5.plastic.PlasticMethod;
+import org.apache.tapestry5.services.transform.ComponentClassTransformWorker2;
+import org.apache.tapestry5.services.transform.TransformationSupport;
 
-public class DiscardAfterWorker implements ComponentClassTransformWorker
+public class DiscardAfterWorker implements ComponentClassTransformWorker2
 {
-
-    private static final ComponentMethodAdvice advice = new ComponentMethodAdvice()
+    private static final MethodAdvice advice = new MethodAdvice()
     {
-
-        public void advise(ComponentMethodInvocation invocation)
+        public void advise(MethodInvocation invocation)
         {
             invocation.proceed();
 
-            if (invocation.isFail())
+            if (invocation.didThrowCheckedException())
                 return;
 
-            ComponentResources resources = invocation.getComponentResources();
+            ComponentResources resources = invocation.getInstanceContext().get(ComponentResources.class);
 
             resources.discardPersistentFieldChanges();
         }
-
     };
 
-    public void transform(final ClassTransformation transformation, final MutableComponentModel model)
+    public void transform(PlasticClass plasticClass, TransformationSupport support, MutableComponentModel model)
     {
-        final List<TransformMethod> methods = transformation.matchMethodsWithAnnotation(DiscardAfter.class);
-
-        if (methods.isEmpty())
-            return;
-
-        for (final TransformMethod method : methods)
+        for (PlasticMethod method : plasticClass.getMethodsWithAnnotation(DiscardAfter.class))
         {
             method.addAdvice(advice);
         }
-
     }
-}
+}
\ No newline at end of file

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java?rev=1150250&r1=1150249&r2=1150250&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java Sun Jul 24 02:17:26 2011
@@ -516,6 +516,7 @@ public final class TapestryModule
      * <dt>Meta</dt>
      * <dd>Checks for meta data annotations and adds it to the component model</dd>
      * <dt>PageActivationContext</dt> <dd>Support for {@link PageActivationContext} annotation</dd>
+     * <dt>DiscardAfter</dt> <dd>Support for {@link DiscardAfter} method annotation </dd>
      * <dt>Cached</dt>
      * <dd>Checks for the {@link org.apache.tapestry5.annotations.Cached} annotation</dd>
      * </dl>
@@ -569,6 +570,8 @@ public final class TapestryModule
 
         configuration.addInstance("Cached", CachedWorker.class);
 
+        configuration.addInstance("DiscardAfter", DiscardAfterWorker.class);
+
         // This one is always last. Any additional private fields that aren't
         // annotated will
         // be converted to clear out at the end of the request.
@@ -634,8 +637,6 @@ public final class TapestryModule
 
         configuration.addInstance("Persist", PersistWorker.class);
 
-        configuration.addInstance("DiscardAfter", DiscardAfterWorker.class);
-
         configuration.addInstance("Log", LogWorker.class);
 
         configuration.addInstance("PageReset", PageResetAnnotationWorker.class);