On 22 Jul 2009, at 01:17, Peter Royle wrote:
>> You just use the manager to create a CreationalContext for
the bean.
>>
>> beanManager.createCreationalContext(bean)
>>
Sounds like just what I need, thanks.
> You should always use the same creational context for the lifecycle
> of
> the bean instance (for creation and destruction) otherwise generate a
> new one.
I'm only going to generate the bean once during the life of the app
(it's @ApplicationScoped). IIUC, thereafter the CreationalContext
should
be ignored.
Yes.
Now, is the CreationalContext then stored with the bean instance and
used for destruction automatically (seems that way in
AbstractMapContext.destroy(Contexual) )?
Yes, if you just clean up the context (either manually via the yet-to-
be-defined WB SPI [1] or automatically via the ServletListener) then
WB takes care of using the correct creationalContext for destroying
the bean.
[1] Currently you have to use calls against the impl for this
Thanks,
Pete.
>
> On 21 Jul 2009, at 16:18, Dan Allen wrote:
>
>> On Tue, Jul 21, 2009 at 10:50 AM, Peter Royle <howardmoon(a)screamingcoder.com
>>> wrote:
>> Sorry to drag this up again, but this has changed now that
>> manager.getReference(...) requires a CreationalContext, about
>> which I
>> know very little. I'll try reading the latest spec soon, but in the
>> meantime if anyone has any silver bullets please let me know.
>>
>> I'm currently using this utility method:
>>
>> public static <T> T getInstanceByType(BeanManager manager,
>> Class<T> type, Annotation... bindings) {
>> return (T)manager.getReference(
>> manager.getBeans(type).iterator().next(), type,
>> null);
>> }
>>
>> Obviously it's that null at the end (where CreationalContext should
>> be) that's causing the problem.
>>
>> You just use the manager to create a CreationalContext for the bean.
>>
>> beanManager.createCreationalContext(bean)
>>
>> If an instance already exists, the CreationalContext is not used.
>> Someone correct me if I am wrong.
>>
>> -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://in.relation.to/Bloggers/Dan
>> _______________________________________________
>> webbeans-dev mailing list
>> webbeans-dev(a)lists.jboss.org
>>
https://lists.jboss.org/mailman/listinfo/webbeans-dev
>