ICallContext now has a property manager ( GetPropertyManager() ). At server side the so got property manager can be used to query the remote client informations such as its IP address ( RemoteIP )

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@573 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
inoussa
2008-09-25 02:24:25 +00:00
parent d80a5005f6
commit 6f801dd3f8
9 changed files with 43 additions and 22 deletions

View File

@ -127,6 +127,7 @@ type
function GetHeaderCount(const ADirections : THeaderDirections):Integer; function GetHeaderCount(const ADirections : THeaderDirections):Integer;
function GetHeader(const AIndex : Integer) : THeaderBlock; function GetHeader(const AIndex : Integer) : THeaderBlock;
procedure ClearHeaders(const ADirection : THeaderDirection); procedure ClearHeaders(const ADirection : THeaderDirection);
function GetPropertyManager():IPropertyManager;
End; End;
TSerializationStyle = ( ssNodeSerialization, ssAttibuteSerialization ); TSerializationStyle = ( ssNodeSerialization, ssAttibuteSerialization );
@ -220,6 +221,7 @@ type
private private
FHeaderList : TObjectList; FHeaderList : TObjectList;
FFreeObjectList : TObjectList; FFreeObjectList : TObjectList;
FPropertyManager : IPropertyManager;
protected protected
procedure AddObjectToFree(const AObject : TObject); procedure AddObjectToFree(const AObject : TObject);
procedure Clear(); procedure Clear();
@ -231,10 +233,11 @@ type
function GetHeader(const AIndex : Integer) : THeaderBlock; function GetHeader(const AIndex : Integer) : THeaderBlock;
procedure ClearHeaders(const ADirection : THeaderDirection); procedure ClearHeaders(const ADirection : THeaderDirection);
procedure FreeHeader(AHeader : THeaderBlock); procedure FreeHeader(AHeader : THeaderBlock);
Public function GetPropertyManager():IPropertyManager;
public
constructor Create(); constructor Create();
destructor Destroy();override; destructor Destroy();override;
End; end;
{ TBaseRemotable } { TBaseRemotable }
TBaseRemotableClass = class of TBaseRemotable; TBaseRemotableClass = class of TBaseRemotable;
@ -2752,10 +2755,16 @@ begin
end; end;
end; end;
function TSimpleCallContext.GetPropertyManager(): IPropertyManager;
begin
Result := FPropertyManager;
end;
constructor TSimpleCallContext.Create(); constructor TSimpleCallContext.Create();
begin begin
FHeaderList := TObjectList.Create(False); FHeaderList := TObjectList.Create(False);
FFreeObjectList := TObjectList.Create(True); FFreeObjectList := TObjectList.Create(True);
FPropertyManager := TStoredPropertyManager.Create() as IPropertyManager;
end; end;
destructor TSimpleCallContext.Destroy(); destructor TSimpleCallContext.Destroy();

View File

@ -37,9 +37,6 @@ uses
IdSocketHandle, IdSocketHandle,
server_listener; server_listener;
{$INCLUDE wst.inc}
{$INCLUDE wst_delphi.inc}
type type
{ TwstIndyHttpListener } { TwstIndyHttpListener }
@ -190,6 +187,7 @@ begin
AResponseInfo.ContentType := ctntyp; AResponseInfo.ContentType := ctntyp;
frmt := Trim(ARequestInfo.Params.Values['format']); frmt := Trim(ARequestInfo.Params.Values['format']);
rqst := TRequestBuffer.Create(trgt,ctntyp,inStream,AResponseInfo.ContentStream,frmt); rqst := TRequestBuffer.Create(trgt,ctntyp,inStream,AResponseInfo.ContentStream,frmt);
rqst.GetPropertyManager().SetProperty(sREMOTE_IP,ARequestInfo.RemoteIP);
HandleServiceRequest(rqst); HandleServiceRequest(rqst);
finally finally
inStream.Free(); inStream.Free();

View File

