Package com.sap.cloud.account
Interface TenantContext
public interface TenantContext
TenantContext
interface provides information about the tenant which is associated with the current
Thread
.-
Method Summary
Modifier and TypeMethodDescription<V> V
This method will execute callable.call() method on behalf of the specified tenant and will return the result of the called method.Deprecated.Returns all tenants subscribed to the calling application.Returns theTenant
associated with the currentThread
.Deprecated.replaced byTenant.getId()
-
Method Details
-
getTenantId
Deprecated.replaced byTenant.getId()
- Returns:
- unique ID of the tenant which is associated with the current
Thread
. - Throws:
TenantUnavailableException
- when there is no tenant context associated with the currentThread
.
-
getAccountName
Deprecated.replaced byAccount.getId()
- Returns:
- the technical representation of the account name of the current tenant which is associated with the
current
Thread
. - Throws:
TenantUnavailableException
- when there is no tenant context associated with the currentThread
.
-
getTenant
Tenant getTenant()Returns theTenant
associated with the currentThread
.- Returns:
- the current
Tenant
. - Throws:
TenantUnavailableException
- when there is no tenant associated with the current thread or the current VM is not started for a particular tenant.
-
getSubscribedTenants
Collection<Tenant> getSubscribedTenants()Returns all tenants subscribed to the calling application. Please note that a cache is used and the result will be up to date after a maximum of 5 minutes.- Returns:
- all tenants subscribed to the calling application or empty collection if there are no subscribed tenants.
-
execute
<V> V execute(String id, Callable<V> callable) throws TenantAlreadySetException, InvalidTenantException, Exception This method will execute callable.call() method on behalf of the specified tenant and will return the result of the called method. Tenant context will be cleared after execution of this method. Tenant identifier will be validated to ensure that the tenant exist and is allowed to be used by this application and on this VM.- Parameters:
id
- the tenant Id. Tenant Id is accessible viaTenant.getId()
. For example the tenant Id of the tenant which is assigned to the current thread can be accessed via#getTenantId()
.callable
- an instance on which call() method will be executed.- Returns:
- the result of callable.call() execution.
- Throws:
TenantAlreadySetException
- if execution cannot be done with the provided tenant Id.InvalidTenantException
- if there is no tenant with the given id, or if the tenant with the given id is not subscribed to the application or if the tenant id passed does not correspond to the tenant for which the current VM has been started.Exception
- any exception thrown during execution of callable.call() method.
-
Account.getId()