Spring.Net Remoting 相关使用
http://www.cnblogs.com/GoodHelper/archive/2009/11/19/SpringNet_Remoting.html 本博客系统转载 原文为
Spring.Services命名空间的目的是为业务服务提供位置的透明性。我们相信使用普通的接口和.NET类,用户应该可以用最简单的方式实现服务。我们也认为在将某个服务发布给客户端的时,应该只关心服务的配置,而无需关心服务的实现。在Spring.Services命名空间的支持下,可以用IoC容器中的服务导出对象将任一个普通对象发布为web服务、企业服务组件或远程对象。这里说的“普通对象”是指不继承或应用基础框架中任何特殊的基类(如MarshalByRefObject)或特性(如WebMethod)的对象。目前Spring.NET要求要发布的对象必须实现一个业务接口(按:即要发布的类必须实现某个接口,但这并非是限制,毕竟面向接口无论在什么时候都是好的编程实践)。Spring.NET的Remoting导出类会自动为其创建一个继承自MarshalByRefObject代理类。在服务端,可以将SAO类型注册为SingleCall或Singleton模式,也可以为每个对象配置生存期和租赁时间。另外,还可以将应用了AOP通知的对象发布为SAO。在客户端,可以用面向接口的最佳编程方式获取CAO的代理对象。Spring.NET还为Remoting创建了专门的schema来简化xml配置,不过我们仍然可以使用标准的schema来创建对象定义。
传统方式,在服务器需要使用RemotingConfiguration.Configure("xxx.exe.config")的方式启动服务,在客户端需要IContract contract = (IContract) Activator.GetObject ( typeof (IContract ), "tcp://localhost:1800/xxxx")的方式来注册服务。现在,一切都由Spring.NET而随之改变。
准备条件:
[Serializable]
public class Person
{
public string Name { get; set; }
public int Age { get; set; }
}
public interface IPersonContract
{
void SavePerson(Person model); Person GetPerson();
}
PersonContract
一、部署为Singleton模式:
服务端
App.config
Program
客户端
App.config
Program
运行效果:

第一次调用

第二次调用

二、部署为SingleCall模式:
修改对象的属性
<object id="personContract" type="RemotingServer.PersonContract, RemotingServer" singleton="false"/>
Program
调用

Spring.Net Remoting 相关使用的更多相关文章
- Spring Boot 2 (三):Spring Boot 2 相关开源软件
Spring Boot 2 (三):Spring Boot 2 相关开源软件 一.awesome-spring-boot Spring Boot 中文索引,这是一个专门收集 Spring Boot 相 ...
- spring boot @ConditionalOnxxx相关注解总结
Spring boot @ConditionalOnxxx相关注解总结 下面来介绍如何使用@Condition public class TestCondition implements Condit ...
- Spring cloud consul 相关前提知识
Spring boot .vs. Spring mvc spring boot extends spring mvc extends spring Spring Boot uses Spring ...
- 转-spring boot web相关配置
spring boot web相关配置 80436 spring boot集成了servlet容器,当我们在pom文件中增加spring-boot-starter-web的maven依赖时,不做任何w ...
- 记录一次Spring Data Solr相关的错误解决
记录一次Spring Data Solr相关的错误解决 生活本不易,流人遂自安 相信大家也使用过SpringDataSolr,但是在最新版的SpringDataSolr 4.0.5 RELEASE中有 ...
- Spring中AOP相关的API及源码解析
Spring中AOP相关的API及源码解析 本系列文章: 读源码,我们可以从第一行读起 你知道Spring是怎么解析配置类的吗? 配置类为什么要添加@Configuration注解? 谈谈Spring ...
- Spring以及SPringmvc相关问题: ServletContext -父子容器
总结如下: 明确了Servlet规范中ServletContext的作用和意义.此外明确一个Tomcat中多个web应用,每个人web应用有唯一的一个ServletContext(全局上下文).[例子 ...
- Spring中Aware相关接口原理
Spring中提供一些Aware相关接口,像是BeanFactoryAware. ApplicationContextAware.ResourceLoaderAware.ServletContextA ...
- spring boot web相关配置
spring boot集成了servlet容器,当我们在pom文件中增加spring-boot-starter-web的maven依赖时,不做任何web相关的配置便能提供web服务,这还得归于spri ...
随机推荐
- 【OpenCV】直方图
今天写直方图,学了几个相关函数 1. mixChannels void mixChannels(const Mat* src, int nsrc, Mat* dst, int ndst, const ...
- PHP如何随机获取一个二维数组中的一个值
获取一个数组: $awardid_list=pdo_fetchall('select id from '.tablename($this->table_award)); 这是微擎的写法哈,意思就 ...
- [Android Pro] app_process command in Android
reference to : http://blog.csdn.net/wangkaiblog/article/details/46050587 本来以为存放在/systen/bin/下的monkey ...
- August 22nd 2016 Week 35th Monday
Have you ever given any thought to your future? 你有没有为将来打算过呢? Have you ever given any thought to your ...
- 【转】深入Windows内核——C++中的消息机制
上节讲了消息的相关概念,本文将进一步聊聊C++中的消息机制. 从简单例子探析核心原理 在讲之前,我们先看一个简单例子:创建一个窗口和两个按钮,用来控制窗口的背景颜色.其效果 图1.效果图 Win32 ...
- Java使用正则表达式解析LRC歌词文件
LRC歌词是一种应用广泛的歌词文件,各主流播放器都支持. lrc歌词文本中含有两类标签: 1.标识标签(ID-tags) [ar:艺人名] [ti:曲名] [al:专辑名] [by:编者(指编辑LRC ...
- poj2492(种类并查集/各种解法)
题目链接: http://poj.org/problem?id=2492 题意: 有t组测试数据, 对于每组数据,第一行n, m分别表示昆虫的数目和接下来m行x, y, x, y表示教授判断x, y为 ...
- C#回顾 - 2.NET的IO:Path、File、FileInfo、Directory、DirectoryInfo、DriveInfo、FileSystemWatcher
1.管理文件系统 一般而言,应用程序都会有保存数据.检索数据的需求. 1.1 使用 path 类来访问文件路径 [path常用的方法]:http://www.cnblogs.com/tangg ...
- Sublime Text + CTags + Cscope (部分替代Source Insight)
CTags & cscope 下载: CTags+Cscope --- 我的百度云盘下载http://pan.baidu.com/s/1gfyPnuN ctags58.zip --- src ...
- 【译】DotNet 5.4或者说 .NET平台标准
原文:DotNet 5.4 or .NET Platform Standards 是的,你看到的确实是"DotNet 5.4".使用Visual Studio 2015 RC1 u ...