@ -168,6 +168,8 @@ begin
locInStream.Write(buff[1],Length(buff)); locInStream.Write(buff[1],Length(buff));
locInStream.Position := 0; locInStream.Position := 0;
rqst := TRequestBuffer.Create(trgt,ctntyp,locInStream,locOutStream,frmt); rqst := TRequestBuffer.Create(trgt,ctntyp,locInStream,locOutStream,frmt);
rqst.GetPropertyManager().SetProperty(sREMOTE_IP,AContext.Binding.PeerIP);
rqst.GetPropertyManager().SetProperty(sREMOTE_PORT,IntToStr(AContext.Binding.PeerPort));
HandleServiceRequest(rqst); HandleServiceRequest(rqst);
i := locOutStream.Size; i := locOutStream.Size;
SetLength(buff,i); SetLength(buff,i);

View File

@ -17,10 +17,7 @@ interface
uses uses
Classes, SysUtils, TypInfo, Classes, SysUtils, TypInfo,
server_service_intf; base_service_intf, server_service_intf;
{$INCLUDE wst.inc}
{$INCLUDE wst_delphi.inc}
Type Type
@ -33,6 +30,7 @@ Type
FFormat : string; FFormat : string;
FContent : TStream; FContent : TStream;
FResponse : TStream; FResponse : TStream;
FPropertyManager : IPropertyManager;
protected protected
function GetTargetService():string; function GetTargetService():string;
function GetContentType():string; function GetContentType():string;
@ -40,6 +38,7 @@ Type
function GetContent():TStream; function GetContent():TStream;
function GetResponse():TStream; function GetResponse():TStream;
function GetFormat() : string; function GetFormat() : string;
function GetPropertyManager():IPropertyManager;
public public
constructor Create( constructor Create(
const ATargetService : string; const ATargetService : string;
@ -92,6 +91,11 @@ begin
Result := FFormat; Result := FFormat;
end; end;
function TRequestBuffer.GetPropertyManager(): IPropertyManager;
begin
Result := FPropertyManager;
end;
constructor TRequestBuffer.Create( constructor TRequestBuffer.Create(
const ATargetService : string; const ATargetService : string;
const AContentType : string; const AContentType : string;
@ -105,6 +109,7 @@ begin
FFormat := AFormat; FFormat := AFormat;
FContent := AContent; FContent := AContent;
FResponse := AResponse; FResponse := AResponse;
FPropertyManager := TStoredPropertyManager.Create() as IPropertyManager;
end; end;

View File

@ -19,10 +19,11 @@ uses
Classes, SysUtils, TypInfo, Contnrs, Classes, SysUtils, TypInfo, Contnrs,
base_service_intf; base_service_intf;
{$INCLUDE wst.inc} const
{$INCLUDE wst_delphi.inc} sREMOTE_IP = 'RemoteIP';
sREMOTE_PORT = 'RemotePort';
Type type
IRequestBuffer = interface; IRequestBuffer = interface;
IServerService = interface; IServerService = interface;
@ -49,6 +50,7 @@ Type
function GetContent():TStream; function GetContent():TStream;
function GetResponse():TStream; function GetResponse():TStream;
function GetFormat() : string; function GetFormat() : string;
function GetPropertyManager():IPropertyManager;
end; end;
IServerService = Interface IServerService = Interface
@ -480,6 +482,7 @@ begin
Error('No formatter for that content type : "%s"',[s]); Error('No formatter for that content type : "%s"',[s]);
try try
cllCtx := CreateCallContext(); cllCtx := CreateCallContext();
cllCtx.GetPropertyManager().Copy(ARequestBuffer.GetPropertyManager(),False);
DoProcessMessage(msBeforeDeserialize,cllCtx,ARequestBuffer); DoProcessMessage(msBeforeDeserialize,cllCtx,ARequestBuffer);
strm := ARequestBuffer.GetContent(); strm := ARequestBuffer.GetContent();
f.LoadFromStream(strm); f.LoadFromStream(strm);

View File

@ -104,6 +104,7 @@ Type
function GetHeader(const AIndex : Integer) : THeaderBlock; function GetHeader(const AIndex : Integer) : THeaderBlock;
// ---- END >> ICallContext implementation ---- // ---- END >> ICallContext implementation ----
procedure ClearHeaders(const ADirection : THeaderDirection); procedure ClearHeaders(const ADirection : THeaderDirection);
function GetPropertyManager():IPropertyManager;
public public
(* This is the primary constructor! *) (* This is the primary constructor! *)
constructor Create( constructor Create(
@ -281,6 +282,11 @@ begin
FCallContext.ClearHeaders(ADirection); FCallContext.ClearHeaders(ADirection);
end; end;
function TBaseProxy.GetPropertyManager(): IPropertyManager;
begin
Result := FCallContext.GetPropertyManager();
end;
constructor TBaseProxy.Create( constructor TBaseProxy.Create(
const ATarget : String; const ATarget : String;
const AProtocol : IServiceProtocol const AProtocol : IServiceProtocol

View File

@ -202,6 +202,8 @@ begin
FInputStream.Write(buff[1],Length(buff)); FInputStream.Write(buff[1],Length(buff));
FInputStream.Position := 0; FInputStream.Position := 0;
rqst := TRequestBuffer.Create(trgt,ctntyp,FInputStream,FOutputStream,frmt); rqst := TRequestBuffer.Create(trgt,ctntyp,FInputStream,FOutputStream,frmt);
rqst.GetPropertyManager().SetProperty(sREMOTE_IP,FSocketObject.GetRemoteSinIP());
rqst.GetPropertyManager().SetProperty(sREMOTE_PORT,IntToStr(FSocketObject.GetRemoteSinPort()));
HandleServiceRequest(rqst); HandleServiceRequest(rqst);
i := FOutputStream.Size; i := FOutputStream.Size;
SetLength(buff,i); SetLength(buff,i);

View File

@ -38,6 +38,7 @@
-O"..\;..\..\;..\..\fcl-units\fcl-passrc\src;..\..\fcl-units\rtl\inc;..\..\wst_rtti_filter" -O"..\;..\..\;..\..\fcl-units\fcl-passrc\src;..\..\fcl-units\rtl\inc;..\..\wst_rtti_filter"
-I"..\;..\..\;..\..\fcl-units\fcl-passrc\src;..\..\fcl-units\rtl\inc;..\..\wst_rtti_filter" -I"..\;..\..\;..\..\fcl-units\fcl-passrc\src;..\..\fcl-units\rtl\inc;..\..\wst_rtti_filter"
-R"..\;..\..\;..\..\fcl-units\fcl-passrc\src;..\..\fcl-units\rtl\inc;..\..\wst_rtti_filter" -R"..\;..\..\;..\..\fcl-units\fcl-passrc\src;..\..\fcl-units\rtl\inc;..\..\wst_rtti_filter"
-DWST_HANDLE_DOC
-w-UNSAFE_TYPE -w-UNSAFE_TYPE
-w-UNSAFE_CODE -w-UNSAFE_CODE
-w-UNSAFE_CAST -w-UNSAFE_CAST

View File

@ -96,7 +96,7 @@ PackageDLLOutputDir=
PackageDCPOutputDir= PackageDCPOutputDir=
SearchPath=..\;..\..\;..\..\fcl-units\fcl-passrc\src;..\..\fcl-units\rtl\inc;..\..\wst_rtti_filter SearchPath=..\;..\..\;..\..\fcl-units\fcl-passrc\src;..\..\fcl-units\rtl\inc;..\..\wst_rtti_filter
Packages=vcl;rtl;vclx;indy;inet;xmlrtl;vclie;inetdbbde;inetdbxpress;dbrtl;dsnap;dsnapcon;vcldb;soaprtl;VclSmp;dbexpress;dbxcds;inetdb;bdertl;vcldbx;webdsnap;websnap;adortl;ibxpress;teeui;teedb;tee;dss;visualclx;visualdbclx;vclactnband;vclshlctrls;IntrawebDB_50_70;Intraweb_50_70;Rave50CLX;Rave50VCL;dclOfficeXP;FIBDBMidas7;Jcl;JclVcl;JvCoreD7R;JvSystemD7R;JvStdCtrlsD7R;JvAppFrmD7R;JvBandsD7R;JvDBD7R;JvDlgsD7R;JvBDED7R;JvCmpD7R;JvCryptD7R;JvCtrlsD7R;JvCustomD7R;JvDockingD7R;JvDotNetCtrlsD7R;JvEDID7R;JvGlobusD7R;JvHMID7R;JvInterpreterD7R;JvJansD7R;JvManagedThreadsD7R;JvMMD7R;JvNetD7R;JvPageCompsD7R;JvPluginD7R;JvPrintPreviewD7R;JvRuntimeDesignD7R;JvTimeFrameworkD7R;JvUIBD7R;JvValidatorsD7R;JvWizardD7R;JvXPCtrlsD7R;dxForumLibD7;cxLibraryVCLD7;cxPageControlVCLD7;dxBarD7;dxComnD7;dxBarDBNavD7;dxBarExtItemsD7;dxBarExtDBItemsD7;dxsbD7;dxmdsD7;dxdbtrD7;dxtrmdD7;dxorgcD7;dxdborD7;dxEdtrD7;EQTLD7;ECQDBCD7;EQDBTLD7;EQGridD7;dxGrEdD7;dxExELD7;dxELibD7;cxEditorsVCLD7;cxGridVCLD7;dxThemeD7;cxDataD7;cxGridUtilsVCLD7;dxPSCoreD7;dxPsPrVwAdvD7;dxPSLnksD7;dxPSTeeChartD7;dxPSDBTeeChartD7;dxPSdxDBTVLnkD7;dxPSdxOCLnkD7;dxPSdxDBOCLnkD7;dxPScxGridLnkD7;dxPSTLLnkD7;qrpt Packages=vcl;rtl;vclx;indy;inet;xmlrtl;vclie;inetdbbde;inetdbxpress;dbrtl;dsnap;dsnapcon;vcldb;soaprtl;VclSmp;dbexpress;dbxcds;inetdb;bdertl;vcldbx;webdsnap;websnap;adortl;ibxpress;teeui;teedb;tee;dss;visualclx;visualdbclx;vclactnband;vclshlctrls;IntrawebDB_50_70;Intraweb_50_70;Rave50CLX;Rave50VCL;dclOfficeXP;FIBDBMidas7;Jcl;JclVcl;JvCoreD7R;JvSystemD7R;JvStdCtrlsD7R;JvAppFrmD7R;JvBandsD7R;JvDBD7R;JvDlgsD7R;JvBDED7R;JvCmpD7R;JvCryptD7R;JvCtrlsD7R;JvCustomD7R;JvDockingD7R;JvDotNetCtrlsD7R;JvEDID7R;JvGlobusD7R;JvHMID7R;JvInterpreterD7R;JvJansD7R;JvManagedThreadsD7R;JvMMD7R;JvNetD7R;JvPageCompsD7R;JvPluginD7R;JvPrintPreviewD7R;JvRuntimeDesignD7R;JvTimeFrameworkD7R;JvUIBD7R;JvValidatorsD7R;JvWizardD7R;JvXPCtrlsD7R;dxForumLibD7;cxLibraryVCLD7;cxPageControlVCLD7;dxBarD7;dxComnD7;dxBarDBNavD7;dxBarExtItemsD7;dxBarExtDBItemsD7;dxsbD7;dxmdsD7;dxdbtrD7;dxtrmdD7;dxorgcD7;dxdborD7;dxEdtrD7;EQTLD7;ECQDBCD7;EQDBTLD7;EQGridD7;dxGrEdD7;dxExELD7;dxELibD7;cxEditorsVCLD7;cxGridVCLD7;dxThemeD7;cxDataD7;cxGridUtilsVCLD7;dxPSCoreD7;dxPsPrVwAdvD7;dxPSLnksD7;dxPSTeeChartD7;dxPSDBTeeChartD7;dxPSdxDBTVLnkD7;dxPSdxOCLnkD7;dxPSdxDBOCLnkD7;dxPScxGridLnkD7;dxPSTLLnkD7;qrpt
Conditionals= Conditionals=WST_HANDLE_DOC
DebugSourceDirs=C:\Programmes\lazarus\wst\trunk\fcl-units\rtl\;C:\Programmes\lazarus\wst\trunk\;C:\Programmes\lazarus\wst\trunk\fcl-units\fcl-passrc\src\ DebugSourceDirs=C:\Programmes\lazarus\wst\trunk\fcl-units\rtl\;C:\Programmes\lazarus\wst\trunk\;C:\Programmes\lazarus\wst\trunk\fcl-units\fcl-passrc\src\
UsePackages=0 UsePackages=0
[Parameters] [Parameters]
@ -134,17 +134,12 @@ OriginalFilename=
ProductName= ProductName=
ProductVersion=1.0.0.0 ProductVersion=1.0.0.0
Comments= Comments=
[Excluded Packages]
C:\Program Files\Developer Express Inc\ExpressPrinting System\Delphi 7\Lib\dxPSdxDBTLLnkD7.bpl=ExpressPrinting System ReportLink for ExpressQuantumDBTreeList by Developer Express Inc.
C:\Program Files\Developer Express Inc\ExpressPrinting System\Delphi 7\Lib\dxPSdxDBGrLnkD7.bpl=ExpressPrinting System ReportLink for ExpressQuantumGrid by Developer Express Inc.
C:\Program Files\Developer Express Inc\ExpressPrinting System\Delphi 7\Lib\dxPSdxInsLnkD7.bpl=ExpressPrinting System ReportLink for ExpressInspector by Developer Express Inc.
C:\Program Files\Developer Express Inc\ExpressPrinting System\Delphi 7\Lib\dxPSdxOILnkD7.bpl=ExpressPrinting System ReportLink for ExpressRTTIInspector by Developer Express Inc.
C:\Program Files\Developer Express Inc\ExpressPrinting System\Delphi 7\Lib\dxPSdxMVLnkD7.bpl=ExpressPrinting System ReportLink for ExpressMasterView by Developer Express Inc.
C:\Program Files\Developer Express Inc\ExpressPrinting System\Delphi 7\Lib\dxPSdxFCLnkD7.bpl=ExpressPrinting System ReportLinks for ExpressFlowChart by Developer Express Inc.
C:\Program Files\Developer Express Inc\ExpressPrinting System\Delphi 7\Lib\dxPScxSSLnkD7.bpl=ExpressPrinting System ReportLink for ExpressSpreadSheet by Developer Express Inc.
[HistoryLists\hlDebugSourcePath] [HistoryLists\hlDebugSourcePath]
Count=1 Count=1
Item0=C:\Programmes\lazarus\wst\trunk\fcl-units\rtl\;C:\Programmes\lazarus\wst\trunk\;C:\Programmes\lazarus\wst\trunk\fcl-units\fcl-passrc\src\ Item0=C:\Programmes\lazarus\wst\trunk\fcl-units\rtl\;C:\Programmes\lazarus\wst\trunk\;C:\Programmes\lazarus\wst\trunk\fcl-units\fcl-passrc\src\
[HistoryLists\hlConditionals]
Count=1
Item0=WST_HANDLE_DOC
[HistoryLists\hlUnitAliases] [HistoryLists\hlUnitAliases]
Count=1 Count=1
Item0=WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE; Item0=WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;