Spring.Net 学习(1)
来源:互联网 发布:学编程需要 编辑:程序博客网 时间:2024/05/22 19:19
(1)了解AOP(面向方向编程,动态代理)的概念。
(2)了解IOC(Inversion Of Control)控制反转的概念。
(3)了解DI(Dependency Injection)依赖注入的概念。
(4)掌握Remoting,类的构造函数,类的属性以及关联类在App.config中的配置方式。
(5)了解需要使用到的相关组件(Spring.Core.dll,Spring.Services.dll,EsBasic.dll,Common.Logging.dll,antlr.runtime.dll)。
服务器端:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="spring">
<section name="context" type="Spring.Context.Support.ContextHandler, Spring.Core"/>
<section name="objects" type="Spring.Context.Support.DefaultSectionHandler, Spring.Core" />
</sectionGroup>
</configSections>
<spring>
<context>
<resource uri="config://spring/objects"/>
</context>
<objects http://www.springframework.net">http://www.springframework.net" >
<object name="calculate" type="RemotingInterface.Calculate,RemotingInterface">
</object>
<object name="saoControlService" type="Spring.Remoting.SaoExporter,Spring.Services">
<property name="TargetName" value="calculate" />
<property name="ServiceName" value="Calculate" />
</object>
</objects>
</spring>
<system.runtime.remoting>
<application>
<channels>
<channel ref="tcp" port="9000" >
<serverProviders>
<provider ref="wsdl" />
<formatter ref="soap" typeFilterLevel="Full" />
<formatter ref="binary" typeFilterLevel="Full" />
</serverProviders>
<clientProviders>
<formatter ref="binary" />
</clientProviders>
</channel>
</channels>
</application>
</system.runtime.remoting>
</configuration>
启动程序:
//程序启动的时候,初始化Remoting配置
RemotingConfiguration.Configure("ServerRemoting.exe.config");
客户端:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="spring">
<section name="context" type="Spring.Context.Support.ContextHandler, Spring.Core"/>
<section name="objects" type="Spring.Context.Support.DefaultSectionHandler, Spring.Core" />
</sectionGroup>
</configSections>
<spring>
<context>
<resource uri="config://spring/objects"/>
</context>
<objects http://www.springframework.net">http://www.springframework.net" >
<object name="frmClient" type="ClientRemoting.frmCaculateClient,ClientRemoting">
<property name="Calculate" ref="remotingCalculate"/>
</object>
<!--访问Remoting ControlService-->
<object name="remotingCalculate" type="Spring.Remoting.SaoFactoryObject, Spring.Services">
<property name="ServiceInterface">
<value>RemotingInterface.ICalculate, RemotingInterface</value>
</property>
<property name="ServiceUrl" value="tcp://服务器的IP:9000/Calculate"/>
</object>
</objects>
</spring>
</configuration>
客户端需要用到的类中:
private ICalculate calculate;
public ICalculate Calculate
{
set
{
calculate = value;
}
}
其他的配置:
<!--默认实现(实现属性方式)-->
<object name="MyDataAccess" type="DataAccessComponent.DefaultDataAccess,DataAccessComponent">
<property name="Connection">
<value>Connection</value>
</property>
</object>
<!--扩展实现(自己设置值)-->
<object name="MyExtendDataAccess" type="ExtendDataAccessComponent.ExtendDataAccess,ExtendDataAccessComponent">
</object>
<!--扩展实现(构造函数)-->
<object name="MyExtendDataAccessStructure" type="ExtendDataAccessComponent.ExtendDataAccess,ExtendDataAccessComponent">
<constructor-arg index="0">
<value>192.168.3.141</value>
</constructor-arg>
</object>
<!--扩展实现(构造函数)-->
<object name="MyDog" type="DataAccessComponent.Dog,DataAccessComponent">
<constructor-arg index="0">
<value>旺财</value>
</constructor-arg>
<property name="NewFood">
<ref object="Food" />
</property>
</object>
<object name="Food" type="DataAccessComponent.Food,DataAccessComponent">
<constructor-arg index="0">
<value>肉</value>
</constructor-arg>
</object>
</objects>
<!--init-method定义一个方法名,便于类在初始化以后自动调用该程序 -->
<object name="form1" type="Demo.MyServer.Form1 ,Demo.MyServer" init-method="Initialize">
<property name="CenterService" ref="remotingCenterService"/>
<property name="ServerInformation" ref="serverInformation"/>
</object>
(2)了解IOC(Inversion Of Control)控制反转的概念。
(3)了解DI(Dependency Injection)依赖注入的概念。
(4)掌握Remoting,类的构造函数,类的属性以及关联类在App.config中的配置方式。
(5)了解需要使用到的相关组件(Spring.Core.dll,Spring.Services.dll,EsBasic.dll,Common.Logging.dll,antlr.runtime.dll)。
服务器端:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="spring">
<section name="context" type="Spring.Context.Support.ContextHandler, Spring.Core"/>
<section name="objects" type="Spring.Context.Support.DefaultSectionHandler, Spring.Core" />
</sectionGroup>
</configSections>
<spring>
<context>
<resource uri="config://spring/objects"/>
</context>
<objects http://www.springframework.net">http://www.springframework.net" >
<object name="calculate" type="RemotingInterface.Calculate,RemotingInterface">
</object>
<object name="saoControlService" type="Spring.Remoting.SaoExporter,Spring.Services">
<property name="TargetName" value="calculate" />
<property name="ServiceName" value="Calculate" />
</object>
</objects>
</spring>
<system.runtime.remoting>
<application>
<channels>
<channel ref="tcp" port="9000" >
<serverProviders>
<provider ref="wsdl" />
<formatter ref="soap" typeFilterLevel="Full" />
<formatter ref="binary" typeFilterLevel="Full" />
</serverProviders>
<clientProviders>
<formatter ref="binary" />
</clientProviders>
</channel>
</channels>
</application>
</system.runtime.remoting>
</configuration>
启动程序:
//程序启动的时候,初始化Remoting配置
RemotingConfiguration.Configure("ServerRemoting.exe.config");
客户端:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="spring">
<section name="context" type="Spring.Context.Support.ContextHandler, Spring.Core"/>
<section name="objects" type="Spring.Context.Support.DefaultSectionHandler, Spring.Core" />
</sectionGroup>
</configSections>
<spring>
<context>
<resource uri="config://spring/objects"/>
</context>
<objects http://www.springframework.net">http://www.springframework.net" >
<object name="frmClient" type="ClientRemoting.frmCaculateClient,ClientRemoting">
<property name="Calculate" ref="remotingCalculate"/>
</object>
<!--访问Remoting ControlService-->
<object name="remotingCalculate" type="Spring.Remoting.SaoFactoryObject, Spring.Services">
<property name="ServiceInterface">
<value>RemotingInterface.ICalculate, RemotingInterface</value>
</property>
<property name="ServiceUrl" value="tcp://服务器的IP:9000/Calculate"/>
</object>
</objects>
</spring>
</configuration>
客户端需要用到的类中:
private ICalculate calculate;
public ICalculate Calculate
{
set
{
calculate = value;
}
}
其他的配置:
<!--默认实现(实现属性方式)-->
<object name="MyDataAccess" type="DataAccessComponent.DefaultDataAccess,DataAccessComponent">
<property name="Connection">
<value>Connection</value>
</property>
</object>
<!--扩展实现(自己设置值)-->
<object name="MyExtendDataAccess" type="ExtendDataAccessComponent.ExtendDataAccess,ExtendDataAccessComponent">
</object>
<!--扩展实现(构造函数)-->
<object name="MyExtendDataAccessStructure" type="ExtendDataAccessComponent.ExtendDataAccess,ExtendDataAccessComponent">
<constructor-arg index="0">
<value>192.168.3.141</value>
</constructor-arg>
</object>
<!--扩展实现(构造函数)-->
<object name="MyDog" type="DataAccessComponent.Dog,DataAccessComponent">
<constructor-arg index="0">
<value>旺财</value>
</constructor-arg>
<property name="NewFood">
<ref object="Food" />
</property>
</object>
<object name="Food" type="DataAccessComponent.Food,DataAccessComponent">
<constructor-arg index="0">
<value>肉</value>
</constructor-arg>
</object>
</objects>
<!--init-method定义一个方法名,便于类在初始化以后自动调用该程序 -->
<object name="form1" type="Demo.MyServer.Form1 ,Demo.MyServer" init-method="Initialize">
<property name="CenterService" ref="remotingCenterService"/>
<property name="ServerInformation" ref="serverInformation"/>
</object>
- Spring.Net 学习(1)
- 学习Spring .net (1)
- Spring.NET学习实践(1)---Spring.NET的构架
- Spring.NET学习实践(1)---Spring.NET的构架
- Spring.Net&NHibernate 学习 1
- Spring.Net框架学习错误集锦1
- spring.net 学习一
- 学习Spring.NET、NHibernate
- 开始学习spring.net
- Spring.NET 学习笔记
- Spring.net学习
- Spring.NET学习笔记
- Spring.NET +Nibernate 学习
- spring.net学习网站
- Spring.Net 入门学习
- Spring.NET 学习总结
- Spring.Net&NHibernate 学习 4
- Spring.Net&NHibernate 学习 5
- [转]C# 中的委托和事件
- Iframe之间及iframe与父窗体之间值的传递
- 草根浙商20条经商法则:坚持看新闻联播居首位
- 中国 移动短消息中心号码大全
- RRD文件格式分析(一)
- Spring.Net 学习(1)
- Struts2拦截器的使用 (详解)
- 博文计划
- 我们的软件课程设计2(超市进销存管理系统)
- collate chinese_prc_ci_as null
- H.264 sequence_parameter_sets成员值含义
- UML基础与入门
- 传递中文url参数
- SkyEye硬件模拟平台:硬件仿真实现之四