Difference between BeanFactory and FactoryBean, beanfactory

Source: Internet
Author: User

Difference between BeanFactory and FactoryBean, beanfactory

BeanFactory is an important interface for Spring IOC containers. It is used for instantiating and obtaining bean instance and bean-related information. Important methods include:

FactoryBean is mainly used to customize instance beans. Its main interfaces include:

By Rewriting the getObject method, we can instantiate the bean we want.

After Spring IOC instantiates a bean, it determines whether the bean is a subclass of FactoryBean. If so, it calls getObject and returns the result.

Based on FactoryBean, we can implement Object Instantiation, implement spring configuration similar to configuring remote services in DUBBO, and compile a class to implement FactoryBean, this class contains application-related attributes, load balance attributes, service type attributes, and proxy interface attributes. The proxy Implementation of the specified interface is returned through ProxyFactory in getObject, in the proxy implementation, you can select an end-to-end service call from the registered server provider based on the configured load balance policy and service type. if the service type is RMI, you can directly use the RMI protocol to call the service, you can use thrift to call RPC. In this way, you can use the implemented classes in spring to proxy remote services.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.