Class CarbonContextHolderBase

java.lang.Object
org.wso2.carbon.base.CarbonContextHolderBase

public final class CarbonContextHolderBase extends Object
This class contains the singleton static references that hold the base of the Carbon Context Holder. This class is supposed to maintain a single static instance spanning across multiple class-loaders. The OSGi servlet bridge will expose this class into the OSGi world.
  • Constructor Details

    • CarbonContextHolderBase

      public CarbonContextHolderBase(CarbonContextHolderBase carbonContextHolder)
      Constructor that can be used to create clones.
      Parameters:
      carbonContextHolder - the CarbonContext holder instance of which the clone will be created from.
  • Method Details

    • getDiscoveryServiceProvider

      public static DiscoveryService getDiscoveryServiceProvider()
      Method to obtain an instance to the Discovery Service.
      Returns:
      instance of the Discovery Service
    • setDiscoveryServiceProvider

      public static void setDiscoveryServiceProvider(DiscoveryService discoveryServiceProvider)
      Method to define the instance of the Discovery Service.
      Parameters:
      discoveryServiceProvider - the Discovery Service instance.
    • getCurrentCarbonContextHolderBase

      public static CarbonContextHolderBase getCurrentCarbonContextHolderBase()
      Method to obtain the current carbon context holder's base.
      Returns:
      the current carbon context holder's base.
    • registerUnloadTenantTask

      public static void registerUnloadTenantTask(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.
    • 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.
    • 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:
      tenantDomain - 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.