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 ...
随机推荐
- 【python】类中的self
在python的类中,经常会写self,代表对象自己.如下例: #coding=utf-8 class Foo: def __init__(self, name): self.name = name ...
- IOS - 首次启动程序出现的画面介绍
1.在appdelegate.m中找到 “application:didFinishLaunchingWithOptions:” 通过NSUserDefaults 来进行判断 if (![[NSUse ...
- php与xpath使用操作文本节点
<?php $html="<p> 对于2014年,省统计局的统计分析显示,我省消费流通领域受诸多因素的影响,有机遇也有挑战.但值得注意的是,消费增长还存在不少制约因素,比如 ...
- 142. Linked List Cycle II
题目: Given a linked list, return the node where the cycle begins. If there is no cycle, return null. ...
- August 11th 2016, Week 33rd Thursday
A particular fine spring came around. 转眼又是一番分外明媚的春光. Hey, it is hot outside, sometimes even unbearab ...
- 查看进程,按内存从大到小 ,查看进程,按CPU利用率从大到小排序
查看进程,按内存从大到小 ps -e -o "%C : %p : %z : %a"|sort -k5 -nr 查看进程,按CPU利用率从大到小排序 ps -e -o "% ...
- Linux SNMP oid
http://www.debianadmin.com/linux-snmp-oids-for-cpumemory-and-disk-statistics.html
- 谈谈Delphi中的类和对象1---介绍几个概念 && 对象是一个地地道道的指针
参考:http://blog.163.com/liang_liu99/blog/static/88415216200952123412180/ 以下的介绍主要针对的是Delphi的面向对象的知识,可能 ...
- python中如何用dis模块来查看py的汇编代码?
之前测试不成功,用导入dis的方式. 但如何在命令行里加入 -m dis,就会OK啦. python -m dis test.py #coding: utf8 x = [1, 2, 3] for i ...
- hdu 4031 2011成都赛区网络赛A题 线段树 ***
就是不知道时间该怎么处理,想了好久,看了别人的题解发现原来是暴力,暴力也很巧妙啊,想不出来的那种 -_-! #include<cstdio> #include<iostream&g ...