-
1. Re: Bean created twice
mbogoevici Jul 22, 2010 3:07 PM (in response to arungupta)Hi Arun,
For every normal-scoped bean there is a proxy, In case, the proxy is a subclass of ShoppingCart, so what you see is the instantiation of two objects: one is the actual bean instance, the other one is the proxy (which being a subclass of ShoppingCart will invoke the no-arg constructor too),
Hope this helps,
Marius -
2. Re: Bean created twice
arungupta Jul 22, 2010 3:27 PM (in response to arungupta)That helps explain the invocation of two constructors.
What is the purpose of this proxy ?
Do the users need to worry about this proxy or is purely for CDI runtime ?
-Arun
-
3. Re: Bean created twice
mbogoevici Jul 22, 2010 4:36 PM (in response to arungupta)No needs to worry about it, unless there are side-effects due to the duplicate instance construction (which, in general is a bad idea).
You can find more details about this here.
-
4. Re: Bean created twice
niknik77771 Jan 28, 2011 4:47 PM (in response to arungupta)What if bean creation is expansive like database call? What is a Best Practices?
-
5. Re: Bean created twice
ssachtleben.ssachtleben.gmail.com Jan 28, 2011 6:29 PM (in response to arungupta)Dont use the constructor for database calls ...
@PostConstruct public void initialize() { log.info("Just called once..."); }
-
6. Re: Bean created twice
niknik77771 Jan 29, 2011 12:31 PM (in response to arungupta)Thank you very much Sebastian. Thats it.