Author: hlship
Date: Sun Jul 24 15:18:14 2011
New Revision: 1150402

URL: http://svn.apache.org/viewvc?rev=1150402&view=rev
Log:
TAP5-1508: Reimplement LogWorker to CCTW2

Modified:
    
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/LogWorker.java
    
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java
    
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/LoggingAdvice.java
    
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/LoggingAdvisorImpl.java
    
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/MethodLogger.java

Modified: 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/LogWorker.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/LogWorker.java?rev=1150402&r1=1150401&r2=1150402&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/LogWorker.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/LogWorker.java
 Sun Jul 24 15:18:14 2011
@@ -15,11 +15,14 @@
 package org.apache.tapestry5.internal.transform;
 
 import org.apache.tapestry5.annotations.Log;
-import org.apache.tapestry5.ioc.MethodAdvice;
 import org.apache.tapestry5.ioc.internal.services.LoggingAdvice;
 import org.apache.tapestry5.ioc.services.ExceptionTracker;
 import org.apache.tapestry5.model.MutableComponentModel;
-import org.apache.tapestry5.services.*;
+import org.apache.tapestry5.plastic.MethodAdvice;
+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;
 
 import java.util.List;
 
@@ -28,7 +31,7 @@ import java.util.List;
  * logging. This is similar to what the {@link 
org.apache.tapestry5.ioc.services.LoggingDecorator} does for service
  * interface methods.
  */
-public class LogWorker implements ComponentClassTransformWorker
+public class LogWorker implements ComponentClassTransformWorker2
 {
     private final ExceptionTracker exceptionTracker;
 
@@ -37,28 +40,20 @@ public class LogWorker implements Compon
         this.exceptionTracker = exceptionTracker;
     }
 
-    public void transform(ClassTransformation transformation, 
MutableComponentModel model)
+    public void transform(PlasticClass plasticClass, TransformationSupport 
support, MutableComponentModel model)
     {
-        List<TransformMethod> methods = 
transformation.matchMethodsWithAnnotation(Log.class);
+        List<PlasticMethod> methods = 
plasticClass.getMethodsWithAnnotation(Log.class);
 
         if (methods.isEmpty())
+        {
             return;
+        }
 
-        // Re-use the logging advice from LoggingDecorator
         final MethodAdvice loggingAdvice = new 
LoggingAdvice(model.getLogger(), exceptionTracker);
 
-        // ... but wrap it for use at the component level.
-        ComponentMethodAdvice advice = new ComponentMethodAdvice()
-        {
-            public void advise(ComponentMethodInvocation invocation)
-            {
-                loggingAdvice.advise(invocation);
-            }
-        };
-
-        for (TransformMethod method : methods)
+        for (PlasticMethod method : methods)
         {
-            method.addAdvice(advice);
+            method.addAdvice(loggingAdvice);
         }
     }
 }

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=1150402&r1=1150401&r2=1150402&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 15:18:14 2011
@@ -542,6 +542,8 @@ public final class TapestryModule
      * <dd>Allows fields to store their their value persistently between 
requests via {@link Persist}</dd>
      * <dt>SessionAttribute</dt>
      * <dd>Support for the {@link SessionAttribute}</dd>
+     * <dt>Log</dt>
+     * <dd>Checks for the {@link org.apache.tapestry5.annotations.Log} 
annotation</dd>
      * </dl>
      */
     @Contribute(ComponentClassTransformWorker2.class)
@@ -611,6 +613,8 @@ public final class TapestryModule
 
         configuration.addInstance("SessionAttribute", 
SessionAttributeWorker.class);
 
+        configuration.addInstance("Log", LogWorker.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.
@@ -623,8 +627,6 @@ public final class TapestryModule
      * <dl>
      * <dt>Inject</dt>
      * <dd>Used with the {@link org.apache.tapestry5.ioc.annotations.Inject} 
annotation, when a value is supplied</dd>
-     * <dt>Log</dt>
-     * <dd>Checks for the {@link org.apache.tapestry5.annotations.Log} 
annotation</dd>
      * <dt>HeartbeatDeferred
      * <dd>Support for the {@link HeartbeatDeferred} annotation
      * </dl>
@@ -636,8 +638,6 @@ public final class TapestryModule
     {
         configuration.addInstance("Inject", InjectWorker.class);
 
-        configuration.addInstance("Log", LogWorker.class);
-
         configuration.addInstance("HeartbeatDeferred", 
HeartbeatDeferredWorker.class, "after:RenderPhase");
     }
 

Modified: 
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/LoggingAdvice.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/LoggingAdvice.java?rev=1150402&r1=1150401&r2=1150402&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/LoggingAdvice.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/LoggingAdvice.java
 Sun Jul 24 15:18:14 2011
@@ -1,4 +1,4 @@
-// Copyright 2008 The Apache Software Foundation
+// Copyright 2008, 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.
@@ -14,9 +14,9 @@
 
 package org.apache.tapestry5.ioc.internal.services;
 
-import org.apache.tapestry5.ioc.Invocation;
-import org.apache.tapestry5.ioc.MethodAdvice;
 import org.apache.tapestry5.ioc.services.ExceptionTracker;
+import org.apache.tapestry5.plastic.MethodAdvice;
+import org.apache.tapestry5.plastic.MethodInvocation;
 import org.slf4j.Logger;
 
 public class LoggingAdvice implements MethodAdvice
@@ -28,7 +28,7 @@ public class LoggingAdvice implements Me
         methodLogger = new MethodLogger(logger, exceptionTracker);
     }
 
-    public void advise(Invocation invocation)
+    public void advise(MethodInvocation invocation)
     {
         boolean debug = methodLogger.isDebugEnabled();
 
@@ -51,9 +51,9 @@ public class LoggingAdvice implements Me
             throw ex;
         }
 
-        if (invocation.isFail())
+        if (invocation.didThrowCheckedException())
         {
-            Exception thrown = invocation.getThrown(Exception.class);
+            Exception thrown = invocation.getCheckedException(Exception.class);
 
             methodLogger.fail(invocation, thrown);
 

Modified: 
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/LoggingAdvisorImpl.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/LoggingAdvisorImpl.java?rev=1150402&r1=1150401&r2=1150402&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/LoggingAdvisorImpl.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/LoggingAdvisorImpl.java
 Sun Jul 24 15:18:14 2011
@@ -1,4 +1,4 @@
-// Copyright 2009, 2010 The Apache Software Foundation
+// Copyright 2009, 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.
@@ -14,11 +14,11 @@
 
 package org.apache.tapestry5.ioc.internal.services;
 
-import org.apache.tapestry5.ioc.MethodAdvice;
 import org.apache.tapestry5.ioc.MethodAdviceReceiver;
 import org.apache.tapestry5.ioc.annotations.PreventServiceDecoration;
 import org.apache.tapestry5.ioc.services.ExceptionTracker;
 import org.apache.tapestry5.ioc.services.LoggingAdvisor;
+import org.apache.tapestry5.plastic.MethodAdvice;
 import org.slf4j.Logger;
 
 @PreventServiceDecoration

Modified: 
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/MethodLogger.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/MethodLogger.java?rev=1150402&r1=1150401&r2=1150402&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/MethodLogger.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/MethodLogger.java
 Sun Jul 24 15:18:14 2011
@@ -1,4 +1,4 @@
-// Copyright 2006, 2007, 2008 The Apache Software Foundation
+// Copyright 2006, 2007, 2008, 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.
@@ -14,16 +14,17 @@
 
 package org.apache.tapestry5.ioc.internal.services;
 
-import org.apache.tapestry5.ioc.Invocation;
 import org.apache.tapestry5.ioc.services.ExceptionTracker;
+import org.apache.tapestry5.plastic.MethodInvocation;
 import org.slf4j.Logger;
 
-import static java.lang.String.format;
 import java.util.Iterator;
 
+import static java.lang.String.format;
+
 /**
  * Used by {@link 
org.apache.tapestry5.ioc.internal.services.LoggingDecoratorImpl} to delegate 
out logging behavior to a
- * seperate object.
+ * separate object.
  */
 public final class MethodLogger
 {
@@ -55,13 +56,13 @@ public final class MethodLogger
      *
      * @param invocation identifies method invoked as well as parameters 
passed to method
      */
-    public void entry(Invocation invocation)
+    public void entry(MethodInvocation invocation)
     {
         StringBuilder buffer = new StringBuilder(BUFFER_SIZE);
 
-        buffer.append(format("[%s] %s(", ENTER, invocation.getMethodName()));
+        buffer.append(format("[%s] %s(", ENTER, 
invocation.getMethod().getName()));
 
-        for (int i = 0; i < invocation.getParameterCount(); i++)
+        for (int i = 0; i < invocation.getMethod().getParameterTypes().length; 
i++)
         {
             if (i > 0) buffer.append(", ");
 
@@ -137,16 +138,16 @@ public final class MethodLogger
      *
      * @param invocation identifies method invocation and  result value
      */
-    public void exit(Invocation invocation)
+    public void exit(MethodInvocation invocation)
     {
         StringBuilder buffer = new StringBuilder(BUFFER_SIZE);
 
-        buffer.append(format("[%s] %s", EXIT, invocation.getMethodName()));
+        buffer.append(format("[%s] %s", EXIT, 
invocation.getMethod().getName()));
 
-        if (invocation.getResultType() != void.class)
+        if (invocation.getMethod().getReturnType() != void.class)
         {
             buffer.append(" [");
-            convert(buffer, invocation.getResult());
+            convert(buffer, invocation.getReturnValue());
             buffer.append(']');
         }
 
@@ -159,12 +160,12 @@ public final class MethodLogger
      * @param invocation identifies method invocation which failed
      * @param t          exception throws by method invocation
      */
-    public void fail(Invocation invocation, Throwable t)
+    public void fail(MethodInvocation invocation, Throwable t)
     {
         logger.debug(
                 format("[%s] %s -- %s", FAIL,
-                       invocation.getMethodName(),
-                       t.getClass().getName()),
+                        invocation.getMethod().getName(),
+                        t.getClass().getName()),
                 exceptionTracker.exceptionLogged(t) ? null : t);
     }
 }


Reply via email to