On Fri, Jul 8, 2011 at 11:50 AM, Amani Soysa <[email protected]> wrote:
>
>
> On Fri, Jul 8, 2011 at 11:18 AM, Kathiravelu Pradeeban <[email protected]
> > wrote:
>
>> Hi,
>> $Subject can be found in https://wso2.org/crucible/cru/COMPONENT-51.
>> Moreover, given below is the steps to set the tenantId for your threads,
>> such that the logging component will get the tenant id for the respective
>> component/thread.
>>
>> If you are starting a new thread, you have to add this below code segment,
>> for the specific thread, to start the tenant flow, and finally end it.
>>
>> Forwarded message from Amani attached below.
>>
>>
>> Basically what we need to do is to set the tenant id in that component
>> specific thread...
>>
>> So you need to create a class extending
>> AbstractAxis2ConfigurationContextObserver (check admin console o event
>> component) and get the tenant id
>> int
>> tenantId=SuperTenantCarbonContext.getCurrentContext(configurationContext).getTenantId();
>>
>> and set the tenant id
>>
>> try {
>> SuperTenantCarbonContext.startTenantFlow()
>>
>> SuperTenantCarbonContext.getCurrentContext().setTenantId(tenantID);
>>
>> SuperTenantCarbonContext.getCurrentContext().getTenantDomain(true);
>>
>
The 2 lines above can be replaced with the following line:
SuperTenantCarbonContext.getCurrentContext().setTenantId(tenantID, true);
>
>> if (!loadedTenants.contains(tenantDomain.trim())) {
>> eventBroker.initializeTenant();
>> loadedTenants.add(tenantDomain.trim());
>> }
>>
>> } catch (Exception e) {
>> log.error("Error in setting tenant information", e);
>> } finally {
>> SuperTenantCarbonContext.endTenantFlow();
>> }
>>
>> Please go through the attached files to get a clear idea on how exactly u
>> should do it.
>>
>
> This is not the only way to set the tenantId inside the thread.It depends
> on the place where you set it ... basically when you create new threads you
> need to set the tenantId. (you only need following few lines of coding)
>
>
> try {
> SuperTenantCarbonContext.startTenantFlow()
>
> SuperTenantCarbonContext.getCurrentContext().setTenantId(tenantID);
>
> SuperTenantCarbonContext.getCurrentContext().getTenantDomain(true);
>
> //your code
>
>
> } catch (Exception e) {
> log.error("Error in setting tenant information", e);
> } finally {
> SuperTenantCarbonContext.endTenantFlow();
> }
>
>
>>
>>
>>
>> Thank you.
>> Regards,
>> Pradeeban.
>>
>>
>> --
>> Kathiravelu Pradeeban.
>> Software Engineer.
>> WSO2 Inc.
>>
>> Blog: [Llovizna] http://kkpradeeban.blogspot.com/
>>
> Regards,
> Amani
>
>
> _______________________________________________
> Carbon-dev mailing list
> [email protected]
> http://mail.wso2.org/cgi-bin/mailman/listinfo/carbon-dev
>
>
--
*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*
_______________________________________________
Carbon-dev mailing list
[email protected]
http://mail.wso2.org/cgi-bin/mailman/listinfo/carbon-dev