Spring (1) -- For Simplify Java Development
来源:互联网 发布:云南大学软件学院 编辑:程序博客网 时间:2024/05/17 20:34
Spring’s primary features are dependency injection (DI) and aspect-oriented programming (AOP).
For simplify Java development, spring employs four key strategies:
1. Lightweight and minimally invasive development with plain old Java objects (POJOs).
2. Loose coupling through DI and interface orientation.
3. Declarative programming through aspects and common conventions.
4. Eliminating bolierplate code with aspects and templates.
Dependency injection
Coupling is a two-headed beast, on the one hand, tightly coupled code is difficult to test, difficult to resure and difficult to understand, on the other hand, coupling is necessary – in order to do anything useful, classes need to know about each other somehow.
With DI, objects are given their dependencies at creation time by some third party that coordinates each objects in the system.
The act of creating associations between aplication components is commonly refered to as wiring.
In a spring application, the spring application context is fully responsible for the creation of and wiring of the objects that make up the application. Spring comes with several implementations of its application context, each primarily differing only in how it loads its configuration.
Aspect-oriented programming
System are composed of several components, each responsible for a specific piece of functionality, but often these components also carry additional reponsibilities beyond their core functionality, such as logging, transaction management or security concern.
With AOP, you can then cover your core application with layers of functionality, these layers can be applied declaratively throughtout your application in a flexible manner without your core application even knowing they exist.
First, you need to declare a bean, then you refer to that bean in the element. Second, you define a pointcut element with an expression attribute set to select where the advice should be applied, the expression syntax is AspectJ’s pointcut expression language.
Template
Many activities require similar boilerplate code, JDBC, JMS, JNDI and the consumption of REST services often involve a lot of commonly repeated code.
Spring seeks to eliminate boilerplate code by encapsulating it in templates.
Spring container
In a Spring application, objects are created, are wried together, and live in the Spring container.
The container is at the core of the Spring framework.
There’s no single Spring container, Spring comes with several container implementations that can be categorized into two distinct type: Bean factories are the simplest containers, providing basic support for DI; Application context build on the nontion of a bean factory by providing application-framework services.
Application context –
XML: ClassPathXMLApplicationContext/FileSystemXMLApplicationContext
Java-Base: AnnotationConfigApplicationContext
Spring bean’s life begin with creation and remain in the application context until the application context is destroyed.
An empty container doesn’t contain anything unless you put something in it.
Spring Modules
For Spring 4.0, these modules can be arranged into six categories of functionality.
Core Spring container
Core/Beans/Context/Expression/Context support
Aspect-oriented programming
AOP/Aspects
Data access & integration
JDBC/ORM/OXM/Transaction/Messaging/JMS
Web and remoting
Web/Web servlet/Web portlet/Websocket
Instrumentation
Instrument/Instrument Tomcat
Testing
Test
- Spring (1) -- For Simplify Java Development
- Component Development for the Java Platform
- Notes for studing Java - Development preparation
- Professional Java Development with the Spring Framework
- Professional Java Development with the Spring Framework
- HDKWizard v0.1 - VCWizard For Houdini Development!
- Simplify Java Application Deployment
- [Leetcode] Simplify Path (Java)
- Simplify Path (Java)
- [LeetCode][Java] Simplify Path
- LeetCode|Simplify Path-java
- Simplify Path leetcode java
- JAVA线程——选自《Learn Java for Android Development》
- 第一章 JAVA入门_Learn Java for Android Development(第三版)
- Professional Java Development with the Spring Framework学习笔记(1) - JdbcTemplate
- Learn Java for Android Development Second Edition 笔记(一)
- Learn Java for Android Development Second Edition 笔记(二)
- Learn Java for Android Development Second Edition 笔记(三)
- sqlAlchemy学习手册(一):sqlAlchemy的安装
- 黑马程序员--#pragma mark作用
- (10.1.6)极简主义
- DNS的配置与正向查找的简单操作
- 黑马程序员——【Java反射学习】Class类的使用
- Spring (1) -- For Simplify Java Development
- 2015年百度之星程序设计大赛 - 资格赛 (1001 大搬家)
- SQL学习错误总结(一)
- 揭秘Socket与底层数据传输实现
- git删除错误的commit和push
- redHat 安装mono 错误
- 项目进行时—整理
- 如何从Windows操作系统的角度来看注册表???
- uva 1593