What is Spring Framework?
On any type of deployment platform, the Spring Framework offers a complete programming and configuration architecture for contemporary Java-based enterprise applications.
Infrastructure support at the application level is a crucial component of Spring. Spring concentrates on "plumbing" corporate applications so that teams may concentrate on application-level business logic without needless attachments to particular deployment environments.
i18n, validation, data binding, type conversion, SpEL, AOP, events, resources, dependency injection, and other core technologies.
Mock objects, the TestContext framework, Spring MVC tests, and WebTestClient are all under test.
features include DAO support, JDBC, ORM, and XML marshaling.
web frameworks Spring WebFlux and Spring MVC.
Kotlin, Groovy, and dynamic languages
Spring Framework Architecture
A modular framework is a spring. It is not provided in a package or bundle with other modules. Different spring parts are available as separate modules. This allows us the freedom to use what we need and discard the rest. For instance, we don't need to include the Spring Web Module in our project if we wish to use the Spring JMS module. Our application becomes focused and lightweight as a result.
Architecture in Spring
Let's take a broad glance at the Spring Architecture (see diagram), and then in later chapters of this tutorial, we'll go deeper into each of these modules. The Core is the foundation of the Spring Framework, as depicted in the diagram. Other modules include Web, Data Access, and a variety of others. The test module, which is built on the core as well, is distinct because it relates to testing the application's spring-backed components.
The heart of Spring is the Core Container. It includes several fundamental framework classes and resources. The Core Container serves as the foundation for the whole Spring Framework.
The Core module includes fundamental classes for the Spring Framework, such as Dependency Injection (DI) and Inversion of Control (IOC). The Spring Core can be found via the Spring Core repository. Regardless of the sort of Spring Application you are creating, Spring Core will always be a direct or indirect dependent.
The lifecycle of beans is managed by the Spring Bean module. Any Java class registered with the Spring Framework is referred to as a bean, and Spring handles these bean classes. The Bean Factory in the Spring Bean module produces bean instances, resolves bean to bean dependencies, and automatically wires the beans according to their type or name.
The Spring Beans Repo is where you may find the Spring Bean module.
We discovered that Spring Beans is in charge of overseeing Spring Beans. This context, which is known as a Context, defines these spring beans. Every object in Spring is a bean, whether it is a configuration setting or a custom class (For example Employee). The Context contains definitions for each of these beans, their constructors or factory methods, and their dependents. Through Context, the beans are accessed.
The Spring Context, also known as an Application Context, is typically launched along with a Spring Application.
Spring Expression Language, sometimes known as SpEL, is a powerful expression language. At runtime, it is employed to convert expressions to values. SpEL can be used for XML- or annotation-based Bean Definition and Bean Configuration and can query objects graphs at runtime. The term "runtime" is crucial since the expressions may be judged based on runtime settings or the results of other expressions.
The Spring Web components are used to create web applications, as is clear from the name alone. We can create whole MVC apps, interceptors, Web Services, and Portlets using the Spring Web module.
Servlet & Spring Web
Numerous options are available for establishing online integrations using Spring Web and Servlets. In one of the aforementioned parts, we learned what an application context is. A Web Application Context similar to the context offered by Spring Web. Inversion of Control and abstraction for servlets are both provided by Spring Web (IOC).
Spring MVC is a further part of the Spring Web framework. A framework for creating Model View Controller-based web applications is provided by Spring MVC. View and Actions are concepts in Spring MVC. Action is the component that fulfills web requests, whereas Views stand in for the user interface or the consumer.
Spring Web Sockets
Web Socket development is supported by Spring Web Sockets. In online applications, web sockets act as a kind of tunnel between a service and a consumer. The client with an HTTP connection must query the server for any updates. Due to the bidirectional communication channel provided by Web Sockets, even servers can send messages directly to clients.
Web Portlets for Spring
Web portlet development is supported by Spring Web Portlets. In a web portal, portlets are pluggable user interface software elements that are managed and displayed. In other terms, it is a method for displaying numerous apps' user interfaces (portlets) on a single user interface. These portlets are often pluggable and repositionable.
Spring Data Access
A collection of modules called Spring Data Access allows users to access data in forms like XML, databases and messaging. Let's review the modules in detail.
Over the Java JDBC API, the Spring JDBC provides an abstraction. We frequently have to deal with Statements, Queries, Result Sets, and notable exceptions when we need to access data from databases. All of this complexity is eliminated by the Spring JDBC abstraction, which also offers a Jdbc Template for simple data access. Additionally, it offers methods for mapping and iterating the result sets.
The integration of Spring ORM with different ORM implementations is supported. The term "ORM" refers to frameworks for Object Relational Mapping in which data is field by field mapped to a Java object. With the use of ORM frameworks, data may be added to a plain Java object and then sent to the ORM API for storage and retrieval in the form of plain Java objects. Popular ORM frameworks like Hibernate, JDO, and JPA are supported by Spring.
JMS, or Java Messaging Service, is a specification that establishes rules for message-based communication between Publishers and Subscribers. Different JMS implementations like ActiveMQ and RabbitMQ are covered by an interface provided by Spring JMS.
Over Java OXM implementations, Spring OXM offers abstraction. Data access and transfer in the form of XML are defined by the Java OXM (Object XML Marshalling) specification. OXM has many different implementations, including JAXB and XStream.
The Spring Transactions Management API offers a consistent method for managing database and data object transactions. Declarative and programmatic transaction management is supported via the Transaction API.
We are now in the final section of the tutorials. This section will teach you about the significant independent modules that make up Spring's Miscellaneous category.
Aspect Oriented Programming is implemented using Spring. Any auxiliary function that an object must carry out is known as an aspect. In addition to its primary function, each Java object may also be required to provide logging or exception handling.
We now understand what aspect-oriented programming is. Like other Aspect Oriented Programming implementations like AspectJ, Spring Aspects offers a consistent method of integration.
Class instrumentation is supported via the Spring Instrumentation module. The instrumentation is used to keep track of how well an application is doing. It keeps track of numerous objects to detect and log application issues.
Integration with messaging systems is supported through Spring Messaging. The module offers a uniform and easier method of interfacing with different messaging systems.
We learned about the Spring Framework Architecture in this article. Spring is a sizable framework with numerous modules. Everything in Spring is supported by the Core Container, on which all other modules depend. In addition to the core, we also looked at Spring Web, Spring Data Access, and a few more modules.