TROPerClientClassFactory

Overview

TROPerClientClassFactory provides a class factory that ties each Service instance to a particular client.

Service instances will be associated with a client using the ClientID, and each request form the same client will be served by the same instance.

Use Case

Use this class factory if you need to persist per-client state between calls that cannot easily be stored in session data instead.

For example, incremental data fetching in DataSnap expects the state of server-side datasets to remain the same between calls, so that data retrieval can continue where the last call left off.

Location


 

constructor Create (string, TRORemotableCreatorFunc, TROInvokerClass)    (declared in TROClassFactory)

Creates a new instance of the class factory.

constructor Create(const anInterfaceName: string; aCreatorFunc: TRORemotableCreatorFunc; anInvokerClass: TROInvokerClass)

Parameters:

  • anInterfaceName: Specifies the interface name (service name) of the service to be registered. This must be the same name that clients will use to access the service.
  • aCreatorFunc: Specifies the function that will be used to create new instances of the service class, when needed. When and how often instances are created will depend on the type of the used class factory.Usually, the creator function will be auto-generated as part of the _Impl unit for your service.
  • anInvokerClass: The Invoker class to be used to invoke methods on your service.Usually, this will be the auto-generated invoker class from the _Invk unit.

constructor Create (string, TRORemotableCreatorFunc, TROInvokerClass, Cardinal)

Creates a new instance of the class factory.

constructor Create(const anInterfaceName: string; aCreatorFunc: TRORemotableCreatorFunc; anInvokerClass: TROInvokerClass; aTimeoutSeconds: Cardinal)

Parameters:

  • anInterfaceName: Specifies the interface name (service name) of the service to be registered. This must be the same name that clients will use to access the service.
  • aCreatorFunc: Specifies the function that will be used to create new instances of the service class, when needed. When and how often instances are created will depend on the type of the used class factory.Usually, the creator function will be auto-generated as part of the _Impl unit for your service.
  • anInvokerClass: The Invoker class to be used to invoke methods on your service.Usually, this will be the auto-generated invoker class from the _Invk unit.
  • aTimeoutSeconds: Timeout

CreateInstance  protected override

This method of the class factory is created whenever a new request from a client needs to be served, in order to return the service instance to serve the request. Whether the returned instance is actually created anew or obtained otherwise will depend on the type of class factory.

procedure CreateInstance(const aClientID: TGUID; out anInstance: IInterface)

Parameters:

  • aClientID: ClientID
  • anInstance: Instance

CreatorFunc    (declared in TROClassFactory)

property CreatorFunc: TRORemotableCreatorFunc read
delegate: procedure CreatorFunc(out anInstance: IInterface)

GetAliasNames  protected    (declared in TROClassFactory)

Holds a list of supported alias names.

function GetAliasNames: TStringList

GetInvoker  protected    (declared in TROClassFactory)

Returns the pointer to IROInvoker.

function GetInvoker: IROInvoker

IsInterfaceNameSupported  protected    (declared in TROClassFactory)

Verifies that the interface with the given name is supported by this class factory.

function IsInterfaceNameSupported(const anInterfaceName: string): Boolean

Parameters:

  • anInterfaceName: Interface name

RegisterInterfaceName  protected    (declared in TROClassFactory)

procedure RegisterInterfaceName(const anInterfaceName: string)

Parameters:

  • anInterfaceName:

ReleaseInstance  protected override

Called whenever a Service instance previously acquired via CreateInstance has finished processing a request. Whether the service instance is actually destroyed or saved for future use will depend on the type of class factory.

procedure ReleaseInstance(const aClientID: TGUID; var anInstance: IInterface)

Parameters:

  • aClientID: ClientID
  • anInstance: Service instance

ResetCache  protected virtual    (declared in TROClassFactory)

procedure ResetCache

TimeoutAllSessions

Manually frees all instantiated per-client Service instances, as if they had expired. All future requests will be served by newly created instances.

class procedure TimeoutAllSessions(const aClientId: TGuid)

Parameters:

  • aClientId: Client ID

TimeoutSession  protected

Manually frees instantiated per-client Service instance, as if it had expired. All future requests will be served by newly created instance.

procedure TimeoutSession(const aClientId: TGuid)

Parameters:

  • aClientId: Client ID

TimeoutSessions  protected

Manually frees all expired instantiated per-client Service instances.

