You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@openwebbeans.apache.org by James Carman <ja...@carmanconsulting.com> on 2017/05/15 18:28:41 UTC

@Produce a generic type?

I am trying to support this pattern:

@Inject
private JaxrsProxy<HelloResource> helloResource;

I am trying to create a @Produces method that takes in an InjectionPoint to
determine the "HelloResource" type parameter on the field and create a
dynamic proxy using a separate "factory" bean.  Is this pattern even
possible?

Thanks,

James

Re: @Produce a generic type?

Posted by Mark Struberg <st...@yahoo.de>.
Yes see the ConfigExtension and ConfigInjectionBean over here for an example:
https://svn.apache.org/repos/asf/geronimo/components/config/trunk/impl/src/main/java/org/apache/geronimo/config/cdi/

LieGrue,
strub


> Am 16.05.2017 um 08:14 schrieb Lars-Fredrik Smedberg <it...@gmail.com>:
> 
> Hi Mark
> 
> I have done something simiilar, the producer produces @Dependent scope to be able to get the types, annotation attribute values and so on... and then later delegate it to a @RequestScoped bean...
> 
> But your trick sounds very interesting, could you elaborate on what you mean with "And later add Beans for each different InjectionPoint type."?
> 
> Thanks
> 
> Regards
> LF
> 
> On Mon, May 15, 2017 at 10:14 PM, Mark Struberg <st...@yahoo.de> wrote:
> Yes, but only if the producer has a @Dependent scope.
> 
> For other scopes there is a trick by using ProcessInjectionPoint to collect the information. And later add Beans for each different InjectionPoint type.
> 
> LieGrue,
> strub
> 
> > Am 15.05.2017 um 20:28 schrieb James Carman <ja...@carmanconsulting.com>:
> >
> > I am trying to support this pattern:
> >
> > @Inject
> > private JaxrsProxy<HelloResource> helloResource;
> >
> > I am trying to create a @Produces method that takes in an InjectionPoint to determine the "HelloResource" type parameter on the field and create a dynamic proxy using a separate "factory" bean.  Is this pattern even possible?
> >
> > Thanks,
> >
> > James
> >
> 
> 
> 
> 
> -- 
> Med vänlig hälsning / Best regards
> 
> Lars-Fredrik Smedberg
> 
> STATEMENT OF CONFIDENTIALITY:
> The information contained in this electronic message and any
> attachments to this message are intended for the exclusive use of the
> address(es) and may contain confidential or privileged information. If
> you are not the intended recipient, please notify Lars-Fredrik Smedberg
> immediately at itsmeden@gmail.com, and destroy all copies of this 
> message and any attachments.


Re: @Produce a generic type?

Posted by Lars-Fredrik Smedberg <it...@gmail.com>.
Hi Mark

I have done something simiilar, the producer produces @Dependent scope to
be able to get the types, annotation attribute values and so on... and then
later delegate it to a @RequestScoped bean...

But your trick sounds very interesting, could you elaborate on what you
mean with "And later add Beans for each different InjectionPoint type."?

Thanks

Regards
LF

On Mon, May 15, 2017 at 10:14 PM, Mark Struberg <st...@yahoo.de> wrote:

> Yes, but only if the producer has a @Dependent scope.
>
> For other scopes there is a trick by using ProcessInjectionPoint to
> collect the information. And later add Beans for each different
> InjectionPoint type.
>
> LieGrue,
> strub
>
> > Am 15.05.2017 um 20:28 schrieb James Carman <james@carmanconsulting.com
> >:
> >
> > I am trying to support this pattern:
> >
> > @Inject
> > private JaxrsProxy<HelloResource> helloResource;
> >
> > I am trying to create a @Produces method that takes in an InjectionPoint
> to determine the "HelloResource" type parameter on the field and create a
> dynamic proxy using a separate "factory" bean.  Is this pattern even
> possible?
> >
> > Thanks,
> >
> > James
> >
>
>


-- 
Med vänlig hälsning / Best regards

Lars-Fredrik Smedberg

STATEMENT OF CONFIDENTIALITY:
The information contained in this electronic message and any
attachments to this message are intended for the exclusive use of the
address(es) and may contain confidential or privileged information. If
you are not the intended recipient, please notify Lars-Fredrik Smedberg
immediately at itsmeden@gmail.com, and destroy all copies of this
message and any attachments.

Re: @Produce a generic type?

Posted by Mark Struberg <st...@yahoo.de>.
Yes, but only if the producer has a @Dependent scope.

For other scopes there is a trick by using ProcessInjectionPoint to collect the information. And later add Beans for each different InjectionPoint type.

LieGrue,
strub

> Am 15.05.2017 um 20:28 schrieb James Carman <ja...@carmanconsulting.com>:
> 
> I am trying to support this pattern:
> 
> @Inject
> private JaxrsProxy<HelloResource> helloResource;
> 
> I am trying to create a @Produces method that takes in an InjectionPoint to determine the "HelloResource" type parameter on the field and create a dynamic proxy using a separate "factory" bean.  Is this pattern even possible?  
> 
> Thanks,
> 
> James
>