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.