Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allowing to override TServiceFactoryClient #271

Merged
merged 2 commits into from Feb 17, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 10 additions & 2 deletions SQLite3/mORMot.pas
Expand Up @@ -13241,6 +13241,9 @@ TServiceFactoryClient = class(TServiceFactory)
property NonBlockWithoutAnswer: boolean read fNonBlockWithoutAnswer write fNonBlockWithoutAnswer;
end;

/// class-reference type (metaclass) of a TServiceFactoryClient kind
TServiceFactoryClientClass = class of TServiceFactoryClient;

/// used to lookup one method in a global list of interface-based services
TServiceContainerInterfaceMethod = record
/// one 'service.method' item, as set at URI
Expand Down Expand Up @@ -13277,6 +13280,7 @@ TServiceContainer = class(TInterfaceResolverInjected)
fListInterfaceMethod: TServiceContainerInterfaceMethods;
fListInterfaceMethods: TDynArrayHashed;
fExpectMangledURI: boolean;
fServicesFactoryClients: TServiceFactoryClientClass;
procedure SetExpectMangledURI(aValue: Boolean);
procedure SetInterfaceMethodBits(MethodNamesCSV: PUTF8Char;
IncludePseudoMethods: boolean; out bits: TServiceContainerInterfaceMethodBits);
Expand Down Expand Up @@ -13363,6 +13367,9 @@ TServiceContainer = class(TInterfaceResolverInjected)
// - if this property is set to TRUE, the mangled URI value will be expected
// instead (may enhance security) - e.g. '00amyWGct0y_ze4lIsj2Mw'
property ExpectMangledURI: boolean read fExpectMangledURI write SetExpectMangledURI;
/// the services factory client classes
// - by default, will use TServiceFactoryClient
property ServicesFactoryClients: TServiceFactoryClientClass read fServicesFactoryClients write fServicesFactoryClients;
end;

/// a callback interface used to notify a TSQLRecord modification in real time
Expand Down Expand Up @@ -54292,7 +54299,7 @@ function TServiceContainer.AddInterface(
exit;
CheckInterface(aInterfaces);
for i := 0 to high(aInterfaces) do begin
F := TServiceFactoryClient.Create(
F := ServicesFactoryClients.Create(
Rest,aInterfaces[i],aInstanceCreation,aContractExpected);
AddServiceInternal(F);
aContractExpected := ''; // supplied contract is only for the 1st interface
Expand All @@ -54305,7 +54312,7 @@ function TServiceContainer.AddInterface(aInterface: PTypeInfo;
const aContractExpected: RawUTF8): TServiceFactoryClient;
begin
CheckInterface([aInterface]);
result := TServiceFactoryClient.Create(Rest,aInterface,aInstanceCreation,aContractExpected);
result := ServicesFactoryClients.Create(Rest,aInterface,aInstanceCreation,aContractExpected);
AddServiceInternal(result);
end;

Expand All @@ -54323,6 +54330,7 @@ constructor TServiceContainer.Create(aRest: TSQLRest);
fList.CaseSensitive := false;
fListInterfaceMethods.InitSpecific(TypeInfo(TServiceContainerInterfaceMethods),
fListInterfaceMethod,djRawUTF8,nil,true);
fServicesFactoryClients := TServiceFactoryClient;
end;

destructor TServiceContainer.Destroy;
Expand Down