* Introduce ExecuteHandler in dispatcher, allows overriding

git-svn-id: trunk@28191 -
This commit is contained in:
michael 2014-07-11 06:55:36 +00:00
parent c3f24cc775
commit 0a220476a3

View File

@ -151,10 +151,11 @@ Type
FOnStartBatch: TNotifyEvent;
FOptions: TJSONRPCDispatchOptions;
Protected
// Find handler. If none found, nil is returned. Executes OnFindHandler if needed.
// On return 'DoFree' must be set to indicate that the hand
Function FindHandler(Const AClassName,AMethodName : TJSONStringType;AContext : TJSONRPCCallContext; Out FreeObject : TComponent) : TCustomJSONRPCHandler; virtual;
// Execute handler instance. This can be overridden to implement e.g. authentication globally before actually executing the handler.
Function ExecuteHandler(H: TCustomJSONRPCHandler; Params, ID: TJSONData; AContext: TJSONRPCCallContext): TJSONData; virtual;
// Execute method. Finds handler, and returns response.
Function ExecuteMethod(Const AClassName, AMethodName : TJSONStringType; Params,ID : TJSONData; AContext : TJSONRPCCallContext) : TJSONData; virtual;
// Check and Execute a single request. Exceptions are caught and converted to request error object.
@ -720,6 +721,11 @@ begin
end;
end;
Function TCustomJSONRPCDispatcher.ExecuteHandler(H : TCustomJSONRPCHandler; Params,ID: TJSONData;AContext : TJSONRPCCallContext): TJSONData;
begin
Result:=H.Execute(Params,AContext);
end;
function TCustomJSONRPCDispatcher.ExecuteMethod(Const AClassName,AMethodName: TJSONStringType;
Params,ID: TJSONData;AContext : TJSONRPCCallContext): TJSONData;
@ -737,7 +743,7 @@ begin
try
If Assigned(FOndispatchRequest) then
FOndispatchRequest(Self,AClassName,AMethodName,Params);
Result:=H.Execute(Params,AContext);
Result:=ExecuteHandler(H,Params,ID,AContext);
finally
If Assigned(FreeObject) then
FreeAndNil(FreeObject);