*PrivilegedCarbonContext.getThreadLocalCarbonContext() *performs better.
This is because, PrivilegedCarbonContext.getContext() will first try to get
the data from Axis2 MessageContext, failing which it will try
ConfigurationContext & AxisConfiguration, and only finally try to get the
data from the ThreadLocal variable. So, 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.

Generally, you should have an idea of what thread you are executing under.
So in the case of util methods, it is better to resolve the CarbonContext
outside that util method. In order to be able to properly retrieve a CC,
anyway the relevant data should be available somewhere (ThreadLocal,
AxisConfig, ConfigContext, MessageContext etc) so generally. If calling
CarbonContext.getCurrentContext returns a CC with tenant ID = -1 or tenant
domain = null, that means, some up stream code had not populated the data
needed for the CC, so you have to first look into fixing that issue.

Azeez

On Fri, Sep 21, 2012 at 10:43 PM, Anjana Fernando <[email protected]> wrote:

> *PrivilegedCarbonContext.getThreadLocalCarbonContext()*




-- 
*Afkham Azeez*
Director of Architecture; WSO2, Inc.; http://wso2.com
Member; Apache Software Foundation; http://www.apache.org/
* <http://www.apache.org/>**
email: **[email protected]* <[email protected]>* cell: +94 77 3320919
blog: **http://blog.afkham.org* <http://blog.afkham.org>*
twitter: **http://twitter.com/afkham_azeez*<http://twitter.com/afkham_azeez>
*
linked-in: **http://lk.linkedin.com/in/afkhamazeez*
*
*
*Lean . Enterprise . Middleware*
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to