commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject svn commit: r903157 - in /commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations: ./ handlers/ providers/
Date Tue, 26 Jan 2010 10:29:31 GMT
Author: simonetripodi
Date: Tue Jan 26 10:29:31 2010
New Revision: 903157

URL: http://svn.apache.org/viewvc?rev=903157&view=rev
Log:
the AnnotationRuleProvider is now an abstract class which fields are final
refactored all the already implemented providers
changed handlers implementations
removed @SuppressWarnings("unchecked") thanks to a better generic implementation

Removed:
    commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/providers/AbstractMethodProvider.java
Modified:
    commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/AnnotationRuleProvider.java
    commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/handlers/DefaultLoaderHandler.java
    commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/handlers/MethodHandler.java
    commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/handlers/SetPropertiesLoaderHandler.java
    commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/providers/AttributeCallParamRuleProvider.java
    commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/providers/BeanPropertySetterRuleProvider.java
    commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/providers/CallMethodRuleProvider.java
    commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/providers/CallParamRuleProvider.java
    commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/providers/FactoryCreateRuleProvider.java
    commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/providers/ObjectCreateRuleProvider.java
    commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/providers/PathCallParamRuleProvider.java
    commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/providers/SetNextRuleProvider.java
    commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/providers/SetPropertiesRuleProvider.java
    commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/providers/SetRootRuleProvider.java
    commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/providers/SetTopRuleProvider.java
    commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/providers/StackCallParamRuleProvider.java

Modified: commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/AnnotationRuleProvider.java
URL: http://svn.apache.org/viewvc/commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/AnnotationRuleProvider.java?rev=903157&r1=903156&r2=903157&view=diff
==============================================================================
--- commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/AnnotationRuleProvider.java
(original)
+++ commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/AnnotationRuleProvider.java
Tue Jan 26 10:29:31 2010
@@ -27,7 +27,17 @@
  * @version $Id$
  * @since 2.1
  */
-public interface AnnotationRuleProvider<A extends Annotation, E extends AnnotatedElement,
R extends Rule> {
+public abstract class AnnotationRuleProvider<A extends Annotation, E extends AnnotatedElement,
R extends Rule> {
+
+    /**
+     * The annotation instance reference.
+     */
+    private final A annotation;
+
+    /**
+     * The annotated element reference.
+     */
+    private final E element;
 
     /**
      * Initializes the provider.
@@ -35,7 +45,28 @@
      * @param annotation the annotation instance.
      * @param element the annotated element reference.
      */
-    void init(A annotation, E element);
+    public AnnotationRuleProvider(A annotation, E element) {
+        this.annotation = annotation;
+        this.element = element;
+    }
+
+    /**
+     * Returns the annotation instance.
+     *
+     * @return the annotation instance.
+     */
+    public A getAnnotation() {
+        return this.annotation;
+    }
+
+    /**
+     * Returns the annotation instance.
+     *
+     * @return the annotation instance.
+     */
+    public E getElement() {
+        return this.element;
+    }
 
     /**
      * Provides an instance of {@link Rule}.
@@ -44,6 +75,6 @@
      *
      * @return an instance of {@link Rule}.
      */
-    R get();
+    public abstract R get();
 
 }

Modified: commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/handlers/DefaultLoaderHandler.java
URL: http://svn.apache.org/viewvc/commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/handlers/DefaultLoaderHandler.java?rev=903157&r1=903156&r2=903157&view=diff
==============================================================================
--- commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/handlers/DefaultLoaderHandler.java
(original)
+++ commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/handlers/DefaultLoaderHandler.java
Tue Jan 26 10:29:31 2010
@@ -19,11 +19,11 @@
 import java.lang.annotation.Annotation;
 import java.lang.reflect.AnnotatedElement;
 
-import org.apache.commons.digester.Rule;
 import org.apache.commons.digester.annotations.AnnotationRuleProvider;
 import org.apache.commons.digester.annotations.DigesterLoaderHandler;
 import org.apache.commons.digester.annotations.DigesterRule;
 import org.apache.commons.digester.annotations.FromAnnotationsRuleSet;
+import org.apache.commons.digester.annotations.utils.AnnotationRuleProviderUtils;
 import org.apache.commons.digester.annotations.utils.AnnotationUtils;
 
 /**
@@ -38,19 +38,10 @@
     /**
      * {@inheritDoc}
      */
-    @SuppressWarnings("unchecked")
     public void handle(Annotation annotation, AnnotatedElement element, FromAnnotationsRuleSet
ruleSet) {
         DigesterRule digesterRule = annotation.annotationType().getAnnotation(DigesterRule.class);
-        try {
-            AnnotationRuleProvider<Annotation, AnnotatedElement, Rule> ruleProvider
=
-                (AnnotationRuleProvider<Annotation, AnnotatedElement, Rule>) digesterRule.providedBy().newInstance();
-            ruleProvider.init(annotation, element);
-            ruleSet.addRuleProvider(AnnotationUtils.getAnnotationPattern(annotation), ruleProvider);
-        } catch (Throwable t) {
-            throw new RuntimeException("Impossible to instantiate provider of type '"
-                    + digesterRule.providedBy().getName()
-                    + "', see nested exceptions", t);
-        }
+        ruleSet.addRuleProvider(AnnotationUtils.getAnnotationPattern(annotation),
+                AnnotationRuleProviderUtils.newProvider(digesterRule.providedBy(), annotation,
element));
     }
 
 }

