-
1. Re: provider from beanmanager
gavin.king Dec 1, 2009 12:01 AM (in response to brackxm)I presume that by
provider
, you mean an instance of Provider<X>. This will work:bm.getReference( bm.resolve( bm.getBeans( new TypeLiteral<Provider<Foo>>() {}, new AnnotationLiteral<SomeQualifier>() {} ) ), Provider.class, bm.createCreationalContext(null) )
It's much, much better to just inject the thing if you can:
@Inject @SomeQualifier Provider<Foo> fooProvider;
Why are you wanting to get it from the BeanManager? Are you writing a portable extension?
-
2. Re: provider from beanmanager
brackxm Dec 1, 2009 10:11 AM (in response to brackxm)Thanks.
Yes, i'm trying to write a portable extension.
I must say, form the javadoc it's not easy to understand the SPI.
Where would you suggest to look for more information? -
3. Re: provider from beanmanager
nickarls Dec 1, 2009 10:33 AM (in response to brackxm)If you'll give some overview of what you are trying to achieve, we might be able to give you more information (and fill in the gap in the docs)
-
4. Re: provider from beanmanager
gavin.king Dec 1, 2009 5:24 PM (in response to brackxm)So why does your portable extension need to obtain a Provider? I can't really think why you would want to do that...
-
5. Re: provider from beanmanager
brackxm Dec 2, 2009 12:54 PM (in response to brackxm)I am trying to write a portable extension for reasteasy.
With a Provider resteasy can get a CDI created instance when it needs one.
Probably the BeanManager could be used each time, but using a Provider seemed easier.I just noticed Jozef Hartinger is going to do JAX-RS integration
(http://www.seamframework.org/Documentation/Seam3Modules) -
6. Re: provider from beanmanager
gavin.king Dec 2, 2009 4:32 PM (in response to brackxm)In a portable extension, I recommend using BeanManager directly. Provider is intended for use in application code.
-
7. Re: provider from beanmanager
brackxm Dec 2, 2009 4:45 PM (in response to brackxm)getReference() returns an object, that's a disadvantage
perhaps you can add that code example to section 16.3 of the reference guice
note that there is a typo: getType() on the type literal is missing
Are there any (example) portable extensions?
-
8. Re: provider from beanmanager
gavin.king Dec 2, 2009 5:17 PM (in response to brackxm)
getReference() returns an object, that's a disadvantageReally? In generic code, you generally work with Object anyway. A JAX-RS resource is just an Object as far as your PE is concerned....