Kitto.DatabaseRouter
Defines the base database router and related classes and services. Database routers allow to use several databases at the same time in a single application. Models, views and specific command texts can be routed to different databases.
TKDatabaseRouter class
Abstract base database router. A database router knows how to route requests to a database among many that can be defined in the config file.
Applications can define, register and use custom routers. The default router simply routes requests to the database whose name is specified in its params.
procedure AfterConstruction;Standard construction hook (no additional initialization).
destructor Destroy;Standard destruction hook (no additional cleanup).
function GetDatabaseName(const ACallerContext: TObject;Returns a database name suitable for the specified context and params.
TKStaticDatabaseRouter class
A database router that routes everything to the database specified in its DatabaseName param. If no DatabaseName param is specified, 'Main' is assumed.
TKDatabaseRouterRegistry class
This class holds a list of registered database router classes.
class destructor Destroy;Frees the singleton registry instance.
procedure RegisterClass(const AId: string;Adds a database router class to the registry.
TKDatabaseRouterFactory class
Creates database routers by Id.
class destructor Destroy;Frees the singleton factory instance.
function CreateObject(const AClassId: string): TKDatabaseRouter;Creates and returns an instance of the database router class identified by AClassId. Raises an exception if said class is not registered.
Parameters:
AClassId— Passing '' uses the default database router.
function GetDatabaseName(const AClassId: string;Shortcut method that creates a database router, returns the result of its GetDatabaseName method and frees it automatically.
Parameters:
AClassId— Passing '' uses the default database router.