procedure TimeoutSessions

UnregisterInterfaceName  protected    (declared in TROClassFactory)

procedure UnregisterInterfaceName(const anInterfaceName: string)

Parameters:

  • anInterfaceName:

 

TimeoutAllSessions

Manually frees all instantiated per-client Service instances, as if they had expired. All future requests will be served by newly created instances.

class procedure TimeoutAllSessions(const aClientId: TGuid)

Parameters:

  • aClientId: Client ID

 

constructor Create (string, TRORemotableCreatorFunc, TROInvokerClass)    (declared in TROClassFactory)

Creates a new instance of the class factory.

constructor Create(const anInterfaceName: string; aCreatorFunc: TRORemotableCreatorFunc; anInvokerClass: TROInvokerClass)

Parameters:

  • anInterfaceName: Specifies the interface name (service name) of the service to be registered. This must be the same name that clients will use to access the service.
  • aCreatorFunc: Specifies the function that will be used to create new instances of the service class, when needed. When and how often instances are created will depend on the type of the used class factory.Usually, the creator function will be auto-generated as part of the _Impl unit for your service.
  • anInvokerClass: The Invoker class to be used to invoke methods on your service.Usually, this will be the auto-generated invoker class from the _Invk unit.

constructor Create (string, TRORemotableCreatorFunc, TROInvokerClass, Cardinal)

Creates a new instance of the class factory.

constructor Create(const anInterfaceName: string; aCreatorFunc: TRORemotableCreatorFunc; anInvokerClass: TROInvokerClass; aTimeoutSeconds: Cardinal)

Parameters:

  • anInterfaceName: Specifies the interface name (service name) of the service to be registered. This must be the same name that clients will use to access the service.
  • aCreatorFunc: Specifies the function that will be used to create new instances of the service class, when needed. When and how often instances are created will depend on the type of the used class factory.Usually, the creator function will be auto-generated as part of the _Impl unit for your service.
  • anInvokerClass: The Invoker class to be used to invoke methods on your service.Usually, this will be the auto-generated invoker class from the _Invk unit.
  • aTimeoutSeconds: Timeout

CreateInstance  protected override

This method of the class factory is created whenever a new request from a client needs to be served, in order to return the service instance to serve the request. Whether the returned instance is actually created anew or obtained otherwise will depend on the type of class factory.

procedure CreateInstance(const aClientID: TGUID; out anInstance: IInterface)

Parameters:

  • aClientID: ClientID
  • anInstance: Instance

GetAliasNames  protected    (declared in TROClassFactory)

Holds a list of supported alias names.

function GetAliasNames: TStringList

GetInvoker  protected    (declared in TROClassFactory)

Returns the pointer to IROInvoker.

function GetInvoker: IROInvoker

IsInterfaceNameSupported  protected    (declared in TROClassFactory)

Verifies that the interface with the given name is supported by this class factory.

function IsInterfaceNameSupported(const anInterfaceName: string): Boolean

Parameters:

  • anInterfaceName: Interface name

RegisterInterfaceName  protected    (declared in TROClassFactory)

procedure RegisterInterfaceName(const anInterfaceName: string)

Parameters:

  • anInterfaceName:

ReleaseInstance  protected override

Called whenever a Service instance previously acquired via CreateInstance has finished processing a request. Whether the service instance is actually destroyed or saved for future use will depend on the type of class factory.

procedure ReleaseInstance(const aClientID: TGUID; var anInstance: IInterface)

Parameters:

  • aClientID: ClientID
  • anInstance: Service instance

ResetCache  protected virtual    (declared in TROClassFactory)

procedure ResetCache

TimeoutSession  protected

Manually frees instantiated per-client Service instance, as if it had expired. All future requests will be served by newly created instance.

procedure TimeoutSession(const aClientId: TGuid)

Parameters:

  • aClientId: Client ID

TimeoutSessions  protected

Manually frees all expired instantiated per-client Service instances.

procedure TimeoutSessions

UnregisterInterfaceName  protected    (declared in TROClassFactory)

procedure UnregisterInterfaceName(const anInterfaceName: string)

Parameters:

  • anInterfaceName:

 

CreatorFunc    (declared in TROClassFactory)

property CreatorFunc: TRORemotableCreatorFunc read
delegate: procedure CreatorFunc(out anInstance: IInterface)