[cdi-dev] [JBoss JIRA] (CDI-481) Introduce AnnotatedParameter.getJavaParameter()

Romain Manni-Bucau (JIRA) issues at jboss.org
Thu Sep 18 13:54:02 EDT 2014


    [ https://issues.jboss.org/browse/CDI-481?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13004040#comment-13004040 ] 

Romain Manni-Bucau edited comment on CDI-481 at 9/18/14 1:53 PM:
-----------------------------------------------------------------

Yep. If you think to an extension allowing kind of dynamic calls it can use then names instead of index or type (which are not enough). For instance:

{code}
@PreSecurity("authenticator.login(username, password)
public Data getSensitiveData() {
  // ...
}

// ...

@Named
public class Authenticator {
    public boolean login(@Parameter("username") String user, @Parameter("password")  String pwd) {
        return true; 
    }
}
{code}


was (Author: rmannibucau):
Yep. If you think to an extension allowing kind of dynamic calls it can use then names instead of index or type (which are not enough). For instance:

{code}
@PreSecurity("authenticator.login(username, password)
public Data getSensitiveData() {
  // ...
}

// ...

@Named
public class Authenticator {
    public boolean login(String user, String pwd) {
        return true; 
    }
}
{code}

> Introduce AnnotatedParameter.getJavaParameter()
> -----------------------------------------------
>
>                 Key: CDI-481
>                 URL: https://issues.jboss.org/browse/CDI-481
>             Project: CDI Specification Issues
>          Issue Type: Feature Request
>          Components: Portable Extensions
>            Reporter: Jozef Hartinger
>
> Make it possible to obtain the Java Reflection object representing the parameter. This is in line with
> AnnotatedField.getJavaMember()
> AnnotatedMethod.getJavaMember()
> AnnotatedConstructor.getJavaMember()
> Can be implemented as a default method such as:
> {code:JAVA}
> default Parameter getJavaParameter() {
>         Member member = getDeclaringCallable().getJavaMember();
>         if (!(member instanceof Executable)) {
>             throw new IllegalStateException("Parameter does not belong to an executable " + member);
>         }
>         Executable executable = (Executable) member;
>         return executable.getParameters()[getPosition()];
>     }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.1#6329)


More information about the cdi-dev mailing list