您的位置:首页 > 编程语言 > Java开发

Spring.net Service 配置Remoting示例

2010-08-23 13:53 337 查看
相关概念:

SAO,CAO

SingleTon(默认),SingleCall

用Spring.net 配置发布Remoting,服务器对象不需要继承MarshByRefObject,而是一个原生的PONO(plain .net object)。spring.net在运行时创建一个proxy继承MarshByRefObject.

Client端配置及调用

<!--cao Services-->
<object id="caoCalculatorServiceOld" type="Spring.Remoting.CaoFactoryObject, Spring.Services">
<property name="RemoteTargetName" value="caoCalculator" />
<property name="ServiceUrl" value="tcp://localhost:8080" />
</object>

<r:caoFactory id="caoCalculatorService"
remoteTargetName="caoCalculator"
serviceUrl="tcp://localhost:8080" />

cs代码:
ICalculator caoCalc = (ICalculator)ctx.GetObject("caoCalculatorServiceOld");
Console.WriteLine("cao multiply:"+ caoCalc.Multiply(10, 20));

ICalculator caoNewCalc = (ICalculator)ctx.GetObject("caoCalculatorService");
Console.WriteLine("cao multiply:" + caoNewCalc.Add(10, 20));

ILease.RenewOnCallTime Property

Gets or sets the amount of time by which a call to the remote object renews the CurrentLeaseTime.

Namespace: System.Runtime.Remoting.Lifetime
Assembly: mscorlib (in mscorlib.dll)

ILease Properties

The ILease type exposes the following members.

Properties

NameDescription

CurrentLeaseTimeGets the amount of time remaining on the lease.

CurrentStateGets the current LeaseState of the lease.

InitialLeaseTimeGets or sets the initial time for the lease.

RenewOnCallTimeGets or sets the amount of time by which a call to the remote object renews the CurrentLeaseTime.

SponsorshipTimeoutGets or sets the amount of time to wait for a sponsor to return with a lease renewal time.
Top
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: