Author: hlship
Date: Thu Mar  3 21:42:19 2011
New Revision: 1076807

URL: http://svn.apache.org/viewvc?rev=1076807&view=rev
Log:
TAP5-1467: Remove deprecated methods from ClassTransformation

Removed:
    
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/FieldFilter.java
Modified:
    
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/InternalClassTransformationImpl.java
    
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/internal/transform/RetainWorker.java
    
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/ClassTransformation.java
    
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/services/ReverseStringsWorker.java
    
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/InternalClassTransformationImplTest.java
    
tapestry/tapestry5/trunk/tapestry-hibernate/src/main/java/org/apache/tapestry5/internal/hibernate/CommitAfterWorker.java

Modified: 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/InternalClassTransformationImpl.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/InternalClassTransformationImpl.java?rev=1076807&r1=1076806&r2=1076807&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/InternalClassTransformationImpl.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/InternalClassTransformationImpl.java
 Thu Mar  3 21:42:19 2011
@@ -23,7 +23,17 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
-import javassist.*;
+import javassist.CannotCompileException;
+import javassist.ClassPool;
+import javassist.CtBehavior;
+import javassist.CtClass;
+import javassist.CtConstructor;
+import javassist.CtField;
+import javassist.CtMember;
+import javassist.CtMethod;
+import javassist.CtNewConstructor;
+import javassist.CtNewMethod;
+import javassist.NotFoundException;
 import javassist.bytecode.FieldInfo;
 import javassist.bytecode.MethodInfo;
 import javassist.bytecode.SignatureAttribute;
@@ -47,7 +57,18 @@ import org.apache.tapestry5.model.Compon
 import org.apache.tapestry5.model.MutableComponentModel;
 import org.apache.tapestry5.runtime.Component;
 import org.apache.tapestry5.runtime.ComponentEvent;
-import org.apache.tapestry5.services.*;
+import org.apache.tapestry5.services.ComponentEventHandler;
+import org.apache.tapestry5.services.ComponentInstanceOperation;
+import org.apache.tapestry5.services.ComponentMethodAdvice;
+import org.apache.tapestry5.services.ComponentMethodInvocation;
+import org.apache.tapestry5.services.ComponentValueProvider;
+import org.apache.tapestry5.services.MethodAccess;
+import org.apache.tapestry5.services.MethodInvocationResult;
+import org.apache.tapestry5.services.TransformConstants;
+import org.apache.tapestry5.services.TransformField;
+import org.apache.tapestry5.services.TransformMethod;
+import org.apache.tapestry5.services.TransformMethodSignature;
+import org.apache.tapestry5.services.TransformUtils;
 import org.slf4j.Logger;
 
 /**
@@ -328,7 +349,7 @@ public final class InternalClassTransfor
          * The static method takes the same parameters as the main method, but 
takes
          * an instance object first. Invoking the static method turns into an 
invocation
          * of the proper method of the instance object.
-         *
+         * 
          * @return the name of the created static access method
          */
         private String createStaticAccessMethodForNonPublicMethod()
@@ -536,6 +557,23 @@ public final class InternalClassTransfor
             return field.getModifiers();
         }
 
+        private void makeReadOnly()
+        {
+            String methodName = newMemberName("write", name);
+
+            TransformMethodSignature sig = new 
TransformMethodSignature(Modifier.PRIVATE, "void", methodName,
+                    new String[]
+                    { type }, null);
+
+            String message = ServicesMessages.readOnlyField(getClassName(), 
name);
+
+            String body = String.format("throw new 
java.lang.RuntimeException(\"%s\");", message);
+
+            addNewMethod(sig, body);
+
+            replaceWriteAccess(methodName);
+        }
+
         void replaceReadAccess(String methodName)
         {
             failIfFrozen();
@@ -754,7 +792,7 @@ public final class InternalClassTransfor
 
             addInjectToConstructor(name, fieldType, value);
 
-            makeReadOnly(name);
+            makeReadOnly();
         }
 
         public <T> void injectIndirect(ComponentValueProvider<T> provider)
@@ -767,7 +805,7 @@ public final class InternalClassTransfor
 
             addToConstructor(String.format("  %s = (%s) (%s).get(%s);", name, 
type, argReference, resourcesFieldName));
 
-            makeReadOnly(name);
+            makeReadOnly();
         }
 
     }
