I also see this snippet in core/org.wso2.carbon.registry.core/3.2.1/src/main/java/org/wso2/carbon/registry/core/utils/RegistryUtils.java. Are there different?
CarbonContextHolder currentContext = CarbonContextHolder.getCurrentCarbonContextHolder(); currentContext.startTenantFlow(); try { //mycode } finally { currentContext.endTenantFlow(); } } On Fri, Jul 8, 2011 at 2:48 PM, Afkham Azeez <az...@wso2.com> wrote: > > > On Fri, Jul 8, 2011 at 11:50 AM, Amani Soysa <am...@wso2.com> wrote: > >> >> >> On Fri, Jul 8, 2011 at 11:18 AM, Kathiravelu Pradeeban < >> pradee...@wso2.com> 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 >> Carbon-dev@wso2.org >> 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: **az...@wso2.com* <az...@wso2.com>* 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 > Carbon-dev@wso2.org > http://mail.wso2.org/cgi-bin/mailman/listinfo/carbon-dev > > -- Thanks, Denis ---------------------------------------------------------- *Denis Weerasiri* Software Engineer; WSO2 Inc.; http://wso2.com, *email: denis <http://goog_277208233/>** [AT] wso2.com* <http://wso2.com/>* blog: **http://ddweerasiri.blogspot.com* <http://ddweerasiri.blogspot.com/>* twitter: **http://twitter.com/ddweerasiri* <http://twitter.com/ddweerasiri>* linked-in: **http://lk.linkedin.com/in/ddweerasiri*<http://lk.linkedin.com/in/ddweerasiri>
_______________________________________________ Carbon-dev mailing list Carbon-dev@wso2.org http://mail.wso2.org/cgi-bin/mailman/listinfo/carbon-dev