TROPooledClassFactory

Overview

TROPooledClassFactory is a class factory that maintains a list of instances of server objects.

Rather than creating a separate instance for each call or always using the same instance, TROPooledClassFactory creates a predefined number of instances and returns the first one currently available to the caller.

You can control some aspects of class factory behavior via the TROPooledClassFactory.Create constructor.

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, Integer, TROPoolBehavior, Boolean)

Creates a new instance of the class factory.

constructor Create(const anInterfaceName: string; aCreatorFunc: TRORemotableCreatorFunc; anInvokerClass: TROInvokerClass; aPoolSize: Integer; aPoolBehavior: TROPoolBehavior; aPreInitializePool: Boolean)

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.
  • aPoolSize: Determines how many items will be kept in the pool.
  • aPoolBehavior: Determines what happens when a request comes in and all pooled items are busy serving a call. You can choose one of three TROPoolBehavior options.
  • aPreInitializePool: Determines whether the instances for all slots of the pool are created at startup (true) or if the pool will be filled on demand (false). For example, if you have a pool size of 10 and set this parameter to true, 10 server objects will be created immediately at startup. If you set it to false, the nth pooled object will not be created until the first time n simultaneous calls are processed. In both cases, all pooled items are not freed, but kept in the pool until the class factory is destroyed or the ClearPool method is manually called.

ClearPool  protected

Frees all objects in the pool. As new requests come in, the pool is gradually rebuilt, similarly to when the pool is first created with aPreInitializePool = false. Note that server objects that are currently serving a call will not be freed immediately, but will simply be removed from the pool. Once their calls have completed, they will be freed.

procedure ClearPool

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

UnregisterInterfaceName  protected    (declared in TROClassFactory)

procedure UnregisterInterfaceName(const anInterfaceName: string)

Parameters:

  • anInterfaceName:

 

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, Integer, TROPoolBehavior, Boolean)

Creates a new instance of the class factory.

constructor Create(const anInterfaceName: string; aCreatorFunc: TRORemotableCreatorFunc; anInvokerClass: TROInvokerClass; aPoolSize: Integer; aPoolBehavior: TROPoolBehavior; aPreInitializePool: Boolean)

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.
  • aPoolSize: Determines how many items will be kept in the pool.
  • aPoolBehavior: Determines what happens when a request comes in and all pooled items are busy serving a call. You can choose one of three TROPoolBehavior options.
  • aPreInitializePool: Determines whether the instances for all slots of the pool are created at startup (true) or if the pool will be filled on demand (false). For example, if you have a pool size of 10 and set this parameter to true, 10 server objects will be created immediately at startup. If you set it to false, the nth pooled object will not be created until the first time n simultaneous calls are processed. In both cases, all pooled items are not freed, but kept in the pool until the class factory is destroyed or the ClearPool method is manually called.

ClearPool  protected

Frees all objects in the pool. As new requests come in, the pool is gradually rebuilt, similarly to when the pool is first created with aPreInitializePool = false. Note that server objects that are currently serving a call will not be freed immediately, but will simply be removed from the pool. Once their calls have completed, they will be freed.

procedure ClearPool

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

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)