不同的services之间调用是有可能,如我们封装了DBSerives,而LoginServices也相对独立,但初次校验Session的用户账号和密码,有可能使用到DBSerives的方法。
我在新闻组看到RO的一个范例,代码如下:
Provided that
- you have 3 services (srvcLogin, srvcOne, srvcTwo)
- these three are connected to a SessionManager
- srvcOne and srvcTwo have RequiresSession = true
- session was initialized with a call to srvcLogin
you can call srvcTwo.CalledBySrvcOne via srvcOne.CallSrvcTwo:
procedure TsrvcOne.CallSrvcTwo;
var
instance: IInterface;
factory: IROClassFactory;
srvc2: IsrvcTwo;
begin
factory := GetClassFactory('srvcTwo');
try
factory.CreateInstance(Session.SessionID, instance);
if (Supports(instance, IsrvcTwo, srvc2)) then
srvc2.CalledBySrvcOne;
finally
factory.ReleaseInstance(Session.SessionID, instance);
end;
end;
评论这张
转发至微博
我在新闻组看到RO的一个范例,代码如下:
Provided that
- you have 3 services (srvcLogin, srvcOne, srvcTwo)
- these three are connected to a SessionManager
- srvcOne and srvcTwo have RequiresSession = true
- session was initialized with a call to srvcLogin
you can call srvcTwo.CalledBySrvcOne via srvcOne.CallSrvcTwo:
procedure TsrvcOne.CallSrvcTwo;
var
instance: IInterface;
factory: IROClassFactory;
srvc2: IsrvcTwo;
begin
factory := GetClassFactory('srvcTwo');
try
factory.CreateInstance(Session.SessionID, instance);
if (Supports(instance, IsrvcTwo, srvc2)) then
srvc2.CalledBySrvcOne;
finally
factory.ReleaseInstance(Session.SessionID, instance);
end;
end;
评论这张

转发至微博