Announcement Announcement Module
Collapse
No announcement yet.
BeanFactory getBean(String name) method implementation. Is it a factory method Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • BeanFactory getBean(String name) method implementation. Is it a factory method

    Hi,

    I am new to Spring.

    Please help in below doubts :

    1. Which class/classes provide the implementation of getBean() method from BeanFactory interface ?

    2. Is the getBean() method a factory method as in factory method design pattern.


    Thanks

  • #2
    Originally posted by abhineetz View Post
    Hi,

    I am new to Spring.
    Welcome :-)

    Originally posted by abhineetz View Post
    Please help in below doubts :

    1. Which class/classes provide the implementation of getBean() method from BeanFactory interface ?
    In my opinion the most important implementations of the BeanFactory[1] interface is all the different application context implementations.
    Simplified you could see it as the interface that defines how to access beans from the context. See the Javadoc [1] for a complete list of implementing classes and a more detailed description of the BeanFactory.
    Normally when you use spring you will not have to bother about the BeanFactory or the ApplicationContext since you can handle DI using annotations or the XML DSL.

    Originally posted by abhineetz View Post
    2. Is the getBean() method a factory method as in factory method design pattern.
    Yes, I would say it is. Since it is the method you call to retrieve a bean from the application context. Depending on the bean definition it will return a singleton bean or build a new instance of the bean.

    The reference manual [2] has good documentation on what the application context and bean factory is.

    [1] http://static.springsource.org/sprin...anFactory.html
    [2] http://static.springsource.org/sprin...tml/beans.html

    Hope this helps
    Pontus Ullgren
    Last edited by ullgren; Aug 31st, 2012, 06:08 AM.

    Comment


    • #3
      @Pontus Ullgren

      Thanks a lot

      Comment

      Working...
      X