FazBrowse Wikipedia Viewer | Main Page |
Search Wikipedia:
|
Viewing: https://en.wikipedia.org/wiki/Spring_Framework#Model-view-controller_framework

Spring Framework

Contents
Modules
    Inversion of control container
        Creating and managing beans
    Remote access framework
        Spring Roo
    Spring WebSocket
    Spring WebFlux
Relationship with Jakarta Enterprise Beans (EJB)
See also
Citations

Spring Framework
DeveloperVMware
Release1 October 2002;24 years ago (2002-10-01)
Repository
  • github.com/spring-projects/spring-framework

    Spring Framework 6.0 was released on 16 November 2022 and came with a Java 17+ baseline and a move to Jakarta EE 9+ (in the jakarta namespace), with a focus on the recently released Jakarta EE 10 APIs such as Servlet 6.0 and JPA 3.1.

    Modules

    edit

    The Spring Framework includes several modules that provide a range of services:

    Spring modules are packaged as JAR files. These artifacts can be accessed via the Maven Central Repository using Maven or Gradle.

    Inversion of control container

    edit

    The inversion of control (IoC) container is the core container in the Spring Framework. It provides a consistent means of configuring and managing Java objects using reflection. The container is responsible for managing object lifecycles of specific objects: creating these objects, calling their initialization methods, and configuring these objects by wiring them together.

    In multiple cases, one need not use the container when using other parts of the Spring Framework, although using it will likely make an application easier to configure and customize. The Spring container provides a consistent mechanism to configure applications and integrates with almost all Java environments, from small-scale applications to large enterprise applications.

    The programmer does not directly create an object, but describes how it should be created, by defining it in the Spring configuration file. Similarly, services and components are not called directly; instead a Spring configuration file defines which services and components must be called. This IoC is intended to increase the ease of maintenance and testing.

    Creating and managing beans

    edit

    Objects created by the container are called managed objects or beans. The container can be configured by loading XML (Extensible Markup Language) files or detecting specific Java annotations on configuration classes. These data sources contain the bean definitions that provide the information required to create the beans.

    The @Bean annotation. The @Qualifier or @Inject.

    The @Resource annotation is an annotation that conforms to JSR 250, or Common Annotations for the Java Platform, and is used for autowiring references to POJOs by name.

    The

    The Spring Framework has its own Aspect-oriented programming (AOP) framework that modularizes cross-cutting concerns in aspects. The motivation for creating a separate AOP framework is to provide basic AOP features without too much complexity in either design, implementation, or configuration. The Spring AOP framework takes full advantage of the Spring container.

    The Spring AOP framework is proxy pattern-based. It is configured at run time.

    Compared to the AspectJ framework, Spring AOP is less powerful, but also less complicated.

    Spring AOP was designed to work with cross-cutting concerns inside the Spring Framework. Any object which is created and configured by the container can be enriched using Spring AOP.

    Since version 2.0 of the framework, Spring provides two approaches to the AOP configuration:

    • schema-based approach<beansxmlns="http://www.springframework.org/schema/beans" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd">

The Spring team decided not to introduce new AOP-related terminology. Therefore, in the Spring reference documentation and API, terms such as aspect, join point, advice, pointcut, introduction, target object (advised object), AOP proxy, and weaving all have the same meanings The Spring Framework is the only framework available in Java that offers managed data access environments outside of an application server or container.java.util.Map interface as a data-oriented abstraction for the Model where keys are expected to be <servlet> <servlet-name>MyServlet</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>MyServlet</servlet-name> <url-pattern>/<url-pattern> </servlet-mapping>

  • By configuring it in web-fragment.xml.
  • By using javax.servlet.ServletContainerInitializer.
  • By implementing the org.springframework.web.WebApplicationInitializer interface.
  • By using the built-in autoconfiguration for Spring Boot, which uses the SpringBootServletInitializer class.

Remote access framework

edit

Spring's Remote Access framework is an abstraction for working with various RPC (remote procedure call)-based technologies available on the Java platform both for client connectivity and marshalling objects on servers. The most important feature offered by this framework is to ease configuration and usage of these technologies as much as possible by combining inversion of control and AOP.

