| With more and more scale and complexity of software, The research on softwarereuse and software architecture has become the focus of modern software development.J2EE is the best platform for current enterprise software development, EJB had been thecore of J2EE before the appearance of lightweight framework. However, EJB is aheavyweight and high invasive framework, it is based on the distributed applications, it iscomplex to deploy, difficult and costly to test and so on, high invasive means that it has alarge number of interfaces and asks applications must implement these interfaces, it isdifficult or impossible to break away the container once the system was developed underthis container, which leads to great complexity and enormous system overhead and otherissues. Lightweight framework not only simplifies enterprise software development andreduces the system overhead, but also greatly improves the efficiency of softwaredevelopment, at the same time improves the reusability and so on.Among many lightweight frameworks, Spring framework is one of the best becauseof its maturity and perfection, it gracefully provides all J2EE services. Spring framework isborn to simplify the enterprise application development, it uses a simple JavaBean toachieve what EJB can only achieve ago, this high scalable framework is formed frommany actual projects. Spring is an open source framework base on inversion of control, itis designed to provide a framework with low invasive and high expansion, that is Springcan manage code which do not need to involve the classes of the framework. Springprovides a lightweight solution for enterprise application development, this solutionincludes the core based on dependency injection mechanism, declarative transactionmanagement based on AOP, integration with persistent layer as well as Web MVCframework. It allows developers to use some or all of the framework, so it reducesrun-time overhead. The development of lightweight framework has become the power topromote the development of J2EE technology, Spring has become the base of nextgeneration J2EE platform.Now, more and more developers use the Spring framework to develop enterpriseapplications, and the Spring framework has achieved great success. But to the majority ofdevelopers Spring framework is a black box, they only know the function of Springframework and how to configure bean information and the relationship between beans,however they do not know the internal structure and working principle, it is harmful to usethis foolish programming style. We can see in the network that developers ask all sorts ofstrange questions and can not get the right solutions, this is because developers do not understand the internal structure and working principle of Spring framework. If you have adeep understanding of the internal structure and working principle of Spring framework,you can find the root cause of the problem by tracking source code step by step.The other modules of Spring framework provide services in the form dependencyinjection, in order to know the internal structure and working principle of Spring, weshould begin with the core IoC container, the container resolves the coupling betweencomponents. As the core of Spring, IoC container has high research value, at present, veryfew people do systematic research in this respect at home and abroad. First of all, ifdevelopers know the internal structure and working principle of IoC container, they canquickly solve the problem starting from source code in the face of exceptions and errors,you need to modify configuration file and Java source file; Secondly, IoC container is onlypart of Spring, Spring has AOP, transaction, etc., we can continue to research othermodules base on IoC container; Third, even though Spring has achieved a great success, itsapplication at basic facilities is still weaker, enterprise can develop a suitable platform fortheir specific needs according their own needs referencing IoC container; Finally, IoCcontainer has a lot of mature tools packages and various algorithms, developers candirectly use the development kits to other systems, thus reducing the duplication andimproving the software development efficiency.This paper first describes the research background of this article, analyses frameworktechnology of current enterprise application development, point out why Spring can beused widely; then analyses the design idea and objectives of IoC container, gives theoverall architecture and working principle of IoC container, abstracts a general modelwhich can solve the problems of the same type; then introduces key related technologiesrequired to design and implement the container, including ClassLoader principle, XML andrelated technologies, reflection mechanism, JavaBean technology, design pattern and so on,these technology is the core of infrastructure, they are the basic of IoC container; thenintroduces the concept of IoC container as well as the two modes of the container, we needto write DTD file to ensure the container can parse the XML configuration file correctly;then gives the overall core UML class diagram of the container and describes the roles ofkey classes, explain the working principle of the container using UML sequence diagramand data flow char, then analyses the characteristics and performance of the container,points out the expansion points of the container and we can do more research at what place,including transforming DTD file to XML file and internationalization; finally summariesand outlooks the subject.IoC container achieves the unified management of JavaBean by factory mode throughreflection mechanism and JavaBean introspection mechanism, it greatly improve therobustness and portability. In this paper, I analyze the design and implementation of IoCcontainer deeply from source code, provide a reference for developers to know the internalstructure and working principle and point out the value of the research on it, and then abstract a common model, this study on the current IoC container has some innovation. |