Spring Framework Overview

Spring是开发java application的通用框架,分为多个模块(modules),核心是core container,包括configuration model(配置模型)和dependency injection(依赖注入)Spring还可以为多种应用架构(application architecture)提供支持,包括messaging,transaction data, persistence(持久化),web。Spring也提供Servlet-based Spring MVC web framework和Spring WebFlux reactive web framework。

History

Spring最早在2003年,由于J2EE过于复杂而被开发出来的。有人认为Spring和Java EE是竞争关系,但Spring更像是对Java EE的补充。Spring整合了一些EE的标准:

  • Servlet API
  • WebSocket API
  • Concurrency Utilities(并发性)
  • JSON Binding API 简介
  • Bean Validation(数据校验) 简介
  • JPA
  • JMS
  • Dependency Injection and Common Annotations

Java EE在app开发中的角色在随时间变化。早期的时候,javaEE和Spring开发的应用是部署在application server上的,今天,在Spring Boot的帮助下开发变得友好且更加云端化(devops and cloud-friendly),嵌入Servelet容器,非常容易改变。在Spring Framework5中,一个webflux应用甚至不需要Servlet API并可以运行在不含Servlet容器的server上。

Spring projects目前在逐渐丰富,建立在Spring Framework上的projects有Spring Boot,Spring Security,Spring Data,Spring Cloud,Spring Batch…

Spring的design philosophy

  • Provide choice at every level 尽可能允许不改动code的情况下变更design
  • Accommodate diverse perspectives 允许设计的灵活性
  • Maintain strong backward compatibility 对JDK和第三方库的高兼容性
  • Care about API design API被设计地简单易用
  • Set high standards for code quality 注意代码的整洁

IoC Container

Introduction

IoC: Inversion of Control(控制反转) 也可称为dependency injection(依赖注入), 定义: it is a process whereby objects define their dependencies (that is, the other objects they work with) only through constructor arguments, arguments to a factory method, or properties that are set on the object instance after it is constructed or returned from a factory method. 容器随后在创建bean时将依赖注入(把需要的对象传入)。这个过程事实上是对bean自身控制实例化或依赖定位(通过直接初始化类或类似Service Locator Pattern机制)的inverse,这就是为什么叫Inversion of Control。

org.springframework.beans 和 org.springframework.context两个包是Spring Framework的IoC容器的基础。BeanFactory接口提供了能管理任何类型对象的高级配置机制。简单来说BeanFactory提供了框架配置和基本的功能。ApplicationContextBeanFactory的子接口,它添加了更多特性企业级应用的功能。在Spring中,塑造应用骨架并被IoC容器管理的对象称为bean。一个bean是一个被IoC容器实例化(instantiated),组装(assembled),管理(managed)的对象,bean只是应用中众多对象中的一个。bean和它周围的依赖都会被容器的配置影响。

Container Overview

org.springframework.context.ApplicationContext接口说明了IoC容器,容器负责实例化,配置,集成beans。容器通过阅读配置文件(configuration metadata)知道实例化(或配置,集成)哪些beans。configuration metadata可以是XML,Java annotations(注释)或java code。IoC可以传递对象以使应用更简练并丰富对象间的依赖。

Spring也提供ApplicationContext接口的一些实现,在实践中经常会创建ClassPathXmlApplicationContextFileSystemXmlApplicationContext的实例。XML是传统的定义configuration metadata的方法。你可以通过一些XML配置(修改配置为支持额外的格式)来让容器使用注释或代码作为metadata。(原文较难理解:you can instruct the container to use Java annotations or code as the metadata format by providing a small amount of XML configuration to declaratively enable support for these additional metadata formats)

在大部分application scenario中IoC容器实例化多个实例并不需要详尽的用户代码,比如说网页应用中创建一个boilerplate只需要几行代码的descriptor。如果使用Spring Tool Suite就甚至只需要鼠标点几下或者键盘敲几下。

how Spring works(图):
Your application classes are combined with configuration metadata so that, after the ApplicationContext is created and initialized, you have a fully configured and executable system or application.

