0

How to ensure that

<class> classInstance = (class)beanManager.getReference(bean, 
      bean.getBeanClass(), beanManager.createCreationalContext(bean)); 

Always creates a new object on every call?

ρяσѕρєя K
  • 132,198
  • 53
  • 198
  • 213
Subhashc
  • 53
  • 10

1 Answers1

0

If you are using CDI you should annotate your bean class with @RequestScoped.

for example:

@Named
@RequestScoped
public class SomeBean{
...
}

Read more here

Milkmaid
  • 1,659
  • 4
  • 26
  • 39
  • but as per the link below i can see that beanManager#getReference will give a new instance. http://stackoverflow.com/questions/20048410/canonical-way-to-obtain-cdi-managed-bean-instance-beanmanagergetreference-vs?answertab=active#tab-top – Subhashc Nov 05 '16 at 08:30