[weld-dev] BeanManager.getReference() VS Context.get()
Muhammad Bhutto
muhammad.bhutto at gmail.com
Wed Nov 20 07:54:28 EST 2013
Hi Struberg,
Thanks for your help, I really appreciate it and it is very helpful for me.
Regards,
Muhammad Bhutto
On Wed, Nov 20, 2013 at 1:45 PM, Mark Struberg <struberg at yahoo.de> wrote:
> .) BeanManager#getReference will return you a 'Contextual Reference',
> means a normalscoping proxy for the bean. If you have a @SessionScoped User
> usr; then the Contextual Reference usr will 'point' to the respective User
> instance (the 'Contextual Instance') of the _current_ session for each
> invocation. Two different invocations to usr.getName() from 2 different web
> browsers will give you different answers.
>
> .) Contest#get() will return you the internal 'Contextual Instance'
> without the normalscoping proxy. This is usually nothing a user should call
> himself. If you get the User usr for "Karl" that way and store it in an
> @ApplicationScoped bean or in a static variable, then it will _always_
> remain to be the user "Karl" - even for web requests from other browsers!
> You will get a direct, non-proxied instance.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/weld-dev/attachments/20131120/4433d18d/attachment.html
More information about the weld-dev
mailing list