public abstract class AbstractTenantContextProvider<T extends TenantContext> extends Object implements TenantContextProvider<T>, TenantIdSetter, ProvisioningTenantContextSetter<T>
fetchTenantContext(java.lang.String) method.
It provides support for caching of the retrieved tenant contexts, which is controlled via the
tcapi.cache.timeout.seconds and tcapi.cache.max.size system properties. The caching
is by default enabled.
| Constructor and Description |
|---|
AbstractTenantContextProvider() |
| Modifier and Type | Method and Description |
|---|---|
protected abstract T |
decorate(TenantContext tc) |
protected abstract TenantContext |
fetchTenantContext(String tenantId)
Fetches the generic
TenantContext based on the supplied tenantId. |
T |
getTenantContext()
Retrieves the
TenantContext corresponding to the set earlier tenantId. |
boolean |
isTenanted()
Returns
true if the there is an available tenant. |
void |
setProvisioningTenantContext(T tenantContext)
Allows the application to set the created at provisioning time
TenantContext. |
void |
setTenantId(String tenantId)
This method allows us to set the incoming from a cookie, HTTP header or SQS
message
tenantId. |
protected abstract TenantContext fetchTenantContext(String tenantId)
TenantContext based on the supplied tenantId.tenantId - the tenant Idprotected abstract T decorate(TenantContext tc)
tc - the TenantContext generic instance which has to be decorated to a product specific TenantContextpublic T getTenantContext() throws TenantContextException
TenantContextProviderTenantContext corresponding to the set earlier tenantId.
If this method is called before/without a previous call to TenantIdConsumer.setTenantId(String), the concrete
TenantContextProvider implementation may choose to return a default TenantContext
or to throw an Exception.getTenantContext in interface TenantContextProvider<T extends TenantContext>TenantContextExceptionpublic void setTenantId(String tenantId) throws TenantContextException
TenantIdSettertenantId. This method must be called once only per work-context,
for example in a Tomcat filter or similar, and should normally be invoked before a call to
TenantContextProvider.getTenantContext() occurs. If it is called more than once per WorkContext
it will throw a TenantContextException.setTenantId in interface TenantIdSettertenantId - the tenant id, must not be nullTenantContextExceptionpublic void setProvisioningTenantContext(T tenantContext) throws TenantContextException
ProvisioningTenantContextSetterTenantContext.
This method must be called once only per work-context as part of the provisioning flow,
for example in a Tomcat filter or similar, and should normally be invoked before a
call to TenantContextProvider.getTenantContext() occurs. If it is called more
than once per WorkContext it will throw a TenantContextException.setProvisioningTenantContext in interface ProvisioningTenantContextSetter<T extends TenantContext>tenantContext - the supplied by the application TenantContext, must not be nullTenantContextExceptionpublic boolean isTenanted()
TenantContextProvidertrue if the there is an available tenant. Checks the WorkContext first - if there is no
WorkContext there is no tenant.isTenanted in interface TenantContextProvider<T extends TenantContext>Copyright © 2016 Atlassian. All rights reserved.