Thinking of the Java framework

Source: Internet
Author: User

The current Java Enterprise Development Framework, which we commonly use roughly includes the IOC AOP MVC ORM Framework


1, IOC Spring is a very good ICO container, the idea is very simple, with a collection object such as map to cache objects (the object is a singleton), which is what spring said in the container of the Singleton, The difference between it and the singleton pattern in Java is that the singleton pattern is to keep the singleton in the current Java process because it has three prerequisites: private static itself object, private constructor method, public static getinstance () method, To keep the singleton in the process, and spring can only guarantee the singleton in the container, the user can manually re-create the other object. So this part if for the sake of simplicity it can be replaced with a singleton mode without spring's IOC framework, which reduces the spring jar package, with the disadvantage of poor maintainability and extensibility. or write an ICO container yourself to implement spring's ICO functionality.


2, the essence of AOP AOP is dynamic proxy model, the framework includes spring, ASPECTJ, of course, spring, Spring has two implementation forms, one is the JDK dynamic agent, one is the Cglib bytecode framework (faster than the JDK reflection, Its ASM framework implementation), the typical scenario is database transactions, personal sense of the application of AOP can be removed. Maintainability does not improve, but change complexity. AOP transactions are based on the threadlocal of Threadlocal. About AOP go or stay to be discussed with you.


3, the MVC Framework Spring MVC struts2 compared to the two frameworks: Spring MVC idea is still more advanced, because the struts2 action Bean is not a singleton, each time by reflection new out of an object, performance will be relatively low. The Spring MVC controller is a singleton, inheriting to the Servlet class (single-case multi-pedigree). The idea of its realization is the injection of method parameters. All two support model drivers. Spring MVC has one drawback, and the annotated configuration model all uses Java reflection. Performance will also have an impact. Both support annotations, and individuals think XML is better than annotations, and development phase annotations are better than XML because they are convenient and can be cumbersome to maintain, especially for newcomers who just took over the project. The best solution is to take the two long, go to its shortcomings, keep the spring of the singleton through the method of injection, injected with the JDK reflex removed, replaced by the idea of ASM injection to improve performance.


4, ORM framework Hibernate mybatis. Hiberate is a fully automatic ORM framework, the advantage is simple to use convenient, but the jar package is many, Big data SQL tuning problem is relatively large. MyBatis by Ibatis upgrade, semi-automatic ORM framework, the need to manually write SQL, the advantage is convenient SQL debugging, the disadvantage is that simple single-table additions and deletions also need to manually write SQL, more trouble. So it is best to combine the advantages of two frameworks to develop a single-table additions and deletions to the ORM (not dependent on SQL), complex SQL can be directly through JDBC to improve performance.

This post originates from other authors and is owned by the original copyright author.

Original address: http://www.cnblogs.com/zhishan/p/3199875.html

Thinking of the Java framework

Related Article

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.