Versions Compared

Key

  • 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

...

getThreadLocalCarbonContext()

Obtain Obtains the PrivilegedCarbonContext by using data stored in the current Threadthread: 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.

...