Modified: commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/handlers/MethodHandler.java
URL: http://svn.apache.org/viewvc/commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/handlers/MethodHandler.java?rev=903157&r1=903156&r2=903157&view=diff
==============================================================================
--- commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/handlers/MethodHandler.java
(original)
+++ commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/handlers/MethodHandler.java
Tue Jan 26 10:29:31 2010
@@ -17,18 +17,16 @@
 package org.apache.commons.digester.annotations.handlers;
 
 import java.lang.annotation.Annotation;
-import java.lang.reflect.AnnotatedElement;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
 
-import org.apache.commons.digester.Rule;
-import org.apache.commons.digester.annotations.AnnotationRuleProvider;
 import org.apache.commons.digester.annotations.CreationRule;
 import org.apache.commons.digester.annotations.DigesterLoader;
 import org.apache.commons.digester.annotations.DigesterLoaderHandler;
 import org.apache.commons.digester.annotations.DigesterRule;
 import org.apache.commons.digester.annotations.DigesterRuleList;
 import org.apache.commons.digester.annotations.FromAnnotationsRuleSet;
+import org.apache.commons.digester.annotations.utils.AnnotationRuleProviderUtils;
 import org.apache.commons.digester.annotations.utils.AnnotationUtils;
 
 /**
@@ -91,17 +89,14 @@
         }
     }
 
-    /**
-     * 
-     *
-     * @param method
-     * @param type
-     * @param ruleSet
-     */
     private void doHandle(Annotation methodAnnotation, Method method, Class<?> type,
FromAnnotationsRuleSet ruleSet) {
         if (type.isInterface()
                 && Modifier.isAbstract(type.getModifiers())) {
-            throw new IllegalArgumentException("");
+            throw new IllegalArgumentException("Impossible to proceed analyzing "
+                    + methodAnnotation
+                    + ", specified type '"
+                    + type.getName()
+                    + "' is an interface/abstract");
         }
 
         for (Annotation annotation : type.getAnnotations()) {
@@ -109,31 +104,15 @@
         }
     }
 
