Announcement Announcement Module
Collapse
No announcement yet.
Question about getBeanFactory() Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Question about getBeanFactory()

    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?

  • #2
    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.

    Regards,
    Andreas

    Comment


    • #3
      Actually, each SLSB instance will have its own ApplicationContext. If you don't want that, use a ContextSingletonBeanFactoryLocator instead of a ContextJndiBeanFactoryLocator.

      Comment


      • #4
        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.

        Comment


        • #5
          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.

          Regards,
          Andreas

          Comment

          Working...
          X