PerClientClassFactory

Overview

The PerClientClassFactory class implements the per-client class factory used for creating instances of services in a Remoting SDK server.

For every client communicating with the server, the class factory will create a new instance of the service implementation and associate it with the corresponding ClientId. The PerClientClassFactory will periodically dispose of expired service instances.

Note that all service implementation fields have to be reinitialized during service activation because otherwise their state would be undefined (i.e. these fields might contain leftover values from the previous request).

This class factory is recommended for service instances that are expensive to create and destroy. It is recommended to use this class factory when the number of clients frequently communicating with the server is limited.

To use a different instantiation mechanism, look into using one of the other class factory implementations, or create a custom class factory descending from the ClassFactory class to implement any custom logic needed.

Location


 

constructor (Type, IServiceActivator, Boolean)  protected    (declared in ExpiringClassFactory)

 

constructor(serviceClass: Type; activator: IServiceActivator; enforceSessionCheck: Boolean)

 

PerClientClassFactory(Type serviceClass, IServiceActivator activator, Boolean enforceSessionCheck)

 

Sub New(serviceClass As Type, activator As IServiceActivator, enforceSessionCheck As Boolean)

Parameters:

  • serviceClass:
  • activator:
  • enforceSessionCheck:

constructor (Type, IServiceActivator, Boolean, Int32, Boolean)

Creates a new instance of the PerClientClassFactory class.

 

constructor(serviceClass: Type; activator: IServiceActivator; enforceSessionCheck: Boolean; timeout: Int32; allowConcurrentAccess: Boolean)

 

PerClientClassFactory(Type serviceClass, IServiceActivator activator, Boolean enforceSessionCheck, Int32 timeout, Boolean allowConcurrentAccess)

 

Sub New(serviceClass As Type, activator As IServiceActivator, enforceSessionCheck As Boolean, timeout As Int32, allowConcurrentAccess As Boolean)

Parameters:

  • serviceClass:
  • activator:
  • enforceSessionCheck:
  • timeout: Timeout in seconds after which the service is considered expired
  • allowConcurrentAccess: Flag indicating whether the same service instance could be aquired more than once in any given moment of time

AcquireInstance

Acquires the service implementation instance associated with the provided ClientId.

This method might raise an InstanceBusyException if the instance is already acquired and concurrent access wasn't allowed.

 

method AcquireInstance(clientId: Guid): IROService

 

IROService AcquireInstance(Guid clientId)

 

Function AcquireInstance(clientId As Guid) As IROService

Parameters:

  • clientId: ID of the client requesting a service instance

ActivateInstance  protected    (declared in ClassFactory)

 

method ActivateInstance(clientId: Guid; instance: IROService)

 

void ActivateInstance(Guid clientId, IROService instance)

 

Sub ActivateInstance(clientId As Guid, instance As IROService)

Parameters:

  • clientId:
  • instance:

CreateInstance    (declared in ClassFactory)

 

method CreateInstance: IROService

 

IROService CreateInstance()

 

Function CreateInstance() As IROService

DeactivateInstance  protected    (declared in ClassFactory)

 

method DeactivateInstance(clientId: Guid; instance: IROService)

 

void DeactivateInstance(Guid clientId, IROService instance)

 

Sub DeactivateInstance(clientId As Guid, instance As IROService)

Parameters:

  • clientId:
  • instance:

Dispose    (declared in ExpiringClassFactory)

Stops and disposes the internal timer.

 

method Dispose

 

void Dispose()

 

Sub Dispose()

DisposeManagedResources  protected    (declared in ExpiringClassFactory)

 

method DisposeManagedResources

 

void DisposeManagedResources()

 

Sub DisposeManagedResources()

DisposeNativeResources  protected    (declared in ExpiringClassFactory)

 

method DisposeNativeResources

 

void DisposeNativeResources()

 

Sub DisposeNativeResources()

ExpireAllInstances

Expires all service implementation instances for the client with the given ClientId.

This method affects all services served by the server application that use the per-client class factory.

It is recommended to call this method on client logout to explicitly free all resources currently used by cached service implementation instances.

 

class method ExpireAllInstances(clientId: Guid)

 

static void ExpireAllInstances(Guid clientId)

 

Shared Sub ExpireAllInstances(clientId As Guid)

Parameters:

  • clientId: ClientId that should expire

ExpireInstances  protected

 

method ExpireInstances

 

void ExpireInstances()

 

Sub ExpireInstances()

ExpireInstances (Guid)

 

method ExpireInstances(clientId: Guid)

 

void ExpireInstances(Guid clientId)

 

Sub ExpireInstances(clientId As Guid)

Parameters:

  • clientId:

Finalize  protected    (declared in ExpiringClassFactory)

 

method Finalize

 

void Finalize()

 

Sub Finalize()

ReleaseInstance (Guid, IROService)    (declared in ClassFactory)

Releases a previously acquired service instance, based on the logic of the class factory implementation.

 

method ReleaseInstance(clientId: Guid; instance: IROService)

 

void ReleaseInstance(Guid clientId, IROService instance)

 

Sub ReleaseInstance(clientId As Guid, instance As IROService)

Parameters:

  • clientId:
  • instance:

ReleaseInstance (Guid, IROService)

Deactivates the service implementation instance by calling its Deactivate method and then removes it from the internal service instances list.

 

method ReleaseInstance(clientId: Guid; serviceInstance: IROService)

 

void ReleaseInstance(Guid clientId, IROService serviceInstance)

 

Sub ReleaseInstance(clientId As Guid, serviceInstance As IROService)

Parameters:

  • clientId: Client ID
  • serviceInstance: Service Instance to be deactivated and removed from the list

 

ExpireAllInstances

Expires all service implementation instances for the client with the given ClientId.

This method affects all services served by the server application that use the per-client class factory.

It is recommended to call this method on client logout to explicitly free all resources currently used by cached service implementation instances.

 

class method ExpireAllInstances(clientId: Guid)

 

static void ExpireAllInstances(Guid clientId)

 

Shared Sub ExpireAllInstances(clientId As Guid)

Parameters:

  • clientId: ClientId that should expire

 

constructor (Type, IServiceActivator, Boolean)  protected    (declared in ExpiringClassFactory)

 

constructor(serviceClass: Type; activator: IServiceActivator; enforceSessionCheck: Boolean)

 

PerClientClassFactory(Type serviceClass, IServiceActivator activator, Boolean enforceSessionCheck)

 

Sub New(serviceClass As Type, activator As IServiceActivator, enforceSessionCheck As Boolean)

Parameters:

  • serviceClass:
  • activator:
  • enforceSessionCheck:

constructor (Type, IServiceActivator, Boolean, Int32, Boolean)

Creates a new instance of the PerClientClassFactory class.

 

constructor(serviceClass: Type; activator: IServiceActivator; enforceSessionCheck: Boolean; timeout: Int32; allowConcurrentAccess: Boolean)

 

PerClientClassFactory(Type serviceClass, IServiceActivator activator, Boolean enforceSessionCheck, Int32 timeout, Boolean allowConcurrentAccess)

 

Sub New(serviceClass As Type, activator As IServiceActivator, enforceSessionCheck As Boolean, timeout As Int32, allowConcurrentAccess As Boolean)

Parameters:

  • serviceClass:
  • activator:
  • enforceSessionCheck:
  • timeout: Timeout in seconds after which the service is considered expired
  • allowConcurrentAccess: Flag indicating whether the same service instance could be aquired more than once in any given moment of time

AcquireInstance

Acquires the service implementation instance associated with the provided ClientId.

This method might raise an InstanceBusyException if the instance is already acquired and concurrent access wasn't allowed.

 

method AcquireInstance(clientId: Guid): IROService

 

IROService AcquireInstance(Guid clientId)

 

Function AcquireInstance(clientId As Guid) As IROService

Parameters:

  • clientId: ID of the client requesting a service instance

ActivateInstance  protected    (declared in ClassFactory)

 

method ActivateInstance(clientId: Guid; instance: IROService)

 

void ActivateInstance(Guid clientId, IROService instance)

 

Sub ActivateInstance(clientId As Guid, instance As IROService)

Parameters:

  • clientId:
  • instance:

CreateInstance    (declared in ClassFactory)

 

method CreateInstance: IROService

 

IROService CreateInstance()

 

Function CreateInstance() As IROService

DeactivateInstance  protected    (declared in ClassFactory)

 

method DeactivateInstance(clientId: Guid; instance: IROService)

 

void DeactivateInstance(Guid clientId, IROService instance)

 

Sub DeactivateInstance(clientId As Guid, instance As IROService)

Parameters:

  • clientId:
  • instance:

Dispose    (declared in ExpiringClassFactory)

Stops and disposes the internal timer.

 

method Dispose

 

void Dispose()

 

Sub Dispose()

DisposeManagedResources  protected    (declared in ExpiringClassFactory)

 

method DisposeManagedResources

 

void DisposeManagedResources()

 

Sub DisposeManagedResources()

DisposeNativeResources  protected    (declared in ExpiringClassFactory)

 

method DisposeNativeResources

 

void DisposeNativeResources()

 

Sub DisposeNativeResources()

ExpireInstances  protected

 

method ExpireInstances

 

void ExpireInstances()

 

Sub ExpireInstances()

ExpireInstances (Guid)

 

method ExpireInstances(clientId: Guid)

 

void ExpireInstances(Guid clientId)

 

Sub ExpireInstances(clientId As Guid)

Parameters:

  • clientId:

Finalize  protected    (declared in ExpiringClassFactory)

 

method Finalize

 

void Finalize()

 

Sub Finalize()

ReleaseInstance (Guid, IROService)    (declared in ClassFactory)

Releases a previously acquired service instance, based on the logic of the class factory implementation.

 

method ReleaseInstance(clientId: Guid; instance: IROService)

 

void ReleaseInstance(Guid clientId, IROService instance)

 

Sub ReleaseInstance(clientId As Guid, instance As IROService)

Parameters:

  • clientId:
  • instance:

ReleaseInstance (Guid, IROService)

Deactivates the service implementation instance by calling its Deactivate method and then removes it from the internal service instances list.

 

method ReleaseInstance(clientId: Guid; serviceInstance: IROService)

 

void ReleaseInstance(Guid clientId, IROService serviceInstance)

 

Sub ReleaseInstance(clientId As Guid, serviceInstance As IROService)

Parameters:

  • clientId: Client ID
  • serviceInstance: Service Instance to be deactivated and removed from the list