Package com.codename1.backend.tenancy
package com.codename1.backend.tenancy
Multi-tenancy: one deployment serving many customers whose data must never mix.
TenantContext holds the tenant of the work running on this thread.
TenantFilter sets it for each request. Two ways to keep the data apart
build on it, and an application can use either or both:
- A shared table. An entity with a
TenantIdfield is partitioned by the managed session itself: every insert is stamped with the current tenant, and every query, count, update and delete is limited to it. With no tenant set the session refuses the entity instead of answering every tenant's rows. - A database or schema per tenant.
TenantDataSourceskeeps oneDataSourceper tenant, opened on first use from a URL template.
-
ClassDescriptionA tenant-partitioned entity was used while no tenant was current.The tenant of the work running on the current thread, the backend's counterpart of Hibernate's
CurrentTenantIdentifierResolverbacked by a thread local.Work run under a tenant.OneDataSourceper tenant -- the backend's counterpart of Spring'sAbstractRoutingDataSource-- for a database, or a schema, per tenant.SetsTenantContextfor the length of each request and clears it after, whatever the handler does.Maps an authenticated principal to its tenant, forTenantFilter.authenticated(TenantFilter.PrincipalTenant).An entity being saved names a tenant other than the current one.Native SQL was attempted on a session that maps tenant-partitioned entities without opting in.Finds the tenant a request belongs to, forTenantFilter.