TROClassFactory

Overview

TROClassFactory forms the base class of all class factories provided with Remoting SDK.

Use Case

Class factories are used to register and instantiate service classes to be available for remote requests.

This is usually done by creating a new instance of a class factory in the implementation section of the service's unit by code that is auto-generated from your RODL file.

Please refer to the Class Factories topic for a more detailed discussion of available class factory types.

Location


 

constructor Create

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.

CreateInstance  protected virtual

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

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

GetAliasNames  protected

Holds a list of supported alias names.

function GetAliasNames: TStringList

GetInvoker  protected

Returns the pointer to IROInvoker.

function GetInvoker: IROInvoker

IsInterfaceNameSupported  protected

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

procedure RegisterInterfaceName(const anInterfaceName: string)

Parameters:

  • anInterfaceName:

ReleaseInstance  protected virtual

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

procedure ResetCache

UnregisterInterfaceName  protected

procedure UnregisterInterfaceName(const anInterfaceName: string)

Parameters:

  • anInterfaceName:

 

constructor Create

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.

CreateInstance  protected virtual

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

Holds a list of supported alias names.

function GetAliasNames: TStringList

GetInvoker  protected

Returns the pointer to IROInvoker.

function GetInvoker: IROInvoker

IsInterfaceNameSupported  protected

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

procedure RegisterInterfaceName(const anInterfaceName: string)

Parameters:

  • anInterfaceName:

ReleaseInstance  protected virtual

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

procedure ResetCache

UnregisterInterfaceName  protected

procedure UnregisterInterfaceName(const anInterfaceName: string)

Parameters:

  • anInterfaceName:

 

CreatorFunc

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