This documentation is for WSO2 Carbon 4.2.0. View documentation for the latest release.
Page Comparison - CarbonContext API (v.23 vs v.24) - Carbon 4.2.0 - WSO2 Documentation

Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.


PrivilegedCarbonContext is a special subclass of CarbonContext, which allows you to perform privileged operations such as, setting the tenant ID and domain, starting or ending tenant flows and more. This class can only be used by Carbon components that have the permission to get hold of an instance of the PrivilegedCarbonContext. An instance of PrivilegedCarbonContext can only be obtained using the static methods outlined in Obtaining the PrivilegedCarbonContextbelow.

Obtaining the PrivilegedCarbonContext



Obtain Obtains the PrivilegedCarbonContext by using data stored in the current Threadcurrent thread: PrivilegedCarbonContext.getThreadLocalCarbonContext(). As a result, in cases like the deployers, where you can be sure that the deployment scheduler thread would set the ThreadLocal data, you should directly call the getThreadLocalCarbonContext method. You should have an idea, under which thread you are executing. It is better to resolve the CarbonContext outside that util method, as opposed to resolving the CarbonContext within the method.