Life is too short to have a dog
Author: Brucebat. Sun
Java development or Spring development
For a Java Web server developer, an application development framework like Spring is a great partner. However, husband and wife can still disagree, and brothers can also fight against each other. After staying with Spring as my old partner for a long time, some “crazy” thoughts would come to my mind from time to time: if Spring disappeared one day, what should I use to complete the development work?
Hahaha, I have to say the above idea is a bit crazy. However, after careful consideration, whether Spring is too appropriate as our partner, so that we would feel confused and difficult to continue without Spring. At this point, I can’t help but wonder: Am I a Spring engineer and not a Java engineer? Sadly, a large part of my job is actually programming for Spring and tools related to the Spring ecosystem.
But if we really want to leave Spring’s embrace one day, we need to figure out what Spring does for us.
What does Spring do
First, let’s go back to where we started, to the day we first met Java. On the first day we met, Java told us that in its world everything is an object, and that all behavior methods need to be defined by classes and implemented by objects. That is, we’ve been programming toward objects (or POJO classes) since the very first day we touched Java. But just so there is no way to meet the demand of enterprise development, enterprise development more and more focus on how to operate the enterprise resources to complete the corresponding business logic, such as how to operate the database resources, how to do the transaction, how to make a remote call, etc.), so in order to meet the needs of enterprise development, Sun introduced J2EE enterprise application development platform. Of course, it is not very appropriate to call it a development platform, J2EE since its birth depends on more as an enterprise development specification in the use and promotion. With the advent of J2EE, an enterprise development framework EJB was also born. But with today’s Spring dominance, you already know what happened to EJBs. But how did EJB, his own son, end up like this? Here the blogger did a quick search of online reviews and found that the content was much the same, but too difficult to use and completely inconsistent with development habits. EJB’s heavy design philosophy was all about rigorously conforming to J2EE specifications, rather than providing developers with a quick, easy and easy-to-use development framework, and this anti-development approach left EJBs in the cold light of day after Spring rolled out.
Start looking at the beginning of the Spring to reduce the developer the difficulty of enterprise development, improve the efficiency of development, the design idea of the most important is to let developers can very simple POJO class oriented programming, no need to like using EJB needs to understand the concept framework provided by the object, and then carried out in accordance with the specified the use of the specified object. In addition, in view of the enterprise resource operation J2EE service component, Spring for internal packaging and realized by means of programming to an interface of functional components introduced pluggable type, both functional components provide developers choose freedom, also blocked some functional components of the implementation details, reduce the use cost of developers.
As we can see from the figure above, Spring, as a lightweight application development framework, provides JavaBean management capabilities with IoC container and AOP modules as the core and functional components (packaged J2EE service components) required for application development. It’s important to note that all of the capabilities provided in Spring rely on the IoC container and AOP module cores, which are the most important aspects of the Spring framework’s design philosophy.
1. The core
The IoC container and AOP module are C – bit members of Spring. There are so many blogs and articles on the web explaining the concepts of these two modules that I won’t go into details here, just to give a brief explanation:
The IoC container
The IoC container provides the Spring framework’s most important JavaBean management capabilities, greatly facilitating the coding work of developers through the container and the support provided around the container (such as Resource access Resource abstraction, internationalization, and event-driven);AOP module
: Based on the JVM dynamic proxy /CGlib implementation of the object enhancement function module, so that developers in the actual development can be relatively easy to carry out the general processing of non-business logic;
2. Functional components
We also mentioned above that for enterprise development, it is the core task to complete the corresponding business logic development by manipulating enterprise resources (databases, internal services). Based on this requirement, Spring provides the following functional components to support:
Spring JDBC/ORM
: Based on JDBC specification, Spring further encapsulates database-related operations, providing more concise API operation mode and object mapping capability. In addition, Spring provides integration and encapsulation of major ORM tools, allowing developers to choose their OWN ORM and combine the transaction management capabilities of Spring with the use of ORM tools.Spring remote call
: Spring encapsulates a complete set of inter-application communication and call implementation logic to achieve inter-application remote call. Of course, in today’s microservices, people may use more service governance frameworks such as SpringCloud, Dubbo, gRPC to make remote calls;Spring MVC
: I have been using Spring’s MVC framework for Web development since the first day I learned Spring. Today, it is safe to say that most Internet companies are willing to use Web applications as a means of software distribution, after all, Web applications can be opened on multiple devices with a browser. And even mobile devices need to be supported by corresponding Web servers if they want to access the Internet.
Third, summary
After a cursory look at Spring’s features and current tool support, I can’t help but wonder how difficult it would be to move on without Spring. Whether you choose to start your own business or use existing alternatives, middleware support, database operations, and other J2EE-related functional components require rethinking of integration issues and can be difficult to learn.
So, if Spring disappears, we’ll probably go back to farming and slash-and-burn and wait for the next Spring, hahaha