You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "Dan Oxlade (JIRA)" <ji...@apache.org> on 2007/06/04 17:14:27 UTC

[jira] Created: (WW-1964) AnnotationUtils.findRecursively should ignore annotated methods in the superclass that have been overridden

AnnotationUtils.findRecursively should ignore annotated methods in the superclass that have been overridden
-----------------------------------------------------------------------------------------------------------

                 Key: WW-1964
                 URL: https://issues.apache.org/struts/browse/WW-1964
             Project: Struts 2
          Issue Type: Bug
          Components: Actions
    Affects Versions: 2.0.1
         Environment: xp, Apache Tomcat/5.5.17, jvm 1.5.0_10-b03
            Reporter: Dan Oxlade
            Priority: Minor


For a simple case I have written an action that has a method:

@Overrides
@BeforeResult
addActionTargets(....

Because this method is in the superclass and is also annotated BeforeResult there, the method gets invoked twice.
This does not seem appropriate. I've now removed the annotation from the subclass but this is extremely counter intuitive IMO.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Closed: (WW-1964) AnnotationUtils.findRecursively should ignore annotated methods in the superclass that have been overridden

Posted by "Musachy Barroso (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/struts/browse/WW-1964?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Musachy Barroso closed WW-1964.
-------------------------------

    Resolution: Won't Fix

Moved to an XWork ticket.

> AnnotationUtils.findRecursively should ignore annotated methods in the superclass that have been overridden
> -----------------------------------------------------------------------------------------------------------
>
>                 Key: WW-1964
>                 URL: https://issues.apache.org/struts/browse/WW-1964
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Actions
>    Affects Versions: 2.0.1
>         Environment: xp, Apache Tomcat/5.5.17, jvm 1.5.0_10-b03
>            Reporter: Dan Oxlade
>            Assignee: Dan Oxlade
>            Priority: Minor
>
> For a simple case I have written an action that has a method:
> @Overrides
> @BeforeResult
> addActionTargets(....
> Because this method is in the superclass and is also annotated BeforeResult there, the method gets invoked twice.
> This does not seem appropriate. I've now removed the annotation from the subclass but this is extremely counter intuitive IMO.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Work started: (WW-1964) AnnotationUtils.findRecursively should ignore annotated methods in the superclass that have been overridden

Posted by "Dan Oxlade (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/struts/browse/WW-1964?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Work on WW-1964 started by Dan Oxlade.

> AnnotationUtils.findRecursively should ignore annotated methods in the superclass that have been overridden
> -----------------------------------------------------------------------------------------------------------
>
>                 Key: WW-1964
>                 URL: https://issues.apache.org/struts/browse/WW-1964
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Actions
>    Affects Versions: 2.0.1
>         Environment: xp, Apache Tomcat/5.5.17, jvm 1.5.0_10-b03
>            Reporter: Dan Oxlade
>            Assignee: Dan Oxlade
>            Priority: Minor
>
> For a simple case I have written an action that has a method:
> @Overrides
> @BeforeResult
> addActionTargets(....
> Because this method is in the superclass and is also annotated BeforeResult there, the method gets invoked twice.
> This does not seem appropriate. I've now removed the annotation from the subclass but this is extremely counter intuitive IMO.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Work stopped: (WW-1964) AnnotationUtils.findRecursively should ignore annotated methods in the superclass that have been overridden

Posted by "Dan Oxlade (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/struts/browse/WW-1964?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Work on WW-1964 stopped by Dan Oxlade.

> AnnotationUtils.findRecursively should ignore annotated methods in the superclass that have been overridden
> -----------------------------------------------------------------------------------------------------------
>
>                 Key: WW-1964
>                 URL: https://issues.apache.org/struts/browse/WW-1964
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Actions
>    Affects Versions: 2.0.1
>         Environment: xp, Apache Tomcat/5.5.17, jvm 1.5.0_10-b03
>            Reporter: Dan Oxlade
>            Assignee: Dan Oxlade
>            Priority: Minor
>
> For a simple case I have written an action that has a method:
> @Overrides
> @BeforeResult
> addActionTargets(....
> Because this method is in the superclass and is also annotated BeforeResult there, the method gets invoked twice.
> This does not seem appropriate. I've now removed the annotation from the subclass but this is extremely counter intuitive IMO.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Assigned: (WW-1964) AnnotationUtils.findRecursively should ignore annotated methods in the superclass that have been overridden

Posted by "Dan Oxlade (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/struts/browse/WW-1964?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Dan Oxlade reassigned WW-1964:
------------------------------

    Assignee: Rainer Hermanns

> AnnotationUtils.findRecursively should ignore annotated methods in the superclass that have been overridden
> -----------------------------------------------------------------------------------------------------------
>
>                 Key: WW-1964
>                 URL: https://issues.apache.org/struts/browse/WW-1964
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Actions
>    Affects Versions: 2.0.1
>         Environment: xp, Apache Tomcat/5.5.17, jvm 1.5.0_10-b03
>            Reporter: Dan Oxlade
>            Assignee: Rainer Hermanns
>            Priority: Minor
>
> For a simple case I have written an action that has a method:
> @Overrides
> @BeforeResult
> addActionTargets(....
> Because this method is in the superclass and is also annotated BeforeResult there, the method gets invoked twice.
> This does not seem appropriate. I've now removed the annotation from the subclass but this is extremely counter intuitive IMO.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (WW-1964) AnnotationUtils.findRecursively should ignore annotated methods in the superclass that have been overridden

Posted by "Dan Oxlade (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/struts/browse/WW-1964?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Dan Oxlade updated WW-1964:
---------------------------


the following seems more appropriate


	/**
	 * For the given <code>Class</code> get a collection of the the {@link AnnotatedElement}s 
	 * that match the given <code>annotation</code>s or if no <code>annotation</code>s are 
	 * specified then return all of the annotated elements of the given <code>Class</code>. 
	 * Includes only the method level annotations.
	 * 
	 * @param clazz The {@link Class} to inspect
	 * @param annotation the {@link Annotation}s to find
	 * @return A {@link Collection}&lt;{@link AnnotatedElement}&gt; containing all of the
	 *  method {@link AnnotatedElement}s matching the specified {@link Annotation}s
	 */
	public static final Collection<? extends AnnotatedElement> getAnnotatedMethods(Class clazz, Class<? extends Annotation>... annotation){
		Collection<AnnotatedElement> toReturn = new HashSet<AnnotatedElement>();
		
		for(Method m : clazz.getMethods()){
			if( ArrayUtils.isNotEmpty(annotation) && isAnnotatedBy(m,annotation) ){
				toReturn.add(m);
			}else if( ArrayUtils.isEmpty(annotation) && ArrayUtils.isNotEmpty(m.getAnnotations())){
				toReturn.add(m);
			}
		}
		
		return toReturn;
	}

	/**
	 * Varargs version of <code>AnnotatedElement.isAnnotationPresent()</code>
	 * @see AnnotatedElement
	 */
	public static final boolean isAnnotatedBy(AnnotatedElement annotatedElement, Class<? extends Annotation>... annotation) {
		if(ArrayUtils.isEmpty(annotation)) return false;
		
		for( Class<? extends Annotation> c : annotation ){
			if( annotatedElement.isAnnotationPresent(c) ) return true;
		}
		
		return false;
	}

> AnnotationUtils.findRecursively should ignore annotated methods in the superclass that have been overridden
> -----------------------------------------------------------------------------------------------------------
>
>                 Key: WW-1964
>                 URL: https://issues.apache.org/struts/browse/WW-1964
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Actions
>    Affects Versions: 2.0.1
>         Environment: xp, Apache Tomcat/5.5.17, jvm 1.5.0_10-b03
>            Reporter: Dan Oxlade
>            Priority: Minor
>
> For a simple case I have written an action that has a method:
> @Overrides
> @BeforeResult
> addActionTargets(....
> Because this method is in the superclass and is also annotated BeforeResult there, the method gets invoked twice.
> This does not seem appropriate. I've now removed the annotation from the subclass but this is extremely counter intuitive IMO.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (WW-1964) AnnotationUtils.findRecursively should ignore annotated methods in the superclass that have been overridden

Posted by "Dan Oxlade (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/struts/browse/WW-1964?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_41168 ] 

Dan Oxlade commented on WW-1964:
--------------------------------

moved to xwork

> AnnotationUtils.findRecursively should ignore annotated methods in the superclass that have been overridden
> -----------------------------------------------------------------------------------------------------------
>
>                 Key: WW-1964
>                 URL: https://issues.apache.org/struts/browse/WW-1964
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Actions
>    Affects Versions: 2.0.1
>         Environment: xp, Apache Tomcat/5.5.17, jvm 1.5.0_10-b03
>            Reporter: Dan Oxlade
>            Assignee: Dan Oxlade
>            Priority: Minor
>
> For a simple case I have written an action that has a method:
> @Overrides
> @BeforeResult
> addActionTargets(....
> Because this method is in the superclass and is also annotated BeforeResult there, the method gets invoked twice.
> This does not seem appropriate. I've now removed the annotation from the subclass but this is extremely counter intuitive IMO.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Assigned: (WW-1964) AnnotationUtils.findRecursively should ignore annotated methods in the superclass that have been overridden

Posted by "Dan Oxlade (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/struts/browse/WW-1964?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Dan Oxlade reassigned WW-1964:
------------------------------

    Assignee: Dan Oxlade  (was: Rainer Hermanns)

> AnnotationUtils.findRecursively should ignore annotated methods in the superclass that have been overridden
> -----------------------------------------------------------------------------------------------------------
>
>                 Key: WW-1964
>                 URL: https://issues.apache.org/struts/browse/WW-1964
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Actions
>    Affects Versions: 2.0.1
>         Environment: xp, Apache Tomcat/5.5.17, jvm 1.5.0_10-b03
>            Reporter: Dan Oxlade
>            Assignee: Dan Oxlade
>            Priority: Minor
>
> For a simple case I have written an action that has a method:
> @Overrides
> @BeforeResult
> addActionTargets(....
> Because this method is in the superclass and is also annotated BeforeResult there, the method gets invoked twice.
> This does not seem appropriate. I've now removed the annotation from the subclass but this is extremely counter intuitive IMO.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Issue Comment Edited: (WW-1964) AnnotationUtils.findRecursively should ignore annotated methods in the superclass that have been overridden

Posted by "Dan Oxlade (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/struts/browse/WW-1964?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_41168 ] 

Dan Oxlade edited comment on WW-1964 at 6/5/07 7:10 AM:
--------------------------------------------------------

moved to xwork, close me


 was:
moved to xwork

> AnnotationUtils.findRecursively should ignore annotated methods in the superclass that have been overridden
> -----------------------------------------------------------------------------------------------------------
>
>                 Key: WW-1964
>                 URL: https://issues.apache.org/struts/browse/WW-1964
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Actions
>    Affects Versions: 2.0.1
>         Environment: xp, Apache Tomcat/5.5.17, jvm 1.5.0_10-b03
>            Reporter: Dan Oxlade
>            Assignee: Dan Oxlade
>            Priority: Minor
>
> For a simple case I have written an action that has a method:
> @Overrides
> @BeforeResult
> addActionTargets(....
> Because this method is in the superclass and is also annotated BeforeResult there, the method gets invoked twice.
> This does not seem appropriate. I've now removed the annotation from the subclass but this is extremely counter intuitive IMO.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.