You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "Chunyang, Wang (JIRA)" <ji...@apache.org> on 2009/06/18 10:51:42 UTC

[jira] Created: (WW-3162) Support @ParentPackage inheritance

Support @ParentPackage inheritance
----------------------------------

                 Key: WW-3162
                 URL: https://issues.apache.org/struts/browse/WW-3162
             Project: Struts 2
          Issue Type: New Feature
          Components: Plugin - Convention
            Reporter: Chunyang, Wang


I want to declare an annotation @ParentPackage("app-secure") in supper class, such as BaseSecureAction, so that the sub-classes can use thes ParentPackage and can override ParentPackage if the sub class declare its own one.

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


[jira] Updated: (WW-3162) Support @ParentPackage inheritance

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

Chunyang, Wang updated WW-3162:
-------------------------------


To fix this feature, a proposal for changing method getPackageConfig() in class PackageBasedActionConfigBuilder is as follow.

        // Next grab the parent annotation from the class 
		String parentName = null;
		for (Class<?> clazz : ReflectionTools.getClassHierarchy(actionClass)) {
			ParentPackage parent = AnnotationTools.findAnnotation(clazz, ParentPackage.class);
			if (parent != null) {
				parentName = parent.value();
			}
		}
		if (LOG.isTraceEnabled() && parentName != null) {
			LOG.trace("Using non-default parent package from annotation of [#0]", parentName);
		}


> Support @ParentPackage inheritance
> ----------------------------------
>
>                 Key: WW-3162
>                 URL: https://issues.apache.org/struts/browse/WW-3162
>             Project: Struts 2
>          Issue Type: New Feature
>          Components: Plugin - Convention
>    Affects Versions: 2.1.7
>            Reporter: Chunyang, Wang
>
> I want to declare an annotation @ParentPackage("app-secure") in supper class, such as BaseSecureAction, so that the sub-classes can use thes ParentPackage and can override ParentPackage if the sub class declare its own one.

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


[jira] Updated: (WW-3162) Support @ParentPackage inheritance

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

Chunyang, Wang updated WW-3162:
-------------------------------

    Affects Version/s: 2.1.7

> Support @ParentPackage inheritance
> ----------------------------------
>
>                 Key: WW-3162
>                 URL: https://issues.apache.org/struts/browse/WW-3162
>             Project: Struts 2
>          Issue Type: New Feature
>          Components: Plugin - Convention
>    Affects Versions: 2.1.7
>            Reporter: Chunyang, Wang
>
> I want to declare an annotation @ParentPackage("app-secure") in supper class, such as BaseSecureAction, so that the sub-classes can use thes ParentPackage and can override ParentPackage if the sub class declare its own one.

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


[jira] Resolved: (WW-3162) Support @ParentPackage inheritance

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

Wes Wannemacher resolved WW-3162.
---------------------------------

       Resolution: Fixed
    Fix Version/s: 2.1.8
         Assignee: Wes Wannemacher

good catch, thanks!

> Support @ParentPackage inheritance
> ----------------------------------
>
>                 Key: WW-3162
>                 URL: https://issues.apache.org/struts/browse/WW-3162
>             Project: Struts 2
>          Issue Type: New Feature
>          Components: Plugin - Convention
>    Affects Versions: 2.1.7
>            Reporter: Chunyang, Wang
>            Assignee: Wes Wannemacher
>             Fix For: 2.1.8
>
>
> I want to declare an annotation @ParentPackage("app-secure") in supper class, such as BaseSecureAction, so that the sub-classes can use thes ParentPackage and can override ParentPackage if the sub class declare its own one.

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


[jira] Commented: (WW-3162) Support @ParentPackage inheritance

Posted by "Wes Wannemacher (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/struts/browse/WW-3162?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=46392#action_46392 ] 

Wes Wannemacher commented on WW-3162:
-------------------------------------

Looking through the code, I think it was intended to do so, if you look at the source for AnnotationTools.findAnnotation - 
public static <T extends Annotation> T findAnnotation(Class<?> klass, Class<T> annotationClass) {
        T ann = klass.getAnnotation(annotationClass);
        while (ann == null && klass != null) {
            ann = klass.getAnnotation(annotationClass);
            if (ann == null)
                ann = klass.getPackage().getAnnotation(annotationClass);
            if (ann == null) {
-->                klass = klass.getSuperclass();
            }
        }

        return ann;
    }

Where I put the arrow seems like a bug. The super class is gotten, but 'ann' is not assigned. I will make the change and hopefully you'll have a fix by 2.1.7, but since it changes behavior, there may be objections.

> Support @ParentPackage inheritance
> ----------------------------------
>
>                 Key: WW-3162
>                 URL: https://issues.apache.org/struts/browse/WW-3162
>             Project: Struts 2
>          Issue Type: New Feature
>          Components: Plugin - Convention
>    Affects Versions: 2.1.7
>            Reporter: Chunyang, Wang
>
> I want to declare an annotation @ParentPackage("app-secure") in supper class, such as BaseSecureAction, so that the sub-classes can use thes ParentPackage and can override ParentPackage if the sub class declare its own one.

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