• Spring---->projects----->Spring Framework


    1.Spring Framework概述:

      • Spring Framework是spring若干子项目中的一个
      • Spring Framework的主要功能有:
          • 依赖注入(dependency injection/IoC),
          • AOP以及声明式的事务管理机制(Aspect-Oriented Programming including Spring's declarative【声明式的】 transaction management
          • web applications:Spring MVC web application and RESTful web service framework
          • data access:Foundational support for JDBC, JPA, JMS
          • messaging,
          • testing and more. 
      • Spring的所有功能模块(about 20 modules):
          • 概述,The Spring Framework总共包含大致20个模块(modules),每个模块都是Spring框架这个project下的子project,也就是说每个子module都有唯一的artifactId,项目管理工具(maven/gradle)可以通过引入某个module的artifactId来向开发者的project中引入单独的某个module。换句话说就是,spring framework下的20个模块都是独立的,开发者在使用spring framework的时候完全可以根据自己项目的实际需要选择向自己的project引入spring framework的20个模块中的任意一个或几个module,而不是将所有module都引入到你的project中(e.g. so for example if you don’t want to write a web application you don’t need the spring-web modules. )
          • Figure 2.1. Overview of the Spring Framework。The Spring Framework的20个模块可以被分成如下几类:Core Container, Data Access/Integration, Web, AOP (Aspect Oriented Programming), Instrumentation【仪器仪表】, Messaging, and Test类, as shown in the following diagram.

            spring overview
          • Table:Spring framework的20个modules的artifactId,有了artifactId,就可以使用项目管理工具(如maven/gradle等)来进行dependencies management了。这些module是相互独立的,可以任意引入其中的一个或多个module。

              • spring framework的这20个module都会被发布到maven中央仓库,并且Many of the common libraries that Spring depends on also are available from Maven Central,所以可以使用maven来进行这些module的dependencies management。使用maven进行dependency management,只需要配置pom.xml,maven就会自动从maven 中央仓库帮你下载相应的jar包到maven本地仓库,你的项目就可以从maven本地仓库找到它的dependencies并使用它们。maven的引入省去了手动下载、添加项目依赖的jar包的过程。
              • the Maven groupId is org.springframework.
              • Table 2.1. Spring Framework Artifacts(Spring framework的20个module的artifactId)
                GroupIdArtifactIdDescription

                org.springframework

                spring-aop

                Proxy-based AOP support

                org.springframework

                spring-aspects

                AspectJ based aspects

                org.springframework

                spring-beans

                Beans support, including Groovy

                org.springframework

                spring-context

                Application context runtime, including scheduling and remoting abstractions

                org.springframework

                spring-context-support

                Support classes for integrating common third-party libraries into a Spring application context

                org.springframework

                spring-core

                Core utilities, used by many other Spring modules

                org.springframework

                spring-expression

                Spring Expression Language (SpEL)

                org.springframework

                spring-instrument

                Instrumentation agent for JVM bootstrapping

                org.springframework

                spring-instrument-tomcat

                Instrumentation agent for Tomcat

                org.springframework

                spring-jdbc

                JDBC support package, including DataSource setup and JDBC access support

                org.springframework

                spring-jms

                JMS support package, including helper classes to send and receive JMS messages

                org.springframework

                spring-messaging

                Support for messaging architectures and protocols

                org.springframework

                spring-orm

                Object/Relational Mapping, including JPA and Hibernate support

                org.springframework

                spring-oxm

                Object/XML Mapping

                org.springframework

                spring-test

                Support for unit testing and integration testing Spring components

                org.springframework

                spring-tx

                Transaction infrastructure, including DAO support and JCA integration

                org.springframework

                spring-web

                Web support packages, including client and web remoting

                org.springframework

                spring-webmvc

                REST Web Services and model-view-controller implementation for web applications

                org.springframework

                spring-webmvc-portlet

                MVC implementation to be used in a Portlet environment

                org.springframework

                spring-websocket

                WebSocket and SockJS implementations, including STOMP support

          • the Spring Framework的20个module,每个module的功能(详述)
              • Core Container(IoC Container)参考资料:

                  • 参考资料:
                    1.   Spring官网:IoC Container
                    2.   Spring官网:
                  • Core Container包括20个module中的5个模块,分别是 spring-corespring-beansspring-contextspring-context-support, and spring-expression 这五个module
                  • 其中,The spring-core ,spring-context and spring-beans modules 提供IoC功能和依赖注入功能,是the spring framework的基本功能模块,要想使用spring framework的beanfactory(实际上是一个配置文件*.xml或者注解)来管理beans,就必须要引入20个module中的 The spring-core and spring-beans modules 。
                      • The org.springframework.beans and org.springframework.context packages are the basis for Spring Framework’s IoC container. 这些包中最主要的两个API是The BeanFactory interface以及 ApplicationContext  interface,这两个接口都是用来管理beans的,建议使用 the ApplicationContext接口。
                      • The BeanFactory interface provides an advanced configuration mechanism capable of managing any type of object.
                      • org.springframework.context.ApplicationContext is a sub-interface of BeanFactory. It adds easier integration with Spring’s AOP features; message resource handling (for use in internationalization), event publication; and application-layer specific contexts such as the WebApplicationContext for use in web applications. 
                      • In short, the BeanFactory provides the configuration framework and basic functionality, and the ApplicationContext adds more enterprise-specific functionality.TheApplicationContext is a complete superset of the BeanFactory,  the ApplicationContext includes all functionality of the BeanFactory,所以一般情况下我们会使用 ApplicationContext interface,下面这个网址有使用ApplicationContext接口及其实现类管理beans的教程。当然,你也可以使用beanFactory来管理你的beans,如下网址是使用BeanFactory接口管理beans的教程。(Spring官网建议使用the ApplicationContext)
                  • the spring-context module
                    • 依赖于the  spring-core and spring-beans 模块,
                    • 功能:support for internationalization【国际化】 (using, for example, resource bundles), event propagation【传播】, resource loading, and the transparent【透明的】 creation of contexts by, for example, a Servlet container. The Context module also supports Java EE features such as EJB, JMX, and basic remoting.
                    • 该模块最常用的API:The ApplicationContext interface is the focal point of the Context module. 
                  • spring-context-support moduleprovides support for integrating common third-party libraries into a Spring application context for caching (EhCache, Guava, JCache), mailing (JavaMail), scheduling (CommonJ, Quartz) and template engines (FreeMarker, JasperReports, Velocity).
                  • The spring-expression module provides是JSP2.1规范中的表达式语言的一个扩展,你可以使用表达式语言来setting and getting property values, property assignment, method invocation, accessing the content of arrays, collections and indexers, logical and arithmetic operators, named variables, and retrieval of objects by name from Spring’s IoC container. It also supports list projection and selection as well as common list aggregations.
              • AOP and Instrumentation

                  • The spring-aop module提供AOP功能,
                  • The separate spring-aspects module provides integration with AspectJ【AspectJ:一个使用java语言编写的面向切面的框架】.    
                  • The spring-instrument module provides class instrumentation support and classloader implementations to be used in certain application servers.
                  • The spring-instrument-tomcat module contains Spring’s instrumentation agent for Tomcat.
              • Messaging

                  • Spring Framework 4 includes a spring-messaging module to serve as a foundation for messaging-based applications. The module also includes a set of annotations for mapping messages to methods, similar to the Spring MVC annotation based programming model.    
              • Data Access/Integration

                  • The spring-jdbc module provides a JDBC-abstraction【抽象】 layer that removes the need to do tedious 【单调乏味的】JDBC coding and parsing【解析】 of database-vendor【数据库供应商】 specific error codes.

                  • The spring-tx module supports programmatic and declarative transaction management for classes that implement special interfaces and for all your POJOs (Plain Old Java Objects).

                    The spring-orm module provides integration layers for popular object-relational mapping APIs, including JPAJDO, and Hibernate. Using the spring-orm module you can use all of these O/R-mapping frameworks in combination with all of the other features Spring offers, such as the simple declarative transaction management feature mentioned previously.

                    The spring-oxm module provides an abstraction layer that supports Object/XML mapping implementations such as JAXB, Castor, XMLBeans, JiBX and XStream.

                    The spring-jms module (Java Messaging Service) contains features for producing and consuming messages. Since Spring Framework 4.1, it provides integration with the spring-messaging module.

                        
              • Web

                  • The Web layer consists of the spring-webspring-webmvcspring-websocket, and spring-webmvc-portlet modules.
                  • The spring-web module provides basic web-oriented integration features such as多文件上传功能、初始化IoC 容器等功能(使用Servlet listeners以及面向web的application context来实现这些功能)。 It also contains an HTTP client and the web-related parts of Spring’s remoting support.
                  • The spring-webmvc module (also known as the Web-Servlet module) 实现了MVC架构模式以及REST Web Services. Spring’s MVC framework provides a clean separation between domain model code and web forms and integrates with all of the other features of the Spring Framework.

                  •  

                    The spring-webmvc-portlet module (also known as the Web-Portlet module) provides the MVC implementation to be used in a Portlet environment and mirrors the functionality of the spring-webmvc module.

                  •     
              • Test

                  • The spring-test module supports the unit testing and integration testing of Spring components with JUnit or TestNG. It provides consistent loading of SpringApplicationContexts and caching of those contexts. It also provides mock objects that you can use to test your code in isolation.    

    2.The Spring Frameork的 使用实例(我的project中引入Spring framework的若干module) 

      2.1 Minimum requirements

          • JDK 6+ for Spring Framework 4.x
          • JDK 5+ for Spring Framework 3.x

           2.2spring framework的20个modules有不同的组合方法,另外,Spring framework也可以和其他技术进行组合开发

            • Figure 2.2. Typical full-fledged Spring web application

                overview full
              Spring’s declarative transaction management features make the web application fully transactional, just as it would be if you used EJB container-managed transactions. All your custom business logic can be implemented with simple POJOs and managed by Spring’s IoC container. Additional services include support for sending email and validation that is independent of the web layer, which lets you choose where to execute validation rules. Spring’s ORM support is integrated with JPA, Hibernate and JDO; for example, when using Hibernate, you can continue to use your existing mapping files and standard Hibernate SessionFactory configuration. Form controllers seamlessly integrate the web-layer with the domain model, removing the need for ActionForms or other classes that transform HTTP parameters to values for your domain model.
            • Figure 2.3. Spring middle-tier using a third-party web framework

              overview thirdparty web
              Sometimes circumstances do not allow you to completely switch to a different framework. The Spring Framework does not force you to use everything within it; it is not an all-or-nothing solution. Existing front-ends built with Struts, Tapestry, JSF or other UI frameworks can be integrated with a Spring-based middle-tier, which allows you to use Spring transaction features. You simply need to wire up your business logic using an ApplicationContext and use a WebApplicationContext to integrate your web layer.
            • Figure 2.5. EJBs - Wrapping existing POJOs

              overview ejb

               

              The Spring Framework also provides an access and abstraction layer for Enterprise JavaBeans, enabling you to reuse your existing POJOs and wrap them in stateless session beans for use in scalable, fail-safe web applications that might need declarative security.

               
               
               
               
                    
    学习的过程中总会得到一些心得体会,认真地将它们记录下来并分享给每一个愿意花费时间去阅读它们的人,然后意外地收获某个读者的评论,从而激发出新的感想,是一件十分令人欢快的事。如果你也在研习这方面的知识,欢迎加入到我们的队伍中来,和我们一起进步吧(^_^)
  • 相关阅读:
    SqlServer卸载实例
    java写的各种钟(收集)
    Codeforces 1003D Coins and Queries 【性质】
    Codeforces 997B Roman Digits【暴力】【枚举】
    洛谷 P2679 子串 【dp神题】【滚动数组】【2015 noip d2t2】
    复习图论
    Codeforces 1000D Yet Another Problem On a Subsequence 【dp】【组合数学】
    Codeforces 1000C Covered Points Count 【前缀和优化】
    Codeforces 999F Cards and Joy 【dp】【性质】
    Codeforces 999D Equalize the Remainders 【模拟】
  • 原文地址:https://www.cnblogs.com/lxrm/p/6193420.html
Copyright © 2020-2023  润新知