there is some confusion between accessing multiple datasources to (allow access to multiple database schemas) and ThreadLocal which confines the java class variables access to the thread scope
to clear up the confusion A single thread can access one datasource with ThreadLocal variables A single thread can also access multiple datasources as long as your thread local variables are unique to that datasource e.g. datasource1 datasource2 ThreadLocal variables can be implemented in a distributed environment if you are managing the access to the object at the Thread Level you will need to consider where the values will be stored after the thread exits or otherwise reclaimed one example would be implementing ThreadLocal<Serializable> http://code.google.com/p/qdss-commons/source/browse/trunk/qdss-commons/src/java/org/qdss/commons/web/filter/AuthenticationFilter.java?spec=svn19&r=19 Martin ______________________________________________ Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen. Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni. > Date: Sun, 17 Oct 2010 12:46:22 +0000 > Subject: Re: Struts, Spring, Hibernate and multiple Sessionfactories > From: raymond.kk...@gmail.com > To: user@struts.apache.org > > 1) In this multi-tenant app, it is OK. Every operation just need to > access one tenant datasource in the thread . 2) Thread > local is not appropriate in distributed architecture. sometimes we > should access 2 or more datasourses at the same time in ONE thread. > > 2010/10/16, Dave Newton <davelnew...@gmail.com>: > > 2010/10/16 Raymond He <raymond.kk...@gmail.com>: > >> To Li Ying and Dave New ton, multiple datasources is a common > >> requirement in large scale e-commerce and telecom application. > > > > I know; that's what I said. > > > > Dave > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > > For additional commands, e-mail: user-h...@struts.apache.org > > > > > > -- > 从我的移动设备发送 > > *Kun He* (or Raymond He) > A Java Programmer > Alibaba inc. > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org >