The framework provides fault-recovery (automatic reconnection after connection failure) and some optimizations for client-side use of EJB remote stateless session beans.

Spring provides support for these protocols and products out of the box

  • HTTP-based protocols
    • Hessian: binary serialization protocol, open-sourced and maintained by CORBA-based protocols

      Spring Boot Extension is Spring's convention-over-configuration solution for creating stand-alone, production-grade Spring-based Applications that you can "just run". It is preconfigured with the Spring team's "opinionated view" of the best configuration and use of the Spring platform and third-party libraries so you can get started with minimum fuss. Most Spring Boot applications need little Spring configuration.

      Key Features:

      • Create stand-alone Spring applications
      • Embed Tomcat or Jetty directly (no need to deploy WAR files)
      • Provide opinionated 'starter' Project Object Models (POMs) to simplify your Maven/Gradle configuration
      • Automatically configure Spring whenever possible
      • Provide production-ready features such as metrics, health checks and externalized configuration
      • Absolutely no code generation and no requirement for XML configuration.
      • Smooth Integration and supports all Enterprise Integration Patterns.

      Spring Roo

      edit

      Spring Integration is a framework for Enterprise application integration that provides reusable functions essential to messaging or event-driven architectures.

      • routers – routes a message to a message channel based on conditions
      • transformers – converts/transforms/changes the message payload and creates a new message with transformed payload
      • adapters – integrates with other technologies and systems (HTTP, AMQP (Advanced Message Queuing Protocol), JMS (Java Message Service), XMPP (Extensible Messaging and Presence Protocol), SMTP (Simple Mail Transfer Protocol), IMAP (Internet Message Access Protocol), FTP (File Transfer Protocol) as well as FTPS/SFTP, file systems, etc.)
      • filters – filters a message based on criteria. If the criteria are not met, the message is dropped.
      • service activators – invoke an operation on a service object. Spring supports the use of the annotation @ServiceActivator to declare the component that requires this functionality.
      • management and auditing
      • gateways - exposes an interface to the client for the requested services. A messaging middleware is responsible for provisioning this interface. This interface decouples the messaging middleware from the client by hiding the underlying JMS or Spring Integration APIs. Gateways are related to the Facade pattern. Spring's Integration class, SimpleMessagingGateway, provides essential support for gateways. SimpleMessagingGateway enables the Spring application to specify the channel that sends requests, and the channel that expects to receive responses. The primary focus of SimpleMessagingGateway is to deal with payloads, which spares the client from the intricate details of the transmitted and received messages. SimpleMessagingGateway is used along with channels to enable integration with file systems, JMS, e-mail, or any other systems that require payloads and channels.
      • splitter - Separates a large payload into smaller payloads to support different processing flows. The splitter is achieved in Spring using the splitter component. The splitter component usually forwards the messages to classes with more specialized functionality. Spring supports the @Splitter annotation to declare the component that requires this functionality.
      • aggregator - Used for combining multiple messages into a single result. Loosely speaking, the aggregator is the reverse of the splitter. The aggregator publishes a single message for all components downstream. Spring supports the @Aggregator annotation to declare the component that requires this functionality.

      Spring Integration supports pipe-and-filter based architectures.

      Spring WebSocket

      edit

      An essential rule for dealing with data streams effectively is to never block. The WebSocket is a viable solution to this problem. The WebSocket Protocol is a low-level transport protocol that allows full-duplex communication channels over a TCP connection. The WebSocket acts as an alternative to HTTP to enable two-way communication between the client and the server. The WebSocket is especially useful for applications that require frequent and fast exchanges of small data chunks, at a high speed and volume.

      Spring supports the WebSocket protocol by providing the WebSocket API for the reactive application. The @EnableWebSocket annotation gives Websocket request processing functionality when placed in a Spring configuration class. A mandatory interface is the WebSocketConfigurer which grants access to the WebSocketConfigurer. Then, the Websocket URL is mapped to the relevant handlers by implementing the registerWebSocketHandlers(WebSocketHandlerRegistry) method.

      Spring WebFlux

      edit

      Spring WebFlux is a framework following the functional programming paradigm, designed for building reactive Spring applications. This framework uses functional programming and Reactive Streams extensively. A good use case for Spring WebFlux is for applications that require sending and receiving instantaneous information, such as a web application with chatting capabilities.

      Although applications using Spring WebFlux technology is usually less readable than their MVC counterparts, they are more resilient, and simpler to extend. Spring WebFlux reduces the need to deal with the complications associated with synchronizing thread access.

      Spring WebFlux supports server-sent events (SSE), which is a server push technology that allows the client to get automatic updates from a server through an HTTP connection. This communication is unidirectional, and shares a number of similarities with the publish/subscribe model found in JMS.

      Relationship with Jakarta Enterprise Beans (EJB)

      edit
      Some

      A remote code execution vulnerability affecting certain versions of Spring Framework was published in April 2022 under CVE-2022-22965. It was given the name Spring4Shell in reference to the recent Log4Shell vulnerability, both having similar proofs-of-concept in which attackers could on vulnerable machines, gain shell access or even full control.

      See also

      edit

      Citations

      edit
        "Spring Framework Overview". docs.spring.io.
      1. ↑ Deinum et al. 2014, pp. 694–698, §16-2 Integrating Two Systems Using JMS.
      2. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 Johnson & Hoeller 2004.
      3. ↑ Deinum & Cosmina 2021, p. 1, §1 Setting up a Local Development Environment.
      4. ↑ "Spring Framework 3.2.5 Released". Official Spring website. 7 Nov 2013. Retrieved 16 October 2016.
      5. ↑ "Spring Framework 4.2 goes GA". Spring Blog.
      6. ↑ "Spring Framework 6.0 goes GA". Spring Blog. 16 November 2022.
      7. ↑ Walls 2019, p. 48.
      8. ↑ Spring Framework documentation for the Core Container
      9. 1 2 Johnson et al. 2005, Chapter §2 - The Bean Factory and ApplicationContext.
      10. ↑ Deinum et al. 2014, p. 137, §3-1 Using Java Config to configure POJOs.
      11. 1 2 Johnson & Hoeller 2004, p. 150, Introducing the Spring Framework - The Core Bean Factory.
      12. 1 2 3 4 5 6 7 Deinum & Cosmina 2021, pp. 22–25, §2 Spring Framework Fundamentals - The Spring Framework.
      13. ↑ Walls 2016, p. 240, §Appendix D Spring Boot dependencies.
      14. ↑ Johnson et al. 2005, Chapter §1 Introducing the Spring Framework - Module Summary.
      15. ↑ Johnson et al. 2005, Chapter §4 - Spring and AOP.
      16. ↑ Deinum et al. 2014, pp. 196–198, §3-17 AOP introductions for POJOs.
      17. ↑ Johnson et al. 2005, Acegi Security System for Spring.
      18. ↑ Deinum et al. 2014, p. 331, §7 Spring Security.
      19. ↑ Walls 2019, pp. 56–59.
      20. 1 2 3 4 5 6 Deinum et al. 2014, pp. 419–426, §10 Data Access.
      21. ↑ Deinum et al. 2014, pp. 677–681, §15-4 Create Message-Driven POJOs in Spring.
      22. ↑ Johnson et al. 2005, Chapter §12 - Web MVC Framework.
      23. 1 2 3 Deinum et al. 2014, p. 217, §4 Spring @MVC.
      24. ↑ Deinum et al. 2014, pp. 525–534, §12-3 Writing a Custom ItemWriter and ItemReader.
      25. ↑ Deinum et al. 2014, pp. 627–632, §14-7 Expose and Invoke Services through RMI; §14-8 Expose and Invoke Services through HTTP.
      26. ↑ Deinum et al. 2014, pp. 641–658, §14-10 Introduction to contract first SOAP Web Services,§14-11 Expose and invoke SOAP Web Services with Spring-WS,§14-12 Develop SOAP Web Services with Spring-WS and XML Marshalling.
      27. ↑ Johnson et al. 2005, Chapter §8 - Lightweight Remoting.
      28. 1 2 Johnson et al. 2005, Chapter §9 - Supporting Services.
      29. ↑ Deinum et al. 2014, p. 475, §11 Spring Transaction Management.
      30. ↑ Deinum et al. 2014, p. 591, §14 Spring Java Enterprise Services and Remoting Technologies.
      31. ↑ Deinum et al. 2014, pp. 737–739, §17-3 Unit Testing Spring MVC Controllers.
      32. ↑ Deinum et al. 2014, pp. 739–743, §17-4 Managing Application Contexts in Integration Tests.
      33. ↑ Musib 2022, p. 358, §8.3 Introducing Spring WebFlux.
      34. ↑ Cosmina et al. 2017, p. 21-23.
      35. ↑ Cosmina et al. 2017, pp. 24–25, §2 Accessing Spring Modules Using Maven.
      36. ↑ Cosmina et al. 2017, p. 26, §2 Accessing Spring Modules Using Gradle.
      37. 1 2 Deinum et al. 2014, pp. 53–62, §2-2 Create POJOs by Invoking a Constructor.
      38. 1 2 Deinum et al. 2014, pp. 48–52, §2-1 Manage and Configure POJOs with the Spring IoC Container.
      39. ↑ Deinum et al. 2014, pp. 59–67, §2-3 Use POJO References, Auto-Wiring, and Imports to Interact with Other POJOs.
      40. ↑ Deinum et al. 2014, pp. 112–116, §2-16 Use Property Editors in Spring.
      41. 1 2 Walls 2019, pp. 4–6, §1.1 Getting started with Spring - What is Spring.
      42. ↑ Cosmina et al. 2017, p. 37, §3 Introducing IoC and DI in Spring.
      43. ↑ What is the difference between the depencylookup and dependency injection - Spring Forum. Forum.springsource.org (2009-10-28). Retrieved on 2013-11-24.
      44. ↑ Deinum & Cosmina 2021, pp. 26–32, §2 Spring Framework Fundamentals - Dependency Injection.
      45. 1 2 Johnson & Hoeller 2004, pp. 135–137, §6 Lightweight Containers and Inversion of Control - IOC Containers.
      46. ↑ Deinum et al. 2014, pp. 145–151, §3-3 Use POJO References and Auto-Wiring to Interact with other POJOs.
      47. 1 2 3 Cosmina et al. 2017, pp. 112–120, §3 Introducing IoC and DI in Spring - Autowiring Your Beans.
      48. 1 2 3 Deinum et al. 2014, pp. 151–154, §3-4 Auto-wire POJOs the @Resource and @Inject annotation.
      49. ↑ Deinum et al. 2014, pp. 99–104, §2-12 Aspect Orientated Programming.
      50. 1 2 3 Deinum et al. 2014, pp. 492–494, §11-6 Managing Transactions Declaratively with the @Transactional Annotation.
      51. ↑ Deinum et al. 2014, pp. 509–510, §11-11 Managing Transactions with Load-Time Weaving.
      52. ↑ Spring AOP XML Configuration
      53. ↑ AspectJ Annotation Configuration
      54. ↑ Deinum et al. 2014, pp. 441–446, §10-5 Handling Exceptions in the Spring JDBC Framework.
      55. ↑ Deinum et al. 2014, pp. 426–441, 463–465.
      56. ↑ Hibernate VS Spring
      57. Deinum et al. 2014, pp. 463–466, §10-8 Persisting Objects with Spring's ORM Templates.
      58. ↑ Deinum et al. 2014, pp. 446–462, §10-6 Problems with Using ORM Frameworks Directly.
      59. ↑ "Spring Boot". spring.io.
      60. ↑ Walls 2016, p. 48, §2.4.
      61. ↑ Deinum & Cosmina 2021, pp. 21–22, §2 Spring Framework Fundamentals.
      62. ↑ Walls 2016, pp. 37–48, §2.3.
      63. 1 2 Walls 2016, p. 7, §1.1.3.
      64. 1 2 Walls 2016, p. x, §Preface.
      65. ↑ Walls 2016, pp. 4–5, §1.1.2.
      66. 1 2 Walls 2016, pp. 124–139, §7.
      67. ↑ Walls 2016, pp. 49–69, §3.1-§3.2.3.
      68. ↑ "Spring4Shell: critical vulnerability in Spring - Kaspersky official blog". April 2022.
      69. ↑

      View original on Wikipedia | Back | FazBrowse Home