[weld-dev] Provided scopes in CDI

Gavin King gavin.king at gmail.com
Thu Mar 4 16:54:33 EST 2010


@New is a pretty specialized thing. It's mainly for writing producer
methods that return instances of a class that is already a bean,
letting you override the metadata specified by the class itself.

On Thu, Mar 4, 2010 at 4:47 PM, Dan Allen <dan.j.allen at gmail.com> wrote:
> On Thu, Mar 4, 2010 at 3:59 PM, Lincoln Baxter, III
> <lincolnbaxter at gmail.com> wrote:
>>
>> Does CDI come out of the box with an equivalent of Spring's "Prototype"
>> scope, which means that wherever injection is requested, a new instance of
>> the class is provided?
>>
>> Is that what
>>
>> @Inject @New MyType instance;
>>
>> would be used for?
>>
>> Could this be simplified by removing the need for @Inject, and requiring
>> only @New?
>
> @New is for getting a @Dependent scoped bean of a bean which has a normal
> scope. So for instance, the bean has @RequestScoped annotation, but you want
> to get a @Dependent scoped instance of it.
> -Dan
>
>>
>> --
>
> Dan Allen
> Senior Software Engineer, Red Hat | Author of Seam in Action
> Registered Linux User #231597
>
> http://mojavelinux.com
> http://mojavelinux.com/seaminaction
> http://www.google.com/profiles/dan.j.allen
>
> _______________________________________________
> weld-dev mailing list
> weld-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/weld-dev
>



-- 
Gavin King
gavin.king at gmail.com
http://in.relation.to/Bloggers/Gavin
http://hibernate.org
http://seamframework.org



More information about the weld-dev mailing list