Spring.net 容器注入是替换(后处理器appConfigPropertyHolder)
.定义节点
下面两个都定义为键值对
<section name="DaoConfiguration" type="System.Configuration.NameValueSectionHandler"/>
<section name="DatabaseConfiguration" type="System.Configuration.NameValueSectionHandler"/> <DaoConfiguration>
The IoC container
Spring Framework (Version 1.3.)
<add key="maxResults" value=""/>
</DaoConfiguration> <DatabaseConfiguration>
<add key="connection.string" value="dsn=MyDSN;uid=sa;pwd=myPassword;"/>
</DatabaseConfiguration> .应用替换
<objects xmlns="http://www.springframework.net"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.net
http://www.springframework.net/xsd/spring-objects.xsd" > <object name="productDao" type="DaoApp.SimpleProductDao, DaoApp ">
<property name="maxResults" value="${maxResults}"/>
<property name="dbConnection" ref="myConnection"/>
</object> <object name="myConnection" type="System.Data.Odbc.OdbcConnection, System.Data">
<property name="connectionstring" value="${connection.string}"/>
</object>
<!--用于spring容器的注时替换,后处理器-->
<object name="appConfigPropertyHolder"
type="Spring.Objects.Factory.Config.PropertyPlaceholderConfigurer, Spring.Core">
<property name="configSections">
<value>DaoConfiguration,DatabaseConfiguration</value>
</property> </object>
</objects>
第二种方法,spring环境变量模式
<object name="appConfigPropertyHolder"
type="Spring.Objects.Factory.Config.PropertyPlaceholderConfigurer, Spring.Core">
<property name="configSections" value="DaoConfiguration,DatabaseConfiguration"/>
<property name="EnvironmentVariableMode" value="Override"/>
</object>
</objects>
<configuration>
The IoC container
Spring Framework (Version 1.3.)
<configSections>
<sectionGroup name="spring">
<section name="context" type="Spring.Context.Support.ContextHandler, Spring.Core"/>
</sectionGroup>
<section name="DaoConfigurationOverride" type="System.Configuration.NameValueSectionHandler"/>
</configSections>
<DaoConfigurationOverride>
<add key="productDao.maxResults" value=""/>
</DaoConfigurationOverride> <spring>
<context>
<resource uri="assembly://DaoApp/DaoApp/objects.xml"/>
</context>
</spring>
</configuration>
之后也只差应用了
<objects xmlns="http://www.springframework.net"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.net http://www.springframework.net/xsd/springobjects.xsd"
>
<object name="productDao" type="PropPlayApp.SimpleProductDao, PropPlayApp " >
<property name="maxResults" value=""/>
<property name="dbConnection" ref="myConnection"/>
<property name="log" ref="daoLog"/>
</object> <object name="daoLog" type="Spring.Objects.Factory.Config.LogFactoryObject, Spring.Core">
<property name="logName" value="DAOLogger"/>
</object> <object name="myConnection" type="System.Data.Odbc.OdbcConnection, System.Data">
<property name="connectionstring">
<value>dsn=MyDSN;uid=sa;pwd=myPassword;</value>
</property>
</object>
<object name="appConfigPropertyOverride" type="Spring.Objects.Factory.Config.PropertyOverrideConfigurer,
Spring.Core">
<property name="configSections">
<value>DaoConfigurationOverride</value>
</property>
</object>
</objects>
Spring.net 容器注入是替换(后处理器appConfigPropertyHolder)的更多相关文章
- spring boot容器加载完后执行特定操作
有时候我们需要在spring boot容器启动并加载完后,开一些线程或者一些程序来干某些事情.这时候我们需要配置ContextRefreshedEvent事件来实现我们要做的事情 1.Applicat ...
- spring启动容器加载成功后执行调用方法
需求: 由于在微服务架构中各服务之间都是通过接口调用来进行交互的,像很多的基础服务,类似字典信息其实并不需每次需要的时候再去请求接口.所以我的想法是每次启动项目的时候,容器初始化完成,就去调用一下基础 ...
- spring中 Bean的装配 Bean后处理器
- Spring Bean后处理器以及容器后处理器【转】
Bean后处理器:即当spring容器实例化Bean实例之后进行的增强处理. 容器后处理器:对容器本身进行处理,并总是在容器实例化其他任何Bean之前读取配置文件的元数据并可能修改这些数据. 一.Be ...
- 8 -- 深入使用Spring -- 1...1Bean后处理器
8.1.1 Bean后处理器(BeanPostProcessor) Bean后处理器主要负责对容器中其他Bean执行后处理,例如为容器中的目标Bean生成代理等. Bean后处理器会在Bean实例创建 ...
- 8 -- 深入使用Spring -- 1...3 容器后处理器
8.1.3 容器后处理器(BeanFactoryPostProcessor) 容器后处理器负责处理容器本身. 容器后处理器必须实现BeanFacotryPostProcessor接口.实现该接口必须实 ...
- 半夜思考之查漏补缺, Spring 中的容器后处理器
之前学 Spring 的时候 , 还没听过容器后处理器 , 但是一旦写出来 , 就会觉得似曾相识 . 容器配置器通常用于对 Spring 容器进行处理 , 并且总是在容器实例化任何其他 Bean 之前 ...
- Spring框架——后处理器
Bean的后处理 Spring容器实例化Bean实例之后进行的增强处理,关于这里的描述之前有点错误,现在来纠正一下:这个过程有点像AOP,不过我们知道AOP是对方法而言的,而Bean后处理器是针对Ja ...
- XI.spring的点点滴滴--IObjectFactoryPostProcessor(工厂后处理器)
承接上文 IObjectFactoryPostProcessor(工厂后处理器)) 前提是实现接口的对象注册给当前容器 直接继承的对象调用这个postProcessBeanFactory方法,参数为工 ...
随机推荐
- Spring AOP两种实现方式
一. AOP 概念: Spring AOP 即Aspect Oriented Programming(面向切面编程), 实现方式分为两种: 1. 注解(Annotation) 2. 配置(Config ...
- 减少TIME_WAIT时间的优化配置
减少TIME_WAIT时间的优化配置 建立TCP需要三次握手才能建立,而断开连接则需要四次握手.整个过程如下图所示: net.ipv4.tcp_max_syn_backlog=8192 增加TCP S ...
- Thread之五:线程的优先级
Java线程可以有优先级的设定,高优先级的线程比低优先级的线程有更高的几率得到执行(不完全正确,请参考下面的“线程优先级的问题“). 记住当线程的优先级没有指定时,所有线程都携带普通优先级. 优先级可 ...
- TCP/IP协议:最大传输单元MTU 和 最大分节大小MSS
MTU = MSS + TCP Header + IP Header. mtu是网络传输最大报文包. mss是网络传输数据最大值. MTU:maximum transmission unit,最大传输 ...
- Windows下编译sqlite3
一.下载 sqlite-amalgamation-3240000:sqlite源代码,主要需要头文件sqlite3.h sqlite-dll-win32-x86-3240000.zip:sqlite3 ...
- linux编辑器使用记录
超强大vim配置文件: wget http://files.cnblogs.com/ma6174/vimrc.zip unzip -f vimrc.zip -d ~/ 一.vim编辑器 进入 ...
- JavaScript中的跨域详解(二)
4.AJAX 同源政策规定,AJAX请求只能发给同源的网址,否则就报错. 除了架设服务器代理(浏览器请求同源服务器,再由后者请求外部服务),有三种方法规避这个限制. JSONP WebSocket C ...
- IDA Pro 权威指南学习笔记(十三) - 基本代码转换
IDA提供的代码转换包括: 1.将数据转换为代码 2.将代码转换为数据 3.指定一个指令序列为函数 4.更改现有函数的起始或结束地址 5.更改指令操作数的显示格式 代码显示选项 通过 Options ...
- selenium3+python3+Firefox54环境搭建
之前使用的环境:selenium2.53.6+Firefox44+Python2.7,没有问题,最近想尝试一下新的环境,就搭了个selenium3的环境,过程是挺坎坷的,花费了一天的时间,各种报错,最 ...
- quartz报错 Couldn't retrieve job because the BLOB couldn't be deserialized: null
今天线上添加定时任务之后 定时任务查询页面报出如上错误, 原因有两点 1.org.quartz.jobStore.useProperties = true 这个属性的意思存储的JobDataMaps是 ...