Package org.wso2.carbon.context.internal
Class CarbonContextDataHolder
- java.lang.Object
-
- org.wso2.carbon.context.internal.CarbonContextDataHolder
-
public final class CarbonContextDataHolder extends Object
This class will preserve an instance the current CarbonContext as a thread local variable. If a CarbonContext is available on a global-scope (i.e. HTTP Session or AxisConfiguration) this class will do the required lookup and obtain the corresponding instance. The CarbonContext provides the API for sub-tenant/super-tenant programming around WSO2 Carbon and WSO2 Stratos.
-
-
Field Summary
Fields Modifier and Type Field Description protected org.wso2.carbon.registry.api.RegistryconfigSystemRegistryThe name of the property that stores a reference to the configuration registry instance of the current tenant, as visible to the system.protected org.wso2.carbon.registry.api.RegistryconfigUserRegistryThe name of the property that stores a reference to the configuration registry instance of the current tenant, as visible to a user.protected org.wso2.carbon.registry.api.RegistrygovernanceSystemRegistryThe name of the property that stores a reference to the governance registry instance of the current tenant, as visible to the system.protected org.wso2.carbon.registry.api.RegistrygovernanceUserRegistryThe name of the property that stores a reference to the governance registry instance of the current tenant, as visible to a user.protected org.wso2.carbon.registry.api.RegistrylocalRepositoryThe name of the property that stores a reference to the local repository instance of the current tenant.protected org.wso2.carbon.user.api.UserRealmuserRealmThe name of the property that stores a reference to the UserRealm instance of the current tenant, as visible to a user.
-
Constructor Summary
Constructors Constructor Description CarbonContextDataHolder(CarbonContextDataHolder carbonContextHolder)Constructor that can be used to create clones.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static voiddestroyCurrentCarbonContextHolder()This method will destroy the current CarbonContext holder.voidendTenantFlow()This will end the tenant flow and restore the previous CarbonContext.StringgetApplicationName()org.wso2.carbon.registry.api.RegistrygetConfigSystemRegistry()org.wso2.carbon.registry.api.RegistrygetConfigUserRegistry()static CarbonContextDataHoldergetCurrentCarbonContextHolderBase()Method to obtain the current carbon context holder's base.static org.wso2.carbon.base.DiscoveryServicegetDiscoveryServiceProvider()Method to obtain an instance to the Discovery Service.org.wso2.carbon.registry.api.RegistrygetGovernanceSystemRegistry()org.wso2.carbon.registry.api.RegistrygetGovernanceUserRegistry()org.wso2.carbon.registry.api.RegistrygetLocalRepository()StringgetOrganizationId()Method to obtain the organization id on this CarbonContext instance.ObjectgetProperty(String name)Method to obtain a property on this CarbonContext instance.StringgetTenantDomain()Method to obtain the tenant domain on this CarbonContext instance.intgetTenantId()Method to obtain the tenant id on this CarbonContext instance.static CarbonContextDataHoldergetThreadLocalCarbonContextHolder()This method will always attempt to obtain an instance of the current CarbonContext from the thread-local copy.StringgetUserId()Method to obtain the user id on this CarbonContext instance.StringgetUsername()Method to obtain the username on this CarbonContext instance.org.wso2.carbon.user.api.UserRealmgetUserRealm()static voidregisterUnloadTenantTask(org.wso2.carbon.base.UnloadTenantTask unloadTenantTask)Method to register a task that will be executed when a tenant is unloaded.voidremoveQueueManager()This method will remove the current multi-tenant queue manager instance.voidsetApplicationName(String applicationName)voidsetConfigSystemRegistry(org.wso2.carbon.registry.api.Registry configSystemRegistry)voidsetConfigUserRegistry(org.wso2.carbon.registry.api.Registry configUserRegistry)static voidsetDiscoveryServiceProvider(org.wso2.carbon.base.DiscoveryService discoveryServiceProvider)Method to define the instance of the Discovery Service.voidsetGovernanceSystemRegistry(org.wso2.carbon.registry.api.Registry governanceSystemRegistry)voidsetGovernanceUserRegistry(org.wso2.carbon.registry.api.Registry governanceUserRegistry)voidsetLocalRepository(org.wso2.carbon.registry.api.Registry localRepository)voidsetOrganizationId(String organizationId)Method to set the organization id on this CarbonContext instance.voidsetProperty(String name, Object value)Method to set a property on this CarbonContext instance.voidsetQueueManager(MultitenantCarbonQueueManager queueManager)This method will set the current multi-tenant queue manager instance.voidsetTenantDomain(String domain)Method to set the tenant domain on this CarbonContext instance.voidsetTenantId(int tenantId)Method to set the tenant id on this CarbonContext instance.voidsetUserId(String userId)Method to set the user id on this CarbonContext instance.voidsetUsername(String username)Method to set the username on this CarbonContext instance.voidsetUserRealm(org.wso2.carbon.user.api.UserRealm userRealm)voidstartTenantFlow()Starts a tenant flow.voidunloadTenant()Method to be called when this tenant is unloaded.static voidunloadTenant(int tenantId)Method that will be called when a tenant is unloaded.
-
-
-
Field Detail
-
localRepository
protected org.wso2.carbon.registry.api.Registry localRepository
The name of the property that stores a reference to the local repository instance of the current tenant.
-
configSystemRegistry
protected org.wso2.carbon.registry.api.Registry configSystemRegistry
The name of the property that stores a reference to the configuration registry instance of the current tenant, as visible to the system.
-
governanceSystemRegistry
protected org.wso2.carbon.registry.api.Registry governanceSystemRegistry
The name of the property that stores a reference to the governance registry instance of the current tenant, as visible to the system.
-
configUserRegistry
protected org.wso2.carbon.registry.api.Registry configUserRegistry
The name of the property that stores a reference to the configuration registry instance of the current tenant, as visible to a user.
-
governanceUserRegistry
protected org.wso2.carbon.registry.api.Registry governanceUserRegistry
The name of the property that stores a reference to the governance registry instance of the current tenant, as visible to a user.
-
userRealm
protected org.wso2.carbon.user.api.UserRealm userRealm
The name of the property that stores a reference to the UserRealm instance of the current tenant, as visible to a user.
-
-
Constructor Detail
-
CarbonContextDataHolder
public CarbonContextDataHolder(CarbonContextDataHolder carbonContextHolder)
Constructor that can be used to create clones.- Parameters:
carbonContextHolder- the CarbonContext holder instance of which the clone will be created from.
-
-
Method Detail
-
getLocalRepository
public org.wso2.carbon.registry.api.Registry getLocalRepository()
-
setLocalRepository
public void setLocalRepository(org.wso2.carbon.registry.api.Registry localRepository)
-
getConfigSystemRegistry
public org.wso2.carbon.registry.api.Registry getConfigSystemRegistry()
-
setConfigSystemRegistry
public void setConfigSystemRegistry(org.wso2.carbon.registry.api.Registry configSystemRegistry)
-
getGovernanceSystemRegistry
public org.wso2.carbon.registry.api.Registry getGovernanceSystemRegistry()
-
setGovernanceSystemRegistry
public void setGovernanceSystemRegistry(org.wso2.carbon.registry.api.Registry governanceSystemRegistry)
-
getConfigUserRegistry
public org.wso2.carbon.registry.api.Registry getConfigUserRegistry()
-
setConfigUserRegistry
public void setConfigUserRegistry(org.wso2.carbon.registry.api.Registry configUserRegistry)
-
getGovernanceUserRegistry
public org.wso2.carbon.registry.api.Registry getGovernanceUserRegistry()
-
setGovernanceUserRegistry
public void setGovernanceUserRegistry(org.wso2.carbon.registry.api.Registry governanceUserRegistry)
-
getUserRealm
public org.wso2.carbon.user.api.UserRealm getUserRealm()
-
setUserRealm
public void setUserRealm(org.wso2.carbon.user.api.UserRealm userRealm)
-
getApplicationName
public String getApplicationName()
-
setApplicationName
public void setApplicationName(String applicationName)
-
unloadTenant
public void unloadTenant()
Method to be called when this tenant is unloaded. This will clear all the resources created by this tenant on the carbon contexts.
-
getThreadLocalCarbonContextHolder
public static CarbonContextDataHolder getThreadLocalCarbonContextHolder()
This method will always attempt to obtain an instance of the current CarbonContext from the thread-local copy.- Returns:
- the CarbonContext holder.
-
setQueueManager
public void setQueueManager(MultitenantCarbonQueueManager queueManager) throws org.wso2.carbon.queuing.QueuingException
This method will set the current multi-tenant queue manager instance.- Parameters:
queueManager- the multi-tenant queue manager.- Throws:
org.wso2.carbon.queuing.QueuingException- if the operation failed.
-
removeQueueManager
public void removeQueueManager() throws org.wso2.carbon.queuing.QueuingExceptionThis method will remove the current multi-tenant queue manager instance.- Throws:
org.wso2.carbon.queuing.QueuingException- if the operation failed.
-
getDiscoveryServiceProvider
public static org.wso2.carbon.base.DiscoveryService getDiscoveryServiceProvider()
Method to obtain an instance to the Discovery Service.- Returns:
- instance of the Discovery Service
-
setDiscoveryServiceProvider
public static void setDiscoveryServiceProvider(org.wso2.carbon.base.DiscoveryService discoveryServiceProvider)
Method to define the instance of the Discovery Service.- Parameters:
discoveryServiceProvider- the Discovery Service instance.
-
getCurrentCarbonContextHolderBase
public static CarbonContextDataHolder getCurrentCarbonContextHolderBase()
Method to obtain the current carbon context holder's base.- Returns:
- the current carbon context holder's base.
-
registerUnloadTenantTask
public static void registerUnloadTenantTask(org.wso2.carbon.base.UnloadTenantTask unloadTenantTask)
Method to register a task that will be executed when a tenant is unloaded.- Parameters:
unloadTenantTask- the task to run.- See Also:
UnloadTenantTask
-
unloadTenant
public static void unloadTenant(int tenantId)
Method that will be called when a tenant is unloaded. This will run all the corresponding tasks that have been registered to be called when a tenant is unloaded.- Parameters:
tenantId- the tenant's identifier.
-
startTenantFlow
public void startTenantFlow()
Starts a tenant flow. This will stack the current CarbonContext and begin a new nested flow which can have an entirely different context. This is ideal for scenarios where multiple super-tenant and sub-tenant phases are required within as a single block of execution.
-
endTenantFlow
public void endTenantFlow()
This will end the tenant flow and restore the previous CarbonContext.
-
getTenantId
public int getTenantId()
Method to obtain the tenant id on this CarbonContext instance.- Returns:
- the tenant id.
-
setTenantId
public void setTenantId(int tenantId)
Method to set the tenant id on this CarbonContext instance.- Parameters:
tenantId- the tenant id.
-
getOrganizationId
public String getOrganizationId()
Method to obtain the organization id on this CarbonContext instance.- Returns:
- the organization id.
-
setOrganizationId
public void setOrganizationId(String organizationId)
Method to set the organization id on this CarbonContext instance.- Parameters:
organizationId- the organization id.
-
getUsername
public String getUsername()
Method to obtain the username on this CarbonContext instance.- Returns:
- the username.
-
setUsername
public void setUsername(String username)
Method to set the username on this CarbonContext instance.- Parameters:
username- the username.
-
getUserId
public String getUserId()
Method to obtain the user id on this CarbonContext instance.- Returns:
- the user id.
-
setUserId
public void setUserId(String userId)
Method to set the user id on this CarbonContext instance.- Parameters:
userId- the user id.
-
getTenantDomain
public String getTenantDomain()
Method to obtain the tenant domain on this CarbonContext instance.- Returns:
- the tenant domain.
-
setTenantDomain
public void setTenantDomain(String domain)
Method to set the tenant domain on this CarbonContext instance.- Parameters:
domain- the tenant domain.
-
getProperty
public Object getProperty(String name)
Method to obtain a property on this CarbonContext instance.- Parameters:
name- the property name.- Returns:
- the value of the property by the given name.
-
setProperty
public void setProperty(String name, Object value)
Method to set a property on this CarbonContext instance.- Parameters:
name- the property name.value- the value to be set to the property by the given name.
-
destroyCurrentCarbonContextHolder
public static void destroyCurrentCarbonContextHolder()
This method will destroy the current CarbonContext holder.
-
-