spring ref &history&design philosophy的更多相关文章

  1. spring ref history Design philosophy

    一.前言 Spring 框架可以说是 Java 开发人员使用的最流行的应用程序开发框架之一.它目前由大量提供一系列服务的模块组成.包括模块容器,为构建横切关注点提供支持的面向切面编程(AOP),安全框 ...

  2. Spring history&Design Philosophy 简单介绍~

    SPRING框架的介绍和历史 Spring Framework是一个开源Java应用程序框架,最初是基于依赖注入(DI)和控制反转(IoC)的原理开发的. Spring Framework已经成长为控 ...

  3. spring history &design Philosophy

    Spring简介 Spring是一个开源框架,它由Rod Johnson创建.它是为了解决企业应用开发的复杂性而创建的.Spring使用基本的JavaBean来完成以前只可能由EJB完成的事情.然而, ...

  4. Spring history、design philosophy (Spring的历史及设计理念)

    一,Spring的发展史 1,Spring1.x 时代 在Spring1.x时代,都是通过xml文件配置bean,随着项目的不断扩大,需要将xml配置分放到不同的配置文件中,需要频繁的在java类和x ...

  5. Spring Taco Cloud——design视图的创建(含thymeleaf模板遇到的一些小问题)

    先来看下综合前两篇内容加上本次视图的成果   可能不是很美观,因为并没有加css样式,我想等整个项目有个差不多的功能实现后再进行页面优化,请谅解 下面我贴上自己定义修改过的Taco的design视图代 ...

  6. design philosophy

  7. A Proof of Stake Design Philosophy - PoS权益证明设计理念

    之前在EthFans上看到了关于PoS(权益证明)的相关文章(原文链接),本着学习的态度,对这篇文章进行了翻译.第一次翻译关于区块链的文章,有些单词及句子的措辞还不是很准确,如果发现有翻译的不恰当的地 ...

  8. SpringMVC执行流程及源码分析

    SpringMVC流程及源码分析 前言 ​ 学了一遍SpringMVC以后,想着做一个总结,复习一下.复习写下面的总结的时候才发现,其实自己学的并不彻底.牢固.也没有学全,视频跟书本是要结合起来一起, ...

  9. Chapter 4: Spring and AOP:Spring's AOP Framework -- draft

    Spring's AOP Framework Let's begin by looking at Spring's own AOP framework - a proxy-based framewor ...

随机推荐

  1. NPOI 读取excel的时候,时间格式的处理

    excel的时间格式是:CellType.Numeric 要判断时间还需要方法:DateUtil.IsCellDateFormatted(cell)的帮助: 示例代码如下: ICell cell = ...

  2. Running Tensorflow on AMD GPU

    keras+tensorflow: based on AMD GPU https://rustyonrampage.github.io/deep-learning/2018/10/18/tensorf ...

  3. python实现压缩当前文件夹下的所有文件

    import os import zipfile def zipDir(dirpath, outFullName): ''' 压缩指定文件夹 :param dirpath: 目标文件夹路径 :para ...

  4. 使用extjs的页面弹出窗口宽度不能自适应如何解决?

    1.资源趋势详情下钻页面宽度不能自适应,无法点击关闭按钮 var detailWindow = Ext.create("App.view.com.huawei.drp.qoe.vivid.C ...

  5. Rollup.js 实践

    音乐分享: B.o.B Ft. Marko Penn - <Roll up> ——————————————————————————————————————————————————————— ...

  6. WPF 10天修炼 第五天- 内容控件

    WPF内容控件 在WPF中,所有呈现在用户界面上的对象都称为用户界面元素.但是只有派生自System.Windows.Controls.Control类的对象才称为控件.内容控件通常是指具有Conte ...

  7. 彻底搞懂 C# 的 async/await

    前言 Talk is cheap, Show you the code first! private void button1_Click(object sender, EventArgs e) { ...

  8. JMM以及并发三大特性介绍(包括解决方案)

    JMM结构图: JMM对同步的8种操作: JMM的同步规则: Countdownlatch介绍: 该类功能是可以阻塞线程,并在保证线程满足特定条件下,继续执行.如上图,Countdownlatch的c ...

  9. Linux搭建NodeJs环境

    文件下载与解压 文件下载 wget https://npm.taobao.org/mirrors/node/v6.10.3/node-v6.10.3-linux-x64.tar.xz 如果要下载最新版 ...

  10. EtherNet/IP 协议结构

    一.Ethernet/IP 协议 将标准的TCP/IP以太网延伸 到工业实时控制并和通用工业协议(CIP)结合,将很好地帮助用户获得更加开放集成的工业自动化和信息化的整体解决方案.EtherNet/I ...