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方法,参数为工 ...
随机推荐
- 黄聪:如何使用Add-on SDK开发一个自己的火狐扩展
火狐开放了扩展的开发权限给程序员们,相信很多人都会希望自己做一些扩展来方便一些使用. 我最近做一些项目也需要开发一个火狐扩展,方便收集自己需要的数据,因此研究了几天怎么开发,现在已经差不多完成了,就顺 ...
- FPGA与DSP简单比较
FPGA与DSP比较 两者的优势不一样.在硬件层面,DSP是ASIC,如同CPU GPU一样,适宜于量产降低成本,缺点是(硬件)设计一旦确定,便不易于修改. 而FPGA较灵活,可以通过硬件描述语言进行 ...
- struts2学习(8)struts标签1(数据标签、控制标签)
一.struts2标签简介: struts标签很多,功能强大,这是优点: 但是缺点的话,性能方面可能会,各方面速度啊啥的会降低:有人比较测试,struts性能比jstl低很多: 二.struts2 ...
- 自己设计代理IP池
大体思路 使用redis作为队列,买了一份蘑菇代理,但是这个代理每5秒可以请求一次,我们将IP请求出来,从redis列表队列的左侧插入,要用的时候再从右侧取出,请求成功证明该IP是可用的,将该代理IP ...
- mysql 优化 (1)
提高IOPS能力的几种方法换SSD,PCIE-SSD(提高IO效率,普通SAS盘5000以内的iops,而新设备可达到数万或者数十万iops)少做IO的活(合并多次读写为一次,或者前端加内存CACHE ...
- python学习(二十) Python 中的比较:is 与 ==
Python 中的比较:is 与 == 在 Python 中会用到对象之间比较,可以用 ==,也可以用 is .但是它们的区别是什么呢? is 比较的是两个实例对象是不是完全相同,它们是不是同一个对象 ...
- 设计模式—三种工厂模式(JAVA)
一:简单工厂: 有一个实际工厂,这个工厂只能造一类的产品,这一类产品就是一个产品接口,会有多个具体产品实现这个接口,例 如,一个手机厂,生产苹果手机,三星手机: 缺点:在工厂类中集中了所有实例的创建逻 ...
- 5月22日上课笔记-js属性选择器、过滤选择器、鼠标事件
一.属性选择器 [attr] 包含属性 [attr=value] 属性值 [attr!=value] 属性值不等于value [attr^=value] 属性值以value开头 [attr$=valu ...
- 【UVa】439 Knight Moves(dfs)
题目 题目 分析 没有估价函数的IDA...... 代码 #include <cstdio> #include <cstring> #include <a ...
- Imply.io单机安装
安装 wget https://static.imply.io/release/imply-2.5.15.tar.gz .tar.gz -C /usr/local/ cd imply- nohup b ...