@groovy.transform.CompileStatic @groovy.util.logging.Slf4j class Tenants extends java.lang.Object
Helper methods for working with multi tenancy
Modifiers | Name | Description |
---|---|---|
protected static class |
Tenants.CurrentTenant |
Constructor and description |
---|
Tenants
() |
Type Params | Return Type | Name and description |
---|---|---|
|
static java.io.Serializable |
currentId()
|
|
static java.io.Serializable |
currentId(MultiTenantCapableDatastore multiTenantCapableDatastore) The current id for the given datastore |
|
static java.io.Serializable |
currentId(java.lang.Class<? extends Datastore> datastoreClass)
|
|
static void |
eachTenant(groovy.lang.Closure callable) Execute the given closure for each tenant. |
|
static void |
eachTenant(java.lang.Class<? extends Datastore> datastoreClass, groovy.lang.Closure callable) Execute the given closure for each tenant. |
|
static void |
eachTenant(MultiTenantCapableDatastore multiTenantCapableDatastore, groovy.lang.Closure callable) Execute the given closure for each tenant for the given datastore. |
|
private static void |
eachTenantInternal(Datastore datastore, groovy.lang.Closure callable) |
<T> |
static T |
withCurrent(groovy.lang.Closure<T> callable) Execute the given closure with the current tenant |
<T> |
static T |
withCurrent(java.lang.Class<? extends Datastore> datastoreClass, groovy.lang.Closure<T> callable) Execute the given closure with the current tenant |
<T> |
static T |
withId(java.io.Serializable tenantId, groovy.lang.Closure<T> callable) Execute the given closure with given tenant id |
<T> |
static T |
withId(java.lang.Class<? extends Datastore> datastoreClass, java.io.Serializable tenantId, groovy.lang.Closure<T> callable) Execute the given closure with given tenant id |
<T> |
static T |
withId(MultiTenantCapableDatastore multiTenantCapableDatastore, java.io.Serializable tenantId, groovy.lang.Closure<T> callable) Execute the given closure with given tenant id for the given datastore. |
<T> |
static T |
withoutId(groovy.lang.Closure<T> callable) Execute the given closure without any tenant id. |
<T> |
static T |
withoutId(MultiTenantCapableDatastore multiTenantCapableDatastore, groovy.lang.Closure<T> callable) Execute the given closure without tenant id for the given datastore. |
Methods inherited from class | Name |
---|---|
class java.lang.Object |
java.lang.Object#wait(long), java.lang.Object#wait(long, int), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
The current id for the given datastore
multiTenantCapableDatastore
- The multi tenant capable datastoreExecute the given closure for each tenant.
callable
- The closureExecute the given closure for each tenant.
callable
- The closureExecute the given closure for each tenant for the given datastore. This method will create a new datastore session for the scope of the call and hence is designed to be used to manage the connection life cycle
callable
- The closureExecute the given closure with the current tenant
callable
- The closureExecute the given closure with the current tenant
datastoreClass
- The datastore classcallable
- The closureExecute the given closure with given tenant id
tenantId
- The tenant idcallable
- The closureExecute the given closure with given tenant id
tenantId
- The tenant idcallable
- The closureExecute the given closure with given tenant id for the given datastore. This method will create a new datastore session for the scope of the call and hence is designed to be used to manage the connection life cycle
tenantId
- The tenant idcallable
- The closureExecute the given closure without any tenant id. In Multi tenancy mode SINGLE this will execute against the default data source. If multi tenancy mode MULTI this will execute without including the "tenantId" on any query. Use with caution.
callable
- The closureExecute the given closure without tenant id for the given datastore. This method will create a new datastore session for the scope of the call and hence is designed to be used to manage the connection life cycle
callable
- The closure