Package org.wso2.carbon.context.internal
Class CarbonContextDataHolder
java.lang.Object
org.wso2.carbon.context.internal.CarbonContextDataHolder
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
FieldsModifier and TypeFieldDescriptionprotected org.wso2.carbon.registry.api.RegistryThe 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.RegistryThe 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.RegistryThe 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.RegistryThe 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.RegistryThe name of the property that stores a reference to the local repository instance of the current tenant.protected org.wso2.carbon.user.api.UserRealmThe name of the property that stores a reference to the UserRealm instance of the current tenant, as visible to a user. -
Constructor Summary
ConstructorsConstructorDescriptionCarbonContextDataHolder(CarbonContextDataHolder carbonContextHolder) Constructor that can be used to create clones. -
Method Summary
Modifier and TypeMethodDescriptionstatic voidThis method will destroy the current CarbonContext holder.voidThis will end the tenant flow and restore the previous CarbonContext.Get the accessing organization id.Get the application resident organization id.org.wso2.carbon.registry.api.Registryorg.wso2.carbon.registry.api.Registrystatic CarbonContextDataHolderMethod to obtain the current carbon context holder's base.static org.wso2.carbon.base.DiscoveryServiceMethod to obtain an instance to the Discovery Service.org.wso2.carbon.registry.api.Registryorg.wso2.carbon.registry.api.Registryorg.wso2.carbon.registry.api.RegistryGet the operation scope validation context.Method to obtain the organization id on this CarbonContext instance.getProperty(String name) Method to obtain a property on this CarbonContext instance.Method to obtain the tenant domain on this CarbonContext instance.intMethod to obtain the tenant id on this CarbonContext instance.static CarbonContextDataHolderThis method will always attempt to obtain an instance of the current CarbonContext from the thread-local copy.Method to obtain the user id on this CarbonContext instance.Method to obtain the username on this CarbonContext instance.org.wso2.carbon.user.api.UserRealmMethod to obtain the user resident organization ID on this CarbonContext instance.static voidregisterUnloadTenantTask(org.wso2.carbon.base.UnloadTenantTask unloadTenantTask) Method to register a task that will be executed when a tenant is unloaded.voidThis method will remove the current multi-tenant queue manager instance.voidsetAccessingOrganizationId(String accessingOrganizationId) Set the accessing organization id.voidsetApplicationName(String applicationName) voidsetApplicationResidentOrganizationId(String applicationResidentOrganizationId) Set the application resident organization id when the request comes in tenant perspective.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) voidsetOperationScopeValidationContext(OperationScopeValidationContext operationScopeValidationContext) Set the operation scope validation context.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.voidMethod 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) voidsetUserResidentOrganizationId(String userResidentOrganizationId) Method to set the user's resident organization id on this CarbonContext instance.voidStarts a tenant flow.voidMethod to be called when this tenant is unloaded.static voidunloadTenant(int tenantId) Method that will be called when a tenant is unloaded.
-
Field Details
-
localRepository
protected org.wso2.carbon.registry.api.Registry localRepositoryThe 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 configSystemRegistryThe 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 governanceSystemRegistryThe 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 configUserRegistryThe 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 governanceUserRegistryThe 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 userRealmThe name of the property that stores a reference to the UserRealm instance of the current tenant, as visible to a user.
-
-
Constructor Details
-
CarbonContextDataHolder
Constructor that can be used to create clones.- Parameters:
carbonContextHolder- the CarbonContext holder instance of which the clone will be created from.
-
-
Method Details
-
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
-
setApplicationName
-
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
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
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:
-
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
Method to obtain the organization id on this CarbonContext instance.- Returns:
- the organization id.
-
setOrganizationId
Method to set the organization id on this CarbonContext instance.- Parameters:
organizationId- The organization id.
-
getUserResidentOrganizationId
Method to obtain the user resident organization ID on this CarbonContext instance.- Returns:
- The organization ID.
-
setUserResidentOrganizationId
Method to set the user's resident organization id on this CarbonContext instance.- Parameters:
userResidentOrganizationId- The user's resident organization id.
-
getUsername
Method to obtain the username on this CarbonContext instance.- Returns:
- the username.
-
setUsername
Method to set the username on this CarbonContext instance.- Parameters:
username- the username.
-
getUserId
Method to obtain the user id on this CarbonContext instance.- Returns:
- the user id.
-
setUserId
Method to set the user id on this CarbonContext instance.- Parameters:
userId- the user id.
-
getTenantDomain
Method to obtain the tenant domain on this CarbonContext instance.- Returns:
- the tenant domain.
-
setTenantDomain
Method to set the tenant domain on this CarbonContext instance.- Parameters:
domain- the tenant domain.
-
getProperty
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
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.
-
setApplicationResidentOrganizationId
Set the application resident organization id when the request comes in tenant perspective.- Parameters:
applicationResidentOrganizationId- Organization id of organization where the application resides.
-
getApplicationResidentOrganizationId
Get the application resident organization id. This is set when the request comes in tenant perspective.- Returns:
- Organization id of organization where the application resides.
-
getOperationScopeValidationContext
Get the operation scope validation context.- Returns:
- OperationScopeValidationContext
-
setOperationScopeValidationContext
public void setOperationScopeValidationContext(OperationScopeValidationContext operationScopeValidationContext) Set the operation scope validation context.- Parameters:
operationScopeValidationContext- OperationScopeValidationContext
-
getAccessingOrganizationId
Get the accessing organization id. This represents the organization id of the accessing organization of the current request.- Returns:
- Accessing organization id.
-
setAccessingOrganizationId
Set the accessing organization id.- Parameters:
accessingOrganizationId- Accessing organization id.
-
destroyCurrentCarbonContextHolder
public static void destroyCurrentCarbonContextHolder()This method will destroy the current CarbonContext holder.
-