[weld-dev] BeanManager.getReference() VS Context.get()
Muhammad Bhutto
muhammad.bhutto at gmail.com
Mon Nov 18 21:09:41 EST 2013
Hi All,
Can you please explain me this one, I have confusion which one is better.
1.
Bean<MyBean> bean = (Bean<MyBean>)
beanManager.resolve(beanManager.getBeans(MyBean.class));
MyBean= (MyBean) beanManager.getReference(bean, bean.getBeanClass(),
beanManager.createCreationalContext(bean));
2.
Bean<MyBean> bean = (Bean<MyBean>)
beanManager.resolve(beanManager.getBeans(MyBean.class));
MyBean bean = beanManager.getContext(bean.getScope()).get(bean,
beanManager.createCreationalContext(bean));
As i know BeanManager.getReference() always creates a whole new proxy
instance, while the Context.get() reuses an existing proxy instance if
already created before.
Is BeanManager.getReference() is more use full than Context.get() ??
Thanks
Muhammad Asif Bhutto
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/weld-dev/attachments/20131119/9033789a/attachment.html
More information about the weld-dev
mailing list