Spring Framework has received more and more attention from the date of birth. Recently, new open source projects support Spring Framework. There are also special websites in China (http://spring.jactiongroup.net/). Then why is it so popular?
What I think is the most important thing is that EJB has a hate everyone. To write an EJB, you need to write localhome, removehome, bean, localinterface, remoteInterface, require a standard descriptor, a special manufacturer descriptor (WebLogic, WebSphere is not the same), if it is an ENTITY BEAN, a mapping file is required. So much, it is really trouble. But EJB is the most important thing to solve the Transaction problem. No other methods can describe it without Spring. Everyone, each company in order to solve the Transaction problem, the programming is different, and the flowers are released. So, Spring appeared when it is most needed.
Spring has a lot of features. But for a product, the most important thing is how to use it. Spring contains several parts of AOP, ORM, DAO, Context, Web, and MVC. WEB, MVC is not considered, with mature struts, JSP or Webwork better. DAO can also be considered due to the popularity of Hibernate, JDO. So the most needed is AOP, ORM, and Context.
In Context, the most important thing is BeanFactory, which is very important to separate interfaces and implementation. I used to write the program, such as an interface IDocument, an implementation class Document1. When writing a program, you need to write idocument doc = new document1 (), once our implementation needs to change, change to Document2, the program needs to be written as idocument doc = new document2 (), all used locations need to be changed. Beanfactory helped us solve this problem. After using Context, it is written to idocument doc = (idocument) beanfactory.getBean ("DOC"). If the implementation class is changed from Document1 to Document2, it can be changed directly in the configuration file. Context is a further abstraction of Bean Factory. Many people like to use ApplicationConext and use servlet to put it LOAD. This is bound to the bean factory with the web. If it is a Fat Client or Remote call, these bean factories is difficult to call, which is actually tighter with the business layer with the business layer. The recommended method is SingletonBeanFactoryLocator. Specifically:
BeanFactoryLocator bfLocator = SingletonBeanFactoryLocator.getInstance (); BeanFactoryReference bf = bfLocator.useBeanFactory ( "beanFactory");. // now use some bean from factory return bf.getFactory () getBean (name);
In this way, it can be expanded at any time to realize the development of components.