Spring.NET学习笔记(4)-对象作用域和类型转换
一.作用域
作为对象定有生命周期,singleton和prototype是最基本的实例状态,其他三个则是对于web平台而言的。熟悉asp.net的则一看便清楚了.
作用域 | 描述 |
---|---|
singleton |
在每个Spring IoC容器中一个bean定义对应一个对象实例。 |
prototype |
一个bean定义对应多个对象实例。 |
request |
在一次HTTP请求中,一个bean定义对应一个实例;即每次HTTP请求将会有各自的bean实例, 它们依据某个bean定义创建而成。该作用域仅在基于web的Spring |
session |
在一个HTTP |
application |
在一个全局的HTTP |
以下两幅图很好的表达了singleton和prototype的概念
二.类型转换器
类型转换器是.net已经有的概念,其实类型转换器的概念在.net中用的很广,asp.net,wpf则到处是类型转换器,只不过平时大家很少用,因为基本的类型.net都帮你做了内置转换。以下是内置spring支持的类型转换器,当然也可以自己扩展,扩展的配置文件需要通过配置来扩展。
Type | Explanation |
---|---|
RuntimeTypeConverter
|
Parses strings representing System.Types to actual System.Types and the other way around.
|
FileInfoConverter
|
Capable of resolving strings to a System.IO.FileInfo object.
|
StringArrayConverter
|
Capable of resolving a comma-delimited list of strings to a string-array and vice versa. |
UriConverter
|
Capable of resolving a string representation of a Uri to an actual Uri -object.
|
CredentialConverter
|
Capable of resolving a string representation of a credential for Web client authentication into an instance of System.Net.ICredentials
|
StreamConverter
|
Capable of resolving Spring IResource Uri (string) to its corresponding InputStream -object.
|
ResourceConverter
|
Capable of resolving Spring IResource Uri (string) to an IResource object.
|
ResourceManagerConverter
|
Capable of resolving a two part string (resource name, assembly name) to a System.Resources.ResourceManager object.
|
RgbColorConverter
|
Capable of resolving a comma separated list of Red, Green, Blue integer values to a System.Drawing.Color structure.
|
ExpressionConverter
|
Capable of resolving a string into an instance of an object that implements the IExpression interface.
|
NameValueConverter
|
Capable of resolving an XML formatted string to a Specialized.NameValueCollection
|
RegexConverter
|
Capable of resolving a string into an instance of Regex
|
RegistryKeyConverter
|
Capable of resolving a string into a Microsoft.Win32.RegistryKey object.
|
这部分先了解,用到再看
Spring.NET学习笔记(4)-对象作用域和类型转换相关推荐
- Spring.NET学习笔记(5)-对象生命周期和创建者对象
一.对象生命周期 说白了就是一init初始化方法和Dispose方法 两种实现方式 1.实现接口方法(造成耦合,放弃),IInitializingObject / init-method和IDispo ...
- Spring.NET学习笔记——目录(原)
目录 前言 Spring.NET学习笔记--前言 第一阶段:控制反转与依赖注入IoC&DI Spring.NET学习笔记1--控制反转(基础篇) Level 200 Spring.NET学习笔 ...
- Spring.NET学习笔记10——方法的注入(基础篇) Level 200
多数用户都会将容器中的大部分对象布署为singleton模式.当一个singleton对象需要和另一个singleton对象协作,或者一个非singleton对象需要和另一个非singleson对象协 ...
- Spring.NET学习笔记——前言
Spring.NET是一个应用程序框架,其目的是协助开发人员创建企业级的.NET应用程序.它提供了很多方面的功能,比如依赖注入.面向方面编程(AOP).数据访问抽象及ASP.NET扩展等等.Sprin ...
- Spring Boot学习笔记-进阶(3)
文章目录 Spring Boot学习笔记-进阶(3) 一.Spring Boot与缓存 二.Spring Boot与消息 三.Spring Boot与检索 四.Spring Boot与任务 异步任务 ...
- Spring Boot学习笔记-基础(2)
Spring Boot学习笔记-基础(2) Spring Boot 优点: – 快速创建独立运行的Spring项目以及与主流框架集成 – 使用嵌入式的Servlet容器,应用无需打成WAR包 – st ...
- Spring Boot学习笔记(1)
文章目录 Spring Boot学习笔记(1) Spring Boot 整合 JSP Spring Boot HTML Thymeleaf 常用语法 Spring Boot 数据校验 Spring B ...
- Spring Cloud 学习笔记(2 / 3)
Spring Cloud 学习笔记(1 / 3) Spring Cloud 学习笔记(3 / 3) - - - 56_Hystrix之全局服务降级DefaultProperties 57_Hystri ...
- Spring Cloud 学习笔记(2 3)
Spring Cloud 学习笔记(1 / 3) Spring Cloud 学习笔记(3 / 3) - - - 56_Hystrix之全局服务降级DefaultProperties 57_Hystri ...
最新文章
- wtl中显示html,用WTL构建HTML界面应用程序(1)
- SAP PM创建/计划MO
- telegram bot 机器人 发送 加粗 斜体 字体
- 【iBoard 电子学堂 / iCore核心板教程】【verilog / modelsim 基础例程】
- javaSE各阶段练习题--工具类-常用类-递归-包装类-内部类
- C# - 创建List属性的简单方法
- Java实现MD5编码32位
- [原创]css设置禁止中文换行
- Win 下面配置 memcache
- Climbing Stairs @python
- C#判断平面中两条直线的夹角
- vs201中debug和release两个版本的区别
- NOIP2016排名(919~1419)
- 计算机应用基础网课试题及答案2020,2019-2020年度公共课计算机应用基础考试试题附答案(5页)-原创力文档...
- 北京车管所 与 换领驾驶证过程
- “第三届金融CIO班”开学典礼成功举行
- 癫痫的神经行为和临床共病:白质网络中断/损伤的作用
- 数字IC手撕代码-兆易创新笔试真题
- 【机器学习】机器学习的基本概念/术语2
- Idea 导包自动变成星号 Idea 导包自动变成*号的问题 java.io.* Idea 自动导包变成星号