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方法,参数为工 ...
随机推荐
- 算法提高 P1001【大数乘法】
当两个比较大的整数相乘时,可能会出现数据溢出的情形.为避免溢出,可以采用字符串的方法来实现两个大数之间的乘法.具体来说,首先以字符串的形式输入两个整数,每个整数的长度不会超过8位,然后把它们相乘的结果 ...
- GOF23设计模式之享元模式(flyweight)
一.享元模式概述 内存属于稀缺资源,不要随便浪费.如果有很多个完全相同或相似的对象,可以通过享元模式,节省内存. 享元模式核心: (1)享元模式可以共享的.方式高效的支持大量细粒度对象的重用: (2) ...
- POJ 2566 Bound Found(尺取法,前缀和)
Bound Found Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 5207 Accepted: 1667 Spe ...
- Linux命令之hostname - 显示或设置主机名
我使用过的Linux命令之hostname - 显示或设置主机名 本文链接:http://codingstandards.iteye.com/blog/804648 (转载请注明出处) 用途说明 ...
- python学习 (三十五) logging
1 demo import logging # log level: # DEBUG # INFO # Warning # Error # CRITICAL logging.basicConfig( ...
- 转-----FPGA工程师:持守梦想or屈于现实
昨晚无意间看到一段新闻频道对最近炒得火热的“史上最年轻教授”的专访,倒是他的一位同学对于梦想的“现实版”解说颇有些耐人寻味.大体意思是说“拼了老命考上一所梦寐以求的大学,父母辛辛苦苦交了学费,我们却 ...
- Storm概念理解
组成: Topology是Storm里的最高抽象概念,相当于Hadoop里的MapReduce,Topology(流转换图)由Spouts和Bolts组成.Spout创建Stream,Stream由无 ...
- 【Oracle】Oracle改变日志归档模式
一.确认工作模式: 1.查询V$DATABASE SQL>select log_mode from v$database; 归档日志:ARCHIVELOG 2.执 ...
- krpano之缩略图文本添加
效果: 在缩略图上添加文本,显示缩略图名称. 方法:将皮肤中的 skin_addthumbs 方法替换为一下代码. <action name="skin_addthumbs" ...
- Remote error: Provider not exported: DataSetProvider1
Remote error: Provider not exported: DataSetProvider1 是服务端的问题,ServerMethodsUnit1.cpp窗体上添加DataSetProv ...