View Full Version : Question about getBeanFactory()
Jul 25th, 2005, 03:57 PM
I have my bean factory set up as an env-entry in ejb-jar.xml. Judging from some debug statements I inserted, it seems that each call to getBeanFactory(), a new context is being created. Is this true?
Jul 26th, 2005, 12:41 AM
This might be the case. However, I do not see this as problem. The idea is to retrieve the BeanFactory once on bean creation to perform initialization. This way you need not to care about possible performance aspects or duplication.
Jul 26th, 2005, 02:50 AM
Actually, each SLSB instance will have its own ApplicationContext. If you don't want that, use a ContextSingletonBeanFactoryLocator instead of a ContextJndiBeanFactoryLocator.
Jul 26th, 2005, 06:19 AM
Well, if I have dao's that I want as singletons, I don't want to be creating new instances everytime a bean factory is created for a stateless bean. So I factored those bean definitions out into a different context file.
Jul 26th, 2005, 08:19 AM
In the normal case you would have one BeanFactory per EJB-instance. So you would also have one DAO instance per EJB.
With the aforementioned ContextSingletonBeanFactoryLocator you might indeed share instances if you like. Just take care that your DAOs (or whatever instances) are thread-safe.
Powered by vBulletin® Version 4.2.1 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.