-    /**
-     * 
-     *
-     * @param annotation
-     * @param method
-     * @param type
-     * @param ruleSet
-     */
-    @SuppressWarnings("unchecked")
     private void doHandle(Annotation methodAnnotation, Annotation annotation, Method method,
Class<?> type, FromAnnotationsRuleSet ruleSet) {
         if (annotation.annotationType().isAnnotationPresent(DigesterRule.class)
                 && annotation.annotationType().isAnnotationPresent(CreationRule.class))
{
             DigesterLoader.addRules(type, ruleSet);
 
             DigesterRule digesterRule = methodAnnotation.annotationType().getAnnotation(DigesterRule.class);
-            try {
-                AnnotationRuleProvider<Annotation, AnnotatedElement, Rule> ruleProvider
=
-                    (AnnotationRuleProvider<Annotation, AnnotatedElement, Rule>) digesterRule.providedBy().newInstance();
-                ruleProvider.init(annotation, method);
-                ruleSet.addRuleProvider(AnnotationUtils.getAnnotationPattern(annotation),
ruleProvider);
-            } catch (Throwable t) {
-                throw new RuntimeException("Impossible to instantiate provider of type '"
-                        + digesterRule.providedBy().getName()
-                        + "', see nested exceptions", t);
-            }
+
+            ruleSet.addRuleProvider(AnnotationUtils.getAnnotationPattern(annotation),
+                    AnnotationRuleProviderUtils.newProvider(digesterRule.providedBy(), methodAnnotation,
method));
         } else if (annotation.annotationType().isAnnotationPresent(DigesterRuleList.class))
{
             // check if it is one of the *.List annotation
             Annotation[] annotations = AnnotationUtils.getAnnotationsArrayValue(annotation);

Modified: commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/handlers/SetPropertiesLoaderHandler.java
URL: http://svn.apache.org/viewvc/commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/handlers/SetPropertiesLoaderHandler.java?rev=903157&r1=903156&r2=903157&view=diff
==============================================================================
--- commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/handlers/SetPropertiesLoaderHandler.java
(original)
+++ commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/handlers/SetPropertiesLoaderHandler.java
Tue Jan 26 10:29:31 2010
@@ -38,7 +38,7 @@
         SetPropertiesRuleProvider ruleProvider = ruleSet.getProvider(annotation.pattern(),
SetPropertiesRuleProvider.class);
 
         if (ruleProvider == null) {
-            ruleProvider = new SetPropertiesRuleProvider();
+            ruleProvider = new SetPropertiesRuleProvider(annotation, element);
             ruleSet.addRuleProvider(annotation.pattern(), ruleProvider);
         }
 

Modified: commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/providers/AttributeCallParamRuleProvider.java
URL: http://svn.apache.org/viewvc/commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/providers/AttributeCallParamRuleProvider.java?rev=903157&r1=903156&r2=903157&view=diff
==============================================================================
--- commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/providers/AttributeCallParamRuleProvider.java
(original)
+++ commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/providers/AttributeCallParamRuleProvider.java
Tue Jan 26 10:29:31 2010
@@ -28,31 +28,25 @@
  * @version $Id$
  * @since 2.1
  */
-public final class AttributeCallParamRuleProvider implements AnnotationRuleProvider<AttributeCallParam,
MethodArgument, CallParamRule> {
+public final class AttributeCallParamRuleProvider extends AnnotationRuleProvider<AttributeCallParam,
MethodArgument, CallParamRule> {
 
     /**
-     * The parameter index.
+     * Creates a new provider of {@link CallParamRule} rule.
+     *
+     * @param annotation the annotation instance.
+     * @param element the annotated element reference.
      */
-    private int paramIndex;
-
-    /**
-     * The attribute name.
-     */
-    private String attributeName;
-
-    /**
-     * {@inheritDoc}
-     */
-    public void init(AttributeCallParam annotation, MethodArgument element) {
-        this.paramIndex = element.getIndex();
-        this.attributeName = annotation.attribute();
+    public AttributeCallParamRuleProvider(AttributeCallParam annotation,
+            MethodArgument element) {
+        super(annotation, element);
     }
 
     /**
      * {@inheritDoc}
      */
     public CallParamRule get() {
-        return new CallParamRule(this.paramIndex, this.attributeName);
+        return new CallParamRule(this.getElement().getIndex(),
+                this.getAnnotation().attribute());
     }
 
 }

Modified: commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/providers/BeanPropertySetterRuleProvider.java
URL: http://svn.apache.org/viewvc/commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/providers/BeanPropertySetterRuleProvider.java?rev=903157&r1=903156&r2=903157&view=diff
==============================================================================
--- commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/providers/BeanPropertySetterRuleProvider.java
(original)
+++ commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/providers/BeanPropertySetterRuleProvider.java
Tue Jan 26 10:29:31 2010
@@ -28,25 +28,24 @@
  * @version $Id$
  * @since 2.1
  */
-public final class BeanPropertySetterRuleProvider implements AnnotationRuleProvider<BeanPropertySetter,
Field, BeanPropertySetterRule> {
+public final class BeanPropertySetterRuleProvider extends AnnotationRuleProvider<BeanPropertySetter,
Field, BeanPropertySetterRule> {
 
     /**
-     * The property name reference.
+     * Creates a new provider of {@link BeanPropertySetterRule} rule.
+     *
+     * @param annotation the annotation instance.
+     * @param element the annotated element reference.
      */
-    private String propertyName;
-
-    /**
-     * {@inheritDoc}
-     */
-    public void init(BeanPropertySetter annotation, Field element) {
-        this.propertyName = element.getName();
+    public BeanPropertySetterRuleProvider(BeanPropertySetter annotation,
+            Field element) {
+        super(annotation, element);
     }
 
     /**
      * {@inheritDoc}
      */
     public BeanPropertySetterRule get() {
-        return new BeanPropertySetterRule(this.propertyName);
+        return new BeanPropertySetterRule(this.getElement().getName());
     }
 
 }

Modified: commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/providers/CallMethodRuleProvider.java
URL: http://svn.apache.org/viewvc/commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/providers/CallMethodRuleProvider.java?rev=903157&r1=903156&r2=903157&view=diff
==============================================================================
--- commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/providers/CallMethodRuleProvider.java
(original)
+++ commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/providers/CallMethodRuleProvider.java
Tue Jan 26 10:29:31 2010
@@ -28,31 +28,25 @@
  * @version $Id$
  * @since 2.1
  */
-public final class CallMethodRuleProvider implements AnnotationRuleProvider<CallMethod,
Method, CallMethodRule> {
+public final class CallMethodRuleProvider extends AnnotationRuleProvider<CallMethod, Method,
CallMethodRule> {
 
     /**
-     * The method name.
+     * Creates a new provider of {@link CallMethodRule} rule.
+     *
+     * @param annotation the annotation instance.
+     * @param element the annotated element reference.
      */
-    private String methodName;
-
-    /**
-     * The parameters types.
-     */
-    private Class<?>[] paramTypes;
-
-    /**
-     * {@inheritDoc}
-     */
-    public void init(CallMethod annotation, Method element) {
-        this.methodName = element.getName();
-        this.paramTypes = element.getParameterTypes();
+    public CallMethodRuleProvider(CallMethod annotation, Method element) {
+        super(annotation, element);
     }
 
     /**
      * {@inheritDoc}
      */
     public CallMethodRule get() {
-        return new CallMethodRule(this.methodName, this.paramTypes.length, this.paramTypes);
+        return new CallMethodRule(this.getElement().getName(),
+                this.getElement().getParameterTypes().length,
+                this.getElement().getParameterTypes());
     }
 
 }

Modified: commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/providers/CallParamRuleProvider.java
URL: http://svn.apache.org/viewvc/commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/providers/CallParamRuleProvider.java?rev=903157&r1=903156&r2=903157&view=diff
==============================================================================
--- commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/providers/CallParamRuleProvider.java
(original)
+++ commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/providers/CallParamRuleProvider.java
Tue Jan 26 10:29:31 2010
@@ -28,25 +28,23 @@
  * @version $Id$
  * @since 2.1
  */
-public final class CallParamRuleProvider implements AnnotationRuleProvider<CallParam,
MethodArgument, CallParamRule> {
+public final class CallParamRuleProvider extends AnnotationRuleProvider<CallParam, MethodArgument,
CallParamRule> {
 
     /**
-     * The parameter index.
+     * Creates a new provider of {@link CallParamRule} rule.
+     *
+     * @param annotation the annotation instance.
+     * @param element the annotated element reference.
      */
-    private int paramIndex;
-
-    /**
-     * {@inheritDoc}
-     */
-    public void init(CallParam annotation, MethodArgument element) {
-        this.paramIndex = element.getIndex();
+    public CallParamRuleProvider(CallParam annotation, MethodArgument element) {
+        super(annotation, element);
     }
 
     /**
      * {@inheritDoc}
      */
     public CallParamRule get() {
-        return new CallParamRule(this.paramIndex);
+        return new CallParamRule(this.getElement().getIndex());
     }
 
 }

Modified: commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/providers/FactoryCreateRuleProvider.java
URL: http://svn.apache.org/viewvc/commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/providers/FactoryCreateRuleProvider.java?rev=903157&r1=903156&r2=903157&view=diff
==============================================================================
--- commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/providers/FactoryCreateRuleProvider.java
(original)
+++ commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/providers/FactoryCreateRuleProvider.java
Tue Jan 26 10:29:31 2010
@@ -26,31 +26,24 @@
  * @version $Id$
  * @since 2.1
  */
-public final class FactoryCreateRuleProvider implements AnnotationRuleProvider<FactoryCreate,
Class<?>, FactoryCreateRule> {
+public final class FactoryCreateRuleProvider extends AnnotationRuleProvider<FactoryCreate,
Class<?>, FactoryCreateRule> {
 
     /**
-     * The factory class reference.
+     * Creates a new provider of {@link FactoryCreateRule} rule.
+     *
+     * @param annotation the annotation instance.
+     * @param element the annotated element reference.
      */
-    private Class<?> factoryClass;
-
-    /**
-     * if true, exceptions thrown by the object creation factory will be ignored
-     */
-    private boolean ignoreCreateExceptions;
-
-    /**
-     * {@inheritDoc}
-     */
-    public void init(FactoryCreate annotation, Class<?> element) {
-        this.factoryClass = annotation.factoryClass();
-        this.ignoreCreateExceptions = annotation.ignoreCreateExceptions();
+    public FactoryCreateRuleProvider(FactoryCreate annotation, Class<?> element) {
+        super(annotation, element);
     }
 
     /**
      * {@inheritDoc}
      */
     public FactoryCreateRule get() {
-        return new FactoryCreateRule(this.factoryClass, this.ignoreCreateExceptions);
+        return new FactoryCreateRule(this.getAnnotation().factoryClass(),
+                this.getAnnotation().ignoreCreateExceptions());
     }
 
 }

Modified: commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/providers/ObjectCreateRuleProvider.java
URL: http://svn.apache.org/viewvc/commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/providers/ObjectCreateRuleProvider.java?rev=903157&r1=903156&r2=903157&view=diff
==============================================================================
--- commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/providers/ObjectCreateRuleProvider.java
(original)
+++ commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/providers/ObjectCreateRuleProvider.java
Tue Jan 26 10:29:31 2010
@@ -26,25 +26,23 @@
  * @version $Id$
  * @since 2.1
  */
-public final class ObjectCreateRuleProvider implements AnnotationRuleProvider<ObjectCreate,
Class<?>, ObjectCreateRule> {
+public final class ObjectCreateRuleProvider extends AnnotationRuleProvider<ObjectCreate,
Class<?>, ObjectCreateRule> {
 
     /**
-     * Java class of the object to be created.
+     * Creates a new provider of {@link ObjectCreateRule} rule.
+     *
+     * @param annotation the annotation instance.
+     * @param element the annotated element reference.
      */
-    private Class<?> type;
-
-    /**
-     * {@inheritDoc}
-     */
-    public void init(ObjectCreate annotation, Class<?> element) {
-        this.type = element;
+    public ObjectCreateRuleProvider(ObjectCreate annotation, Class<?> element) {
+        super(annotation, element);
     }
 
     /**
      * {@inheritDoc}
      */
     public ObjectCreateRule get() {
-        return new ObjectCreateRule(this.type);
+        return new ObjectCreateRule(this.getElement());
     }
 
 }

Modified: commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/providers/PathCallParamRuleProvider.java
URL: http://svn.apache.org/viewvc/commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/providers/PathCallParamRuleProvider.java?rev=903157&r1=903156&r2=903157&view=diff
==============================================================================
--- commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/providers/PathCallParamRuleProvider.java
(original)
+++ commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/providers/PathCallParamRuleProvider.java
Tue Jan 26 10:29:31 2010
@@ -27,25 +27,24 @@
  * @version $Id$
  * @since 2.1
  */
-public final class PathCallParamRuleProvider implements AnnotationRuleProvider<PathCallParam,
MethodArgument, PathCallParamRule> {
+public final class PathCallParamRuleProvider extends AnnotationRuleProvider<PathCallParam,
MethodArgument, PathCallParamRule> {
 
     /**
-     * The parameter index.
+     * Creates a new provider of {@link PathCallParamRule} rule.
+     *
+     * @param annotation the annotation instance.
+     * @param element the annotated element reference.
      */
-    private int paramIndex;
-
-    /**
-     * {@inheritDoc}
-     */
-    public void init(PathCallParam annotation, MethodArgument element) {
-        this.paramIndex = element.getIndex();
+    public PathCallParamRuleProvider(PathCallParam annotation,
+            MethodArgument element) {
+        super(annotation, element);
     }
 
     /**
      * {@inheritDoc}
      */
     public PathCallParamRule get() {
-        return new PathCallParamRule(this.paramIndex);
+        return new PathCallParamRule(this.getElement().getIndex());
     }
 
 }

Modified: commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/providers/SetNextRuleProvider.java
URL: http://svn.apache.org/viewvc/commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/providers/SetNextRuleProvider.java?rev=903157&r1=903156&r2=903157&view=diff
==============================================================================
--- commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/providers/SetNextRuleProvider.java
(original)
+++ commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/providers/SetNextRuleProvider.java
Tue Jan 26 10:29:31 2010
@@ -16,7 +16,10 @@
  */
 package org.apache.commons.digester.annotations.providers;
 
+import java.lang.reflect.Method;
+
 import org.apache.commons.digester.SetNextRule;
+import org.apache.commons.digester.annotations.AnnotationRuleProvider;
 import org.apache.commons.digester.annotations.SetNext;
 
 /**
@@ -25,13 +28,24 @@
  * @version $Id$
  * @since 2.1
  */
-public final class SetNextRuleProvider extends AbstractMethodProvider<SetNext, SetNextRule>{
+public final class SetNextRuleProvider extends AnnotationRuleProvider<SetNext, Method,
SetNextRule> {
+
+    /**
+     * Creates a new provider of {@link SetNextRule} rule.
+     *
+     * @param annotation the annotation instance.
+     * @param element the annotated element reference.
+     */
+    public SetNextRuleProvider(SetNext annotation, Method element) {
+        super(annotation, element);
+    }
 
     /**
      * {@inheritDoc}
      */
     public SetNextRule get() {
-        return new SetNextRule(this.getMethodName(), this.getParamType());
+        return new SetNextRule(this.getElement().getName(),
+                this.getElement().getParameterTypes()[0].getName());
     }
 
 }

Modified: commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/providers/SetPropertiesRuleProvider.java
URL: http://svn.apache.org/viewvc/commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/providers/SetPropertiesRuleProvider.java?rev=903157&r1=903156&r2=903157&view=diff
==============================================================================
--- commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/providers/SetPropertiesRuleProvider.java
(original)
+++ commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/providers/SetPropertiesRuleProvider.java
Tue Jan 26 10:29:31 2010
@@ -31,7 +31,7 @@
  * @version $Id$
  * @since 2.1
  */
-public final class SetPropertiesRuleProvider implements AnnotationRuleProvider<SetProperty,
Field, SetPropertiesRule> {
+public final class SetPropertiesRuleProvider extends AnnotationRuleProvider<SetProperty,
Field, SetPropertiesRule> {
 
     /**
      * The data structure that stores the aliases.
@@ -39,9 +39,13 @@
     private final Map<String, String> aliases = new HashMap<String, String>();
 
     /**
-     * {@inheritDoc}
+     * Creates a new provider of {@link SetPropertiesRule} rule.
+     *
+     * @param annotation the annotation instance.
+     * @param element the annotated element reference.
      */
-    public void init(SetProperty annotation, Field element) {
+    public SetPropertiesRuleProvider(SetProperty annotation, Field element) {
+        super(annotation, element);
         this.addAlias(annotation, element);
     }
 

Modified: commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/providers/SetRootRuleProvider.java
URL: http://svn.apache.org/viewvc/commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/providers/SetRootRuleProvider.java?rev=903157&r1=903156&r2=903157&view=diff
==============================================================================
--- commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/providers/SetRootRuleProvider.java
(original)
+++ commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/providers/SetRootRuleProvider.java
Tue Jan 26 10:29:31 2010
@@ -16,7 +16,10 @@
  */
 package org.apache.commons.digester.annotations.providers;
 
+import java.lang.reflect.Method;
+
 import org.apache.commons.digester.SetRootRule;
+import org.apache.commons.digester.annotations.AnnotationRuleProvider;
 import org.apache.commons.digester.annotations.SetRoot;
 
 /**
@@ -25,13 +28,24 @@
  * @version $Id$
  * @since 2.1
  */
-public final class SetRootRuleProvider extends AbstractMethodProvider<SetRoot, SetRootRule>{
+public final class SetRootRuleProvider extends AnnotationRuleProvider<SetRoot, Method,
SetRootRule>{
+
+    /**
+     * Creates a new provider of {@link SetRootRule} rule.
+     *
+     * @param annotation the annotation instance.
+     * @param element the annotated element reference.
+     */
+    public SetRootRuleProvider(SetRoot annotation, Method element) {
+        super(annotation, element);
+    }
 
     /**
      * {@inheritDoc}
      */
     public SetRootRule get() {
-        return new SetRootRule(this.getMethodName(), this.getParamType());
+        return new SetRootRule(this.getElement().getName(),
+                this.getElement().getParameterTypes()[0].getName());
     }
 
 }

Modified: commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/providers/SetTopRuleProvider.java
URL: http://svn.apache.org/viewvc/commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/providers/SetTopRuleProvider.java?rev=903157&r1=903156&r2=903157&view=diff
==============================================================================
--- commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/providers/SetTopRuleProvider.java
(original)
+++ commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/providers/SetTopRuleProvider.java
Tue Jan 26 10:29:31 2010
@@ -16,7 +16,10 @@
  */
 package org.apache.commons.digester.annotations.providers;
 
+import java.lang.reflect.Method;
+
 import org.apache.commons.digester.SetTopRule;
+import org.apache.commons.digester.annotations.AnnotationRuleProvider;
 import org.apache.commons.digester.annotations.SetTop;
 
 /**
@@ -25,13 +28,24 @@
  * @version $Id$
  * @since 2.1
  */
-public final class SetTopRuleProvider extends AbstractMethodProvider<SetTop, SetTopRule>{
+public final class SetTopRuleProvider extends AnnotationRuleProvider<SetTop, Method, SetTopRule>{
+
+    /**
+     * Creates a new provider of {@link SetTopRule} rule.
+     *
+     * @param annotation the annotation instance.
+     * @param element the annotated element reference.
+     */
+    public SetTopRuleProvider(SetTop annotation, Method element) {
+        super(annotation, element);
+    }
 
     /**
      * {@inheritDoc}
      */
     public SetTopRule get() {
-        return new SetTopRule(this.getMethodName(), this.getParamType());
+        return new SetTopRule(this.getElement().getName(),
+                this.getElement().getParameterTypes()[0].getName());
     }
 
 }

Modified: commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/providers/StackCallParamRuleProvider.java
URL: http://svn.apache.org/viewvc/commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/providers/StackCallParamRuleProvider.java?rev=903157&r1=903156&r2=903157&view=diff
==============================================================================
--- commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/providers/StackCallParamRuleProvider.java
(original)
+++ commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/providers/StackCallParamRuleProvider.java
Tue Jan 26 10:29:31 2010
@@ -28,31 +28,24 @@
  * @version $Id$
  * @since 2.1
  */
-public final class StackCallParamRuleProvider implements AnnotationRuleProvider<StackCallParam,
MethodArgument, CallParamRule> {
+public final class StackCallParamRuleProvider extends AnnotationRuleProvider<StackCallParam,
MethodArgument, CallParamRule> {
 
     /**
-     * The parameter index.
+     * Creates a new provider of {@link CallParamRule} rule.
+     *
+     * @param annotation the annotation instance.
+     * @param element the annotated element reference.
      */
-    private int paramIndex;
-
-    /**
-     * The stack index.
-     */
-    private int stackIndex;
-
-    /**
-     * {@inheritDoc}
-     */
-    public void init(StackCallParam annotation, MethodArgument element) {
-        this.paramIndex = element.getIndex();
-        this.stackIndex = annotation.stackIndex();
+    public StackCallParamRuleProvider(StackCallParam annotation,
+            MethodArgument element) {
+        super(annotation, element);
     }
 
     /**
      * {@inheritDoc}
      */
     public CallParamRule get() {
-        return new CallParamRule(this.paramIndex, this.stackIndex);
+        return new CallParamRule(this.getElement().getIndex(), this.getAnnotation().stackIndex());
     }
 
 }



Mime
View raw message