Results 1 to 3 of 3

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

  1. #1
    Join Date
    Aug 2012
    Posts
    2

    Default 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. #2
    Join Date
    Jun 2011
    Posts
    35

    Default

    Quote Originally Posted by abhineetz View Post
    Hi,

    I am new to Spring.
    Welcome :-)

    Quote 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.

    Quote 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 at 05:08 AM.

  3. #3
    Join Date
    Aug 2012
    Posts
    2

    Default

    @Pontus Ullgren

    Thanks a lot

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •