Class Factories (.NET and Delphi)
Class Factory Overview
RemObjects SDK uses so called Class Factories to control how and when instances of your service implementations will be created and destroyed, and how they will serve requests coming in from remote clients.
Each service that you define in your RODL file, and subsequently implement, will be associated with a specific type of class factory. Whenever a new request comes in from a client, its class factory will be asked to provide an available instance that can serve the request, and whenever a request is finished, that instance is released back to the class factory.
It is up to the class factory implementation itself to determine how and when to create and dispose service instances, or how to match existing instances to any given incoming request.
Available Class Factory Types
RemObjects SDK comes with a number of ready-to-use class factories that cover the most common use cases. The class factory framework is extensible, allowing you to implement your own class factories if you need more control or have a scenario not covered by the existing ones.
The class factories provided with RemObjects SDK include:
- Per-request instantiation - a new service instance will be created for each incoming request, and destroyed afterwards (default)
- Singleton - a single service instance will be used to serve all calls (with different synchronization options for thread safety)
- Pooling - a pool of instances will be maintained to server incoming requests
- Per-Client instantiation - every client will be served by a distinct service instance
Selecting the Class Factory
How RemObjects SDK determines the class factory to use for your service implementation differs slightly between the different platforms.
- In .NET, attributes are attached to the implementation class to select the appropriate class factory. The RemObjects.SDK.Server.ClassFactories namespace provides attributes for each of the available class factories. Where additional configurations are available, parameters can be passed to the attribute.
- In Delphi, a class factory is created and registered in the initialization section of the service implementation unit.
On both platforms, the default class factory used is the per-request Standard Class Factory; you can change this simply by providing the proper type name of the class factory you want to use instead.
- Namespace Lists for .NET — Java
- Interface Lists for .NET — Delphi — Java
- Protocol Lists for Xcode
- Class Lists for .NET — Xcode — Delphi — Java
- Enum Lists for .NET — Xcode — Java
- Alias Lists for Xcode — Delphi
- Implements Lists for .NET — Xcode — Delphi — Java
- Data Types
- File Types