[cdi-dev] [JBoss JIRA] (CDI-670) Clarify InterceptionFactory.ignoreFinalMethods() purpose and functioning

Martin Kouba (JIRA) issues at jboss.org
Thu Dec 15 03:49:00 EST 2016


     [ https://issues.jboss.org/browse/CDI-670?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Martin Kouba updated CDI-670:
-----------------------------
    Description: 
It should be clear that {{InterceptionFactory.ignoreFinalMethods()}} only affects the generation of the "proxy" which enables interception. E.g. the following example would FAIL during validation of {{myFoo}} injection point (bootstrap):

{code:java}
 @Inject
 Foo myFoo;

 @Produces
 @RequestScoped // -> Requires a client proxy
 public Foo produce(InterceptionFactory<Foo> interceptionFactory) {
        // Suppose Foo has a final method
        return interceptionFactory.ignoreFinalMethods().createInterceptedInstance(new Foo());
  }
{code}

The reason is that the CDI container must treat the producer as a deployment problem (unless {{javax.enterprise.inject.spi.ProcessBeanAttributes.ignoreFinalMethods()}} is used for the producer method).

I understand that it's not very intuitive. On the other hand, these are two different concepts. I.e. the *injection point validation happens during bootstrap* while the {{InterceptionFactory}} *is used at runtime*.

  was:
It should be clear that {{InterceptionFactory.ignoreFinalMethods()}} only affects the generation of the "proxy" which enables interception. E.g. the following example would FAIL during validation of {{myFoo}} injection point (bootstrap):

{code:java}
 @Inject
 Foo myFoo;

 @Produces
 @RequestScoped // -> Requires a client proxy
 public Foo produce(InterceptionFactory<Foo> interceptionFactory) {
        // Suppose Foo has a final method
        return interceptionFactory.ignoreFinalMethods().createInterceptedInstance(new FinalProduct());
  }
{code}

The reason is that the CDI container must treat the producer as a deployment problem (unless {{javax.enterprise.inject.spi.ProcessBeanAttributes.ignoreFinalMethods()}} is used for the producer method).

I understand that it's not very intuitive. On the other hand, these are two different concepts. I.e. the *injection point validation happens during bootstrap* while the {{InterceptionFactory}} *is used at runtime*.



> Clarify InterceptionFactory.ignoreFinalMethods() purpose and functioning
> ------------------------------------------------------------------------
>
>                 Key: CDI-670
>                 URL: https://issues.jboss.org/browse/CDI-670
>             Project: CDI Specification Issues
>          Issue Type: Clarification
>            Reporter: Martin Kouba
>            Priority: Critical
>             Fix For: 2.0 .Final
>
>
> It should be clear that {{InterceptionFactory.ignoreFinalMethods()}} only affects the generation of the "proxy" which enables interception. E.g. the following example would FAIL during validation of {{myFoo}} injection point (bootstrap):
> {code:java}
>  @Inject
>  Foo myFoo;
>  @Produces
>  @RequestScoped // -> Requires a client proxy
>  public Foo produce(InterceptionFactory<Foo> interceptionFactory) {
>         // Suppose Foo has a final method
>         return interceptionFactory.ignoreFinalMethods().createInterceptedInstance(new Foo());
>   }
> {code}
> The reason is that the CDI container must treat the producer as a deployment problem (unless {{javax.enterprise.inject.spi.ProcessBeanAttributes.ignoreFinalMethods()}} is used for the producer method).
> I understand that it's not very intuitive. On the other hand, these are two different concepts. I.e. the *injection point validation happens during bootstrap* while the {{InterceptionFactory}} *is used at runtime*.



--
This message was sent by Atlassian JIRA
(v7.2.3#72005)


More information about the cdi-dev mailing list