@@ -991,21 +1029,11 @@ public final class InternalClassTransfor
             throw new 
RuntimeException(ServicesMessages.nonPrivateFields(getClassName(), names));
     }
 
-    public <T extends Annotation> T getFieldAnnotation(String fieldName, 
Class<T> annotationClass)
-    {
-        return getField(fieldName).getAnnotation(annotationClass);
-    }
-
-    public <T extends Annotation> T 
getMethodAnnotation(TransformMethodSignature signature, Class<T> 
annotationClass)
-    {
-        return getOrCreateMethod(signature).getAnnotation(annotationClass);
-    }
-
     /**
      * Searches an array of objects (that are really annotations instances) to 
find one that is of
      * the correct type,
      * which is returned.
-     *
+     * 
      * @param <T>
      * @param annotationClass
      *            the annotation to search for
@@ -1131,7 +1159,7 @@ public final class InternalClassTransfor
      * degenerate cases that are not covered properly: these are related to 
base interfaces that may
      * be implemented by
      * base classes.
-     *
+     * 
      * @param ctInterface
      * @throws NotFoundException
      */
@@ -1221,11 +1249,6 @@ public final class InternalClassTransfor
         return false;
     }
 
-    public void claimField(String fieldName, Object tag)
-    {
-        getField(fieldName).claim(tag);
-    }
-
     public void addMethod(TransformMethodSignature signature, String 
methodBody)
     {
         removed("addMethod(TransformMethodSignature,String)");
@@ -1556,28 +1579,6 @@ public final class InternalClassTransfor
         return true;
     }
 
-    public List<String> findFieldsWithAnnotation(final Class<? extends 
Annotation> annotationClass)
-    {
-        return toFieldNames(matchFieldsWithAnnotation(annotationClass));
-    }
-
-    public List<String> findFields(final FieldFilter filter)
-    {
-        assert filter != null;
-
-        failIfFrozen();
-
-        List<TransformField> fields = matchFields(new 
Predicate<TransformField>()
-        {
-            public boolean accept(TransformField object)
-            {
-                return filter.accept(object.getName(), object.getType());
-            }
-        });
-
-        return toFieldNames(fields);
-    }
-
     public List<TransformField> matchFields(Predicate<TransformField> 
predicate)
     {
         failIfFrozen();
@@ -1596,34 +1597,6 @@ public final class InternalClassTransfor
         });
     }
 
-    public List<TransformMethodSignature> findMethodsWithAnnotation(final 
Class<? extends Annotation> annotationClass)
-    {
-        List<TransformMethod> methods = matchMethods(new 
Predicate<TransformMethod>()
-        {
-            public boolean accept(TransformMethod method)
-            {
-                return method.getAnnotation(annotationClass) != null;
-            };
-        });
-
-        return toMethodSignatures(methods);
-    }
-
-    public List<TransformMethodSignature> findMethods(final MethodFilter 
filter)
-    {
-        assert filter != null;
-
-        List<TransformMethod> methods = matchMethods(new 
Predicate<TransformMethod>()
-        {
-            public boolean accept(TransformMethod object)
-            {
-                return filter.accept(object.getSignature());
-            };
-        });
-
-        return toMethodSignatures(methods);
-    }
-
     public List<TransformMethod> matchMethods(Predicate<TransformMethod> 
predicate)
     {
         failIfFrozen();
@@ -1650,10 +1623,12 @@ public final class InternalClassTransfor
             String[] parameters = toTypeNames(method.getParameterTypes());
             String[] exceptions = toTypeNames(method.getExceptionTypes());
 
-            final SignatureAttribute attribute = 
(SignatureAttribute)method.getMethodInfo().getAttribute(SignatureAttribute.tag);
+            final SignatureAttribute attribute = (SignatureAttribute) 
method.getMethodInfo().getAttribute(
+                    SignatureAttribute.tag);
             String sig = attribute != null ? attribute.getSignature() : null;
 
-            return new TransformMethodSignature(method.getModifiers(), type, 
sig, method.getName(), parameters, exceptions);
+            return new TransformMethodSignature(method.getModifiers(), type, 
sig, method.getName(), parameters,
+                    exceptions);
         }
         catch (NotFoundException ex)
         {
@@ -1868,7 +1843,7 @@ public final class InternalClassTransfor
     /**
      * Adds a parameter to the constructor for the class; the parameter is 
used to initialize the
      * value for a field.
-     *
+     * 
      * @param fieldName
      *            name of field to inject
      * @param fieldType
@@ -2144,24 +2119,6 @@ public final class InternalClassTransfor
         return builder.toString();
     }
 
-    public void makeReadOnly(String fieldName)
-    {
-        String methodName = newMemberName("write", fieldName);
-
-        String fieldType = getFieldType(fieldName);
-
-        TransformMethodSignature sig = new 
TransformMethodSignature(Modifier.PRIVATE, "void", methodName, new String[]
-        { fieldType }, null);
-
-        String message = ServicesMessages.readOnlyField(getClassName(), 
fieldName);
-
-        String body = String.format("throw new 
java.lang.RuntimeException(\"%s\");", message);
-
-        addNewMethod(sig, body);
-
-        replaceWriteAccess(fieldName, methodName);
-    }
-
     public void removeField(String fieldName)
     {
         removed("removeField(String)");
@@ -2320,7 +2277,7 @@ public final class InternalClassTransfor
 
     /**
      * Adds a new constructor argument to the transformed constructor.
-     *
+     * 
      * @param parameterType
      *            type of parameter
      * @param value

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=1076807&r1=1076806&r2=1076807&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
 Thu Mar  3 21:42:19 2011
@@ -1,10 +1,10 @@
-// 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.
 // You may obtain a copy of the License at
 //
-//     http://www.apache.org/licenses/LICENSE-2.0
+// 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,
@@ -39,9 +39,10 @@ public class LogWorker implements Compon
 
     public void transform(ClassTransformation transformation, 
MutableComponentModel model)
     {
-        List<TransformMethodSignature> signatures = 
transformation.findMethodsWithAnnotation(Log.class);
+        List<TransformMethod> methods = 
transformation.matchMethodsWithAnnotation(Log.class);
 
-        if (signatures.isEmpty()) return;
+        if (methods.isEmpty())
+            return;
 
         // Re-use the logging advice from LoggingDecorator
         final MethodAdvice loggingAdvice = new 
LoggingAdvice(model.getLogger(), exceptionTracker);
@@ -55,7 +56,9 @@ public class LogWorker implements Compon
             }
         };
 
-        for (TransformMethodSignature signature : signatures)
-            transformation.advise(signature, advice);
+        for (TransformMethod method : methods)
+        {
+            method.addAdvice(advice);
+        }
     }
 }

Modified: 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/RetainWorker.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/RetainWorker.java?rev=1076807&r1=1076806&r2=1076807&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/RetainWorker.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/RetainWorker.java
 Thu Mar  3 21:42:19 2011
@@ -1,4 +1,4 @@
-// Copyright 2006 The Apache Software Foundation
+// Copyright 2006, 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,10 +14,13 @@
 
 package org.apache.tapestry5.internal.transform;
 
+import java.util.List;
+
 import org.apache.tapestry5.annotations.Retain;
 import org.apache.tapestry5.model.MutableComponentModel;
 import org.apache.tapestry5.services.ClassTransformation;
 import org.apache.tapestry5.services.ComponentClassTransformWorker;
+import org.apache.tapestry5.services.TransformField;
 
 /**
  * Identifies fields with the {@link org.apache.tapestry5.annotations.Retain} 
annotation, and "claims" them so that no
@@ -29,14 +32,16 @@ public final class RetainWorker implemen
      * Claims each field with the {@link 
org.apache.tapestry5.annotations.Retain} annotation, claiming it using the
      * annotation as the tag.
      */
+    @SuppressWarnings("deprecation")
     public void transform(ClassTransformation transformation, 
MutableComponentModel model)
     {
-        for (String fieldName : 
transformation.findFieldsWithAnnotation(Retain.class))
+        List<TransformField> fields = 
transformation.matchFieldsWithAnnotation(Retain.class);
+
+        for (TransformField field : fields)
         {
-            Retain annotation = transformation.getFieldAnnotation(fieldName, 
Retain.class);
+            Retain annotation = field.getAnnotation(Retain.class);
 
-            transformation.claimField(fieldName, annotation);
+            field.claim(annotation);
         }
     }
-
 }

Modified: 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/ClassTransformation.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/ClassTransformation.java?rev=1076807&r1=1076806&r2=1076807&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/ClassTransformation.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/ClassTransformation.java
 Thu Mar  3 21:42:19 2011
@@ -91,15 +91,6 @@ public interface ClassTransformation ext
     String newMemberName(String prefix, String baseName);
 
     /**
-     * Generates a list of the names of declared instance fields that have the 
indicated annotation.
-     * Non-private and
-     * static fields are ignored. Only the names of private instance fields 
are returned.
-     * 
-     * @deprecated Use {@link #matchFieldsWithAnnotation(Class)} instead
-     */
-    List<String> findFieldsWithAnnotation(Class<? extends Annotation> 
annotationClass);
-
-    /**
      * Returns a sorted list of declared instance fields with the indicated 
annotation. Non-private
      * and static fields are ignored.
      * 
@@ -108,28 +99,6 @@ public interface ClassTransformation ext
     List<TransformField> matchFieldsWithAnnotation(Class<? extends Annotation> 
annotationClass);
 
     /**
-     * Finds all methods defined in the class that are marked with the 
provided annotation.
-     * 
-     * @param annotationClass
-     * @return a list of method signature (which may be empty) in ascending 
order
-     * @see #findMethods(MethodFilter)
-     * @deprecated Use {@link #matchMethodsWithAnnotation(Class)} instead
-     */
-    List<TransformMethodSignature> findMethodsWithAnnotation(Class<? extends 
Annotation> annotationClass);
-
-    /**
-     * Finds all methods matched by the provided filter.
-     * 
-     * @param filter
-     *            Passed each method signature, it may include or exclude each 
potential
-     * @return a list of matching method signatures (which may be empty) in 
ascending order (by
-     *         method name), but
-     *         descending order (by parameter count) within overrides of a 
single method name.
-     * @deprecated Use {@link #matchMethods(Predicate)} instead
-     */
-    List<TransformMethodSignature> findMethods(MethodFilter filter);
-
-    /**
      * Finds all methods matched by the provided predicate.
      * 
      * @param predicate
@@ -150,17 +119,6 @@ public interface ClassTransformation ext
     List<TransformMethod> matchMethodsWithAnnotation(Class<? extends 
Annotation> annotationType);
 
     /**
-     * Finds all unclaimed fields matched by the provided filter. Only 
considers private instance
-     * fields.
-     * 
-     * @param filter
-     *            passed each field name and field type
-     * @return the names of all matched fields, in ascending order
-     * @deprecated Use {@link #matchFields(Predicate)} instead
-     */
-    List<String> findFields(FieldFilter filter);
-
-    /**
      * Finds all unclaimed fields matched by the provided predicate. Only 
considers instance fields.
      * Added, removed and claimed fields are excluded.
      * 
@@ -172,22 +130,6 @@ public interface ClassTransformation ext
     List<TransformField> matchFields(Predicate<TransformField> predicate);
 
     /**
-     * Finds an annotation on a declared instance field.
-     * 
-     * @param <T>
-     *            constrains parameter and return value to Annotation types
-     * @param fieldName
-     *            the name of the field, which must exist
-     * @param annotationClass
-     *            the type of annotation to access
-     * @return the annotation if present, or null otherwise
-     * @throws IllegalArgumentException
-     *             if the fieldName does not correspond to a declared field
-     * @deprecated Use {@link TransformField#getAnnotation(Class)} instead
-     */
-    <T extends Annotation> T getFieldAnnotation(String fieldName, Class<T> 
annotationClass);
-
-    /**
      * Locates a declared field by its field name. The field must exist.
      * 
      * @param name
@@ -200,56 +142,6 @@ public interface ClassTransformation ext
     TransformField getField(String fieldName);
 
     /**
-     * Finds an annotation on a declared method.
-     * 
-     * @param <T>
-     *            constrains parameter and return value to Annotation types
-     * @param method
-     *            the method signature to search
-     * @param annotationClass
-     *            the type of annotation to access
-     * @return the annotation if present, or null otherwise
-     * @throws IllegalArgumentException
-     *             if the method signature does not correspond to a declared 
method
-     * @deprecated Use {@link TransformMethod#getAnnotation(Class)} instead
-     */
-    <T extends Annotation> T getMethodAnnotation(TransformMethodSignature 
method, Class<T> annotationClass);
-
-    /**
-     * Claims a field so as to ensure that only a single annotation is applied 
to any single field.
-     * When a
-     * transformation occurs (driven by a field annotation), the field is 
claimed (using the
-     * annotation object as the
-     * tag). If a field has multiple conflicting annotations, this will be 
discovered when the code
-     * attempts to claim
-     * the field a second time.
-     * 
-     * @param fieldName
-     *            the name of the field that is being claimed
-     * @param tag
-     *            a non-null object that represents why the field is being 
tagged (this is typically
-     *            a specific
-     *            annotation on the field)
-     * @throws IllegalArgumentException
-     *             if the fieldName does not correspond to a declared instance 
field
-     * @throws IllegalStateException
-     *             if the field is already claimed for some other tag
-     * @deprecated Use {@link TransformField#claim(Object)} instead
-     */
-    void claimField(String fieldName, Object tag);
-
-    /**
-     * Changes the field to be read only. Any existing code that changes the 
field will cause a
-     * runtime exception.
-     * 
-     * @param fieldName
-     *            name of field to so change
-     * @deprecated Use {@link TransformField#replaceAccess(TransformField)} 
instead
-     * @see ReadOnlyFieldValueConduit
-     */
-    void makeReadOnly(String fieldName);
-
-    /**
      * Finds any declared <em>instance</em> fields that have not been claimed 
(via {@link #claimField(String, Object)})
      * and have not been added , and returns the names of those fields. May 
return an empty array.
      * 

Modified: 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/services/ReverseStringsWorker.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/services/ReverseStringsWorker.java?rev=1076807&r1=1076806&r2=1076807&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/services/ReverseStringsWorker.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/services/ReverseStringsWorker.java
 Thu Mar  3 21:42:19 2011
@@ -1,10 +1,10 @@
-// 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.
 // You may obtain a copy of the License at
 //
-//     http://www.apache.org/licenses/LICENSE-2.0
+// 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,
@@ -41,10 +41,8 @@ public class ReverseStringsWorker implem
                 {
                     Exception thrown = invocation.getThrown(Exception.class);
 
-                    invocation.overrideResult(
-                            String.format("Invocation of method %s() failed 
with %s.",
-                                          invocation.getMethodName(),
-                                          thrown.getClass().getName()));
+                    invocation.overrideResult(String.format("Invocation of 
method %s() failed with %s.",
+                            invocation.getMethodName(), 
thrown.getClass().getName()));
 
                     return;
                 }
@@ -71,9 +69,9 @@ public class ReverseStringsWorker implem
 
     public void transform(ClassTransformation transformation, 
MutableComponentModel model)
     {
-        for (TransformMethodSignature sig : 
transformation.findMethodsWithAnnotation(ReverseStrings.class))
+        for (TransformMethod method : 
transformation.matchMethodsWithAnnotation(ReverseStrings.class))
         {
-            transformation.advise(sig, advice);
+            method.addAdvice(advice);
         }
     }
 }

Modified: 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/InternalClassTransformationImplTest.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/InternalClassTransformationImplTest.java?rev=1076807&r1=1076806&r2=1076807&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/InternalClassTransformationImplTest.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/InternalClassTransformationImplTest.java
 Thu Mar  3 21:42:19 2011
@@ -36,6 +36,8 @@ import org.apache.tapestry5.annotations.
 import org.apache.tapestry5.annotations.OnEvent;
 import org.apache.tapestry5.annotations.Retain;
 import org.apache.tapestry5.annotations.SetupRender;
+import org.apache.tapestry5.func.F;
+import org.apache.tapestry5.func.Predicate;
 import org.apache.tapestry5.internal.InternalComponentResources;
 import org.apache.tapestry5.internal.model.MutableComponentModelImpl;
 import org.apache.tapestry5.internal.test.InternalBaseTestCase;
@@ -67,6 +69,7 @@ import org.apache.tapestry5.services.Com
 import org.apache.tapestry5.services.MethodAccess;
 import org.apache.tapestry5.services.MethodFilter;
 import org.apache.tapestry5.services.MethodInvocationResult;
+import org.apache.tapestry5.services.TransformField;
 import org.apache.tapestry5.services.TransformMethod;
 import org.apache.tapestry5.services.TransformMethodSignature;
 import org.slf4j.Logger;
@@ -242,7 +245,7 @@ public class InternalClassTransformation
     }
 
     @Test
-    public void find_annotation_on_unknown_field() throws Exception
+    public void get_unknown_field() throws Exception
     {
         Logger logger = mockLogger();
 
@@ -252,7 +255,7 @@ public class InternalClassTransformation
 
         try
         {
-            ct.getFieldAnnotation("unknownField", Retain.class);
+            ct.getField("unknownField");
             unreachable();
         }
         catch (RuntimeException ex)
@@ -265,7 +268,7 @@ public class InternalClassTransformation
     }
 
     @Test
-    public void find_field_annotation() throws Exception
+    public void get_field_annotation() throws Exception
     {
         Logger logger = mockLogger();
 
@@ -273,7 +276,7 @@ public class InternalClassTransformation
 
         ClassTransformation ct = createClassTransformation(ParentClass.class, 
logger);
 
-        Retain retain = ct.getFieldAnnotation("_annotatedField", Retain.class);
+        Retain retain = 
ct.getField("_annotatedField").getAnnotation(Retain.class);
 
         assertNotNull(retain);
 
@@ -290,16 +293,16 @@ public class InternalClassTransformation
         ClassTransformation ct = createClassTransformation(ParentClass.class, 
logger);
 
         // Field with annotation, but not that annotation
-        assertNull(ct.getFieldAnnotation("_annotatedField", Override.class));
+        
assertNull(ct.getField("_annotatedField").getAnnotation(Override.class));
 
         // Field with no annotation
-        assertNull(ct.getFieldAnnotation("_parentField", Override.class));
+        assertNull(ct.getField("_parentField").getAnnotation(Override.class));
 
         verify();
     }
 
     @Test
-    public void find_fields_with_annotation() throws Exception
+    public void match_fields_with_annotation() throws Exception
     {
         Logger logger = mockLogger();
 
@@ -307,10 +310,10 @@ public class InternalClassTransformation
 
         ClassTransformation ct = createClassTransformation(ParentClass.class, 
logger);
 
-        List<String> fields = ct.findFieldsWithAnnotation(Retain.class);
+        List<TransformField> fields = 
ct.matchFieldsWithAnnotation(Retain.class);
 
         assertEquals(fields.size(), 1);
-        assertEquals(fields.get(0), "_annotatedField");
+        assertEquals(fields.get(0).getName(), "_annotatedField");
 
         verify();
     }
@@ -352,7 +355,7 @@ public class InternalClassTransformation
 
         ClassTransformation ct = createClassTransformation(ParentClass.class, 
logger);
 
-        List<String> fields = ct.findFieldsWithAnnotation(Documented.class);
+        List<TransformField> fields = 
ct.matchFieldsWithAnnotation(Documented.class);
 
         assertTrue(fields.isEmpty());
 
@@ -372,7 +375,7 @@ public class InternalClassTransformation
 
         assertEquals(unclaimed, asList("_field1", "_field4", "_zzfield"));
 
-        ct.claimField("_field4", "Fred");
+        ct.getField("_field4").claim("Fred");
 
         unclaimed = ct.findUnclaimedFields();
 
@@ -380,7 +383,7 @@ public class InternalClassTransformation
 
         try
         {
-            ct.claimField("_field4", "Barney");
+            ct.getField("_field4").claim("Barney");
             unreachable();
         }
         catch (RuntimeException ex)
@@ -703,8 +706,8 @@ public class InternalClassTransformation
                         // Don't even bother with proceed() this time, which 
is OK (but
                         // somewhat rare).
 
-                        MethodInvocationResult result = 
targetMethodAccess.invoke(invocation.getInstance(), invocation
-                                .getParameter(0), invocation.getParameter(1));
+                        MethodInvocationResult result = 
targetMethodAccess.invoke(invocation.getInstance(),
+                                invocation.getParameter(0), 
invocation.getParameter(1));
 
                         invocation.overrideResult(result.getReturnValue());
                     }
@@ -763,7 +766,7 @@ public class InternalClassTransformation
         InternalClassTransformation ct = new 
InternalClassTransformationImpl(classFactory, targetObjectCtClass, null,
                 model, null, false);
 
-        ct.makeReadOnly("_value");
+        ct.getField("_value").inject("Read-Only Value");
 
         ct.finish();
 
@@ -910,7 +913,7 @@ public class InternalClassTransformation
     }
 
     @Test
-    public void find_methods_with_annotation() throws Exception
+    public void match_methods_with_annotation() throws Exception
     {
         Logger logger = mockLogger();
 
@@ -918,27 +921,27 @@ public class InternalClassTransformation
 
         ClassTransformation ct = 
createClassTransformation(AnnotatedPage.class, logger);
 
-        List<TransformMethodSignature> l = 
ct.findMethodsWithAnnotation(SetupRender.class);
+        List<TransformMethod> l = 
ct.matchMethodsWithAnnotation(SetupRender.class);
 
         // Check order
 
         assertEquals(l.size(), 2);
-        assertEquals(l.get(0).toString(), "void beforeRender()");
-        assertEquals(l.get(1).toString(), "boolean 
earlyRender(org.apache.tapestry5.MarkupWriter)");
+        assertEquals(l.get(0).getSignature().toString(), "void 
beforeRender()");
+        assertEquals(l.get(1).getSignature().toString(), "boolean 
earlyRender(org.apache.tapestry5.MarkupWriter)");
 
         // Check up on cacheing
 
-        assertEquals(ct.findMethodsWithAnnotation(SetupRender.class), l);
+        assertEquals(ct.matchMethodsWithAnnotation(SetupRender.class), l);
 
         // Check up on no match.
 
-        assertTrue(ct.findFieldsWithAnnotation(Deprecated.class).isEmpty());
+        assertTrue(ct.matchMethodsWithAnnotation(Deprecated.class).isEmpty());
 
         verify();
     }
 
     @Test
-    public void find_methods_using_filter() throws Exception
+    public void match_methods_using_predicate() throws Exception
     {
         Logger logger = mockLogger();
 
@@ -948,29 +951,29 @@ public class InternalClassTransformation
 
         // Duplicates, somewhat less efficiently, the logic in 
find_methods_with_annotation().
 
-        MethodFilter filter = new MethodFilter()
+        Predicate<TransformMethod> predicate = new Predicate<TransformMethod>()
         {
-            public boolean accept(TransformMethodSignature signature)
+            public boolean accept(TransformMethod element)
             {
-                return ct.getMethodAnnotation(signature, SetupRender.class) != 
null;
+                return element.getAnnotation(SetupRender.class) != null;
             }
         };
 
-        List<TransformMethodSignature> l = ct.findMethods(filter);
+        List<TransformMethod> l = ct.matchMethods(predicate);
 
         // Check order
 
         assertEquals(l.size(), 2);
-        assertEquals(l.get(0).toString(), "void beforeRender()");
-        assertEquals(l.get(1).toString(), "boolean 
earlyRender(org.apache.tapestry5.MarkupWriter)");
+        assertEquals(l.get(0).getSignature().toString(), "void 
beforeRender()");
+        assertEquals(l.get(1).getSignature().toString(), "boolean 
earlyRender(org.apache.tapestry5.MarkupWriter)");
 
         // Check up on cacheing
 
-        assertEquals(ct.findMethodsWithAnnotation(SetupRender.class), l);
+        assertEquals(ct.matchMethodsWithAnnotation(SetupRender.class), l);
 
         // Check up on no match.
 
-        assertTrue(ct.findFieldsWithAnnotation(Deprecated.class).isEmpty());
+        assertTrue(ct.matchMethodsWithAnnotation(Deprecated.class).isEmpty());
 
         verify();
     }
@@ -1035,7 +1038,7 @@ public class InternalClassTransformation
 
         ClassTransformation ct = 
createClassTransformation(EventHandlerTarget.class, logger);
 
-        OnEvent annotation = ct.getMethodAnnotation(new 
TransformMethodSignature("handler"), OnEvent.class);
+        OnEvent annotation = ct.getOrCreateMethod(new 
TransformMethodSignature("handler")).getAnnotation(OnEvent.class);
 
         // Check that the attributes of the annotation match the expectation.
 
@@ -1062,14 +1065,12 @@ public class InternalClassTransformation
 
         ClassTransformation ct = 
createClassTransformation(MethodIdentifier.class, logger);
 
-        List<TransformMethodSignature> sigs = 
ct.findMethodsWithAnnotation(OnEvent.class);
+        List<TransformMethod> methods = 
ct.matchMethodsWithAnnotation(OnEvent.class);
 
-        assertEquals(sigs.size(), 1);
-
-        TransformMethodSignature sig = sigs.get(0);
+        assertEquals(methods.size(), 1);
 
         assertEquals(
-                ct.getMethodIdentifier(sig),
+                methods.get(0).getMethodIdentifier(),
                 
"org.apache.tapestry5.internal.transform.pages.MethodIdentifier.makeWaves(java.lang.String,
 int[]) (at MethodIdentifier.java:24)");
 
         verify();
@@ -1082,23 +1083,15 @@ public class InternalClassTransformation
 
         replay();
 
-        MethodFilter filter = new MethodFilter()
-        {
-            public boolean accept(TransformMethodSignature signature)
-            {
-                return true;
-            }
-        };
-
         ClassTransformation ct = createClassTransformation(SimpleBean.class, 
logger);
 
-        List<TransformMethodSignature> methods = ct.findMethods(filter);
+        List<TransformMethod> methods = ct.matchMethods(F.<TransformMethod> 
notNull());
 
         assertFalse(methods.isEmpty());
 
-        for (TransformMethodSignature sig : methods)
+        for (TransformMethod method : methods)
         {
-            assertFalse(ct.isMethodOverride(sig));
+            assertFalse(method.isOverride());
         }
 
         verify();

Modified: 
tapestry/tapestry5/trunk/tapestry-hibernate/src/main/java/org/apache/tapestry5/internal/hibernate/CommitAfterWorker.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-hibernate/src/main/java/org/apache/tapestry5/internal/hibernate/CommitAfterWorker.java?rev=1076807&r1=1076806&r2=1076807&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-hibernate/src/main/java/org/apache/tapestry5/internal/hibernate/CommitAfterWorker.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-hibernate/src/main/java/org/apache/tapestry5/internal/hibernate/CommitAfterWorker.java
 Thu Mar  3 21:42:19 2011
@@ -1,10 +1,10 @@
-// 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.
 // You may obtain a copy of the License at
 //
-//     http://www.apache.org/licenses/LICENSE-2.0
+// 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,
@@ -21,8 +21,8 @@ import org.apache.tapestry5.services.*;
 
 /**
  * Searches for methods that have the {@link 
org.apache.tapestry5.hibernate.annotations.CommitAfter} annotation and adds
- * logic around the method to commit or abort the transaction.  The 
commit/abort logic is the same as for the {@link
- * org.apache.tapestry5.hibernate.HibernateTransactionDecorator} service.
+ * logic around the method to commit or abort the transaction. The 
commit/abort logic is the same as for the
+ * {@link org.apache.tapestry5.hibernate.HibernateTransactionDecorator} 
service.
  */
 public class CommitAfterWorker implements ComponentClassTransformWorker
 {
@@ -56,9 +56,9 @@ public class CommitAfterWorker implement
 
     public void transform(ClassTransformation transformation, 
MutableComponentModel model)
     {
-        for (TransformMethodSignature sig : 
transformation.findMethodsWithAnnotation(CommitAfter.class))
+        for (TransformMethod method : 
transformation.matchMethodsWithAnnotation(CommitAfter.class))
         {
-            transformation.advise(sig, advice);
+            method.addAdvice(advice);
         }
     }
 }


Reply via email to