@FunctionalInterface public interface TenantResolver
Modifier and Type | Field and Description |
---|---|
static String |
CONTEXT_KEY
Default
Context resource reference |
Modifier and Type | Method and Description |
---|---|
static <V> V |
execute(String tenantId,
Callable<V> operation)
Execute given
Callable operation on behalf of given tenantId , binding to
current thread a static TenantResolver context resource with default CONTEXT_KEY
key providing the specified tenant id. |
static void |
execute(String tenantId,
Runnable operation)
Execute given
Runnable operation on behalf of given tenantId , binding to
current thread a static TenantResolver context resource with default CONTEXT_KEY
key providing the specified tenant id. |
static Optional<TenantResolver> |
getCurrent()
Convenience method to obtain the current
TenantResolver made available as Context resource, using
default ClassLoader . |
Optional<String> |
getTenantId()
Gets the current tenant id, if available
|
static TenantResolver |
staticTenantResolver(String tenantId)
Build a static
TenantResolver , returning always the given tenantId as current tenant id. |
Optional<String> getTenantId()
static Optional<TenantResolver> getCurrent()
TenantResolver
made available as Context
resource, using
default ClassLoader
.
See Context.resource(String, Class)
for details about context resources availability conditions.
static TenantResolver staticTenantResolver(String tenantId)
TenantResolver
, returning always the given tenantId
as current tenant id.tenantId
- Static tenant id to be returned by the resolverstatic void execute(String tenantId, Runnable operation) throws RuntimeException
Runnable
operation
on behalf of given tenantId
, binding to
current thread a static TenantResolver
context resource with default CONTEXT_KEY
key providing the specified tenant id.tenantId
- Tenant idoperation
- Operation to execute (not null)RuntimeException
- Exception during operation executionstatic <V> V execute(String tenantId, Callable<V> operation) throws RuntimeException
Callable
operation
on behalf of given tenantId
, binding to
current thread a static TenantResolver
context resource with default CONTEXT_KEY
key providing the specified tenant id.V
- Operation result typetenantId
- Tenant idoperation
- Operation to executeRuntimeException
- Exception during operation executionCopyright © 2019 The Holon Platform. All rights reserved.