[ 
https://issues.apache.org/jira/browse/OWB-1416?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17627549#comment-17627549
 ] 

Alexander Larsen commented on OWB-1416:
---------------------------------------

Thanks for the rapid reply!

I'm not sure i entirely understand the answer. A bean has a set of types, and 
the default set of types include all the implemented types of a (managed) bean. 
This set of types can be restricted with {{@Typed}}, but this does not solve 
the problem for OWB anyways, since the deployment validation service will stil 
throw Unproxyable-exception, even though if the bean is annotated with 
{{@Typed(SomeInterface.class)}}

Example that currently isn't working with OWB:

{code:java}
public interface FooService {
    int getFoo();
}
{code}

{code:java}
@ApplicationScoped
//@Typed(FooService.class) makes no difference, still getting 
Unproxiable-exception
class FooServiceImpl implements FooService {
    private final BeanManager bm;  // example dependency

    @Inject
    FooServiceImpl(BeanManager bm) {
        this.bm = bm;
    }

    public final int getFoo() { return 42; }
}
{code}

{code:java}
@ApplicationScoped
public class SomeConsumerBean {
    @Inject
    private FooService fooService;
}
{code}

There should not be a problem injecting a {{FooService}}-proxy in the consumer 
bean, since this proxy does not need to subclass/implement {{FooServiceImpl}}

> Possible misintepretation of spec regarding Unproxyable bean types
> ------------------------------------------------------------------
>
>                 Key: OWB-1416
>                 URL: https://issues.apache.org/jira/browse/OWB-1416
>             Project: OpenWebBeans
>          Issue Type: Bug
>            Reporter: Alexander Larsen
>            Priority: Major
>
> OWB seems to throw an exception for all unproxyable normal scoped beans. I 
> think that this might be incorrect.
> The 
> [specification|https://docs.jboss.org/cdi/spec/2.0/cdi-spec.html#unproxyable] 
> says the "A bean type must be proxyable if an injection point resolves to a 
> bean", not that all the types of the bean must be proxyable. In other words, 
> as long as the bean is a legal bean, and all injection point resolving to 
> this bean is a proxyable type - no exception should be thrown.
> In the part about [contextual 
> references|https://docs.jboss.org/cdi/spec/2.0/cdi-spec.html#contextual_reference],
>  there is further indications that unproxyable types should be allowed in the 
> set of types for the bean. It's only when you try to get a reference(injected 
> or by bean manager) to an unproxyable type, and the bean must be proxied 
> (normal scoped, intercepted or decorated) an exception should thrown.
> Also, the [Weld user guide suggests introducing an interface as a solution to 
> having an unproxyable 
> bean|https://docs.jboss.org/weld/reference/latest/en-US/html_single/#_client_proxies].
> The current OWB implementation makes a pattern of having an interface and 
> (one or more) implementation class with final fields/methods somewhat 
> difficult :)



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to