|
From: =?iso-8859-1?Q?<jp....@ti...> - 2003-07-12 15:16:35
|
Hello Thomas,=0D=0A=0D=0AThis is very close to what I made until a few da= ys. What is wrong in this?=0D=0A=0D=0AIf two users request the same and h= ave different contexts (ie Locales), the last will change on the road the= context to use for the first. For avoiding this, I used a "run" method s= etting the context like in your exeample and calling the "execute method.= The "run" method being "synchronized".=0D=0AIn this manner, it works. Bu= t I would eliminate the need of synchronizing due to performance reasons = and for clarity. The context lifecycle is really tied to the execute meth= od and setting it as an Instance variable is a workaround threadsafe only= with synchronizing.=0D=0A=0D=0AAs long as no consensus will be, I simply= will use the three changed classes in a private package. They don't brea= k any backward compatibility, so I will use them instead of standard ones= . The problem is only that I will have to check from time to time if the = original have not changed. Secondly, I guess it's not a common need but n= evertheless a general one and early or later, passing so contextual infor= mation will be requested by developers.=0D=0A=0D=0AJean-Pierre=0D=0A=0D=0A= ---------- Initial Header -----------=0D=0A=0D=0AFrom : trisberg@tri= db.com=0D=0ATo : "jp....@ti..." <jp....@ti...>=0D= =0ACc : "jp.pawlak" <jp....@ti...>, "rod.johnson" <rod.j= oh...@in...>, kk <kk...@kk...>, springframework-developer <sp= rin...@li...>=0D=0ADate : Sat, 12 J= ul 2003 10:49:56 -0400=0D=0ASubject : Re: Re:[Springframework-developer] = Re: [Springframework-developer] Locale in rowmap?=0D=0A=0D=0AJean-Pierre,= =0D=0A=0D=0ACould you not do this without modifying the JDBC layer? Mayb= e declare a=0D=0AUserContext in the custom class and set that via a bean = setter.=0D=0A=0D=0ASomething like:=0D=0A=0D=0Apublic class SpringQuery ex= tends MappingSqlQuery {=0D=0A=0D=0A private UserContext userContext;=0D=0A= =0D=0A public SpringQuery(DataSource ds) {=0D=0A super(ds, "select co= l1, col2 from table");=0D=0A compile(); =0D=0A }=0D=0A=0D=0A protec= ted Object mapRow(ResultSet rs, int rownum) throws SQLException {=0D=0A = ....=0D=0A if (userContext.getLocale().equals("xxx")) =0D=0A = ....=0D=0A ....=0D=0A }=0D=0A=0D=0A public setUserContext(UserContex= t uc) {=0D=0A userContext =3D uc;=0D=0A }=0D=0A=0D=0A}=0D=0A=0D=0A=0D= =0AThomas=0D=0A=0D=0A> What I used also in the past is letting the DAO cr= eate a 'data-layer' list=0D=0A> and after that in business layer, iterate= the list to replace data-layer=0D=0A> elements by business-layer ones kn= owing the contextual information.=0D=0A> =0D=0A> This is certainly a bett= er school-approach, but has clearly a performance=0D=0A> drawback.=0D=0A>= =0D=0A> Letting rowmap being able to create definitive objects (indeed h= aving a user=0D=0A> defined contextual info), seems to me, for now, a bet= ter solution.=0D=0A> =0D=0A> Jean-Pierre =0D=0A> =0D=0A> ---------- Initi= al Header -----------=0D=0A> =0D=0A> From : springframework-develope= r-...@li...=0D=0A> To : "rod.johnson" <rod.joh= ns...@in...>=0D=0A> Cc : "trisberg" <tri...@tr...= >,"kk"=0D=0A> <kk...@kk...>,"springframework-developer"=0D=0A> <springfr= ame...@li...>=0D=0A> Date : Sat, 12 Jul 2= 003 12:05:19 +0200=0D=0A> Subject : [Springframework-developer] Re: [Spri= ngframework-developer] Locale=0D=0A> in rowmap?=0D=0A> =0D=0A> Hi Ken, Th= omas, Rod,=0D=0A> =0D=0A> It seems be a general miscomprehension.=0D=0A> = =0D=0A> 1) I have no intend to put any dependency between WEB and JDBC.=0D= =0A> My request is only at being able to add an optional 'Object' supplem= ental=0D=0A> attribute in execute method. The intend of this attribute is= simply to be=0D=0A> passed on rowmap.=0D=0A> =0D=0A> 2) Why cannot this = object be passed simply on the current methods?=0D=0A> Just because JDBC = has nothing to do with. It is only for rowmap method as=0D=0A> this metho= d is responsible for creating (business) objects.=0D=0A> =0D=0A> 3) Typic= al example: =0D=0A> Searching adresses. =0D=0A> =0D=0A> a)Consider the se= arched adresses are not localized on the database and=0D=0A> contain a co= untry information.=0D=0A> =0D=0A> b)The database contain only the country= code of the address.=0D=0A> =0D=0A> c)With this country code is read fro= m the database, the rowmap method will=0D=0A> have to create a Country Ob= ject to put in the Address one. This Country=0D=0A> object will have a na= me property matching with the current user to serve and=0D=0A> has nothin= g to do with the JDBC record.=0D=0A> =0D=0A> For creating the correct Cou= ntry Object, rowmap has to know the Locale to=0D=0A> serve. In this case = the new 'Object' parameter would be filled with the User=0D=0A> Locale an= d casted so in rowmap. But in others cases, it could be another=0D=0A> in= formation as the Locale.=0D=0A> =0D=0A> The main need is:=0D=0A> ROWMAP I= S RESPONSIBLE FOR CREATING OBJECTS AND FOR THIS IT CAN HAVE TO KNOW=0D=0A= > OTHER INFORMATION AS JUST THESE READ IN THE DATABASE.=0D=0A> =0D=0A> Th= is other information can be just right during the 'execution' call and=0D= =0A> cannot be in this case an instance variable. =0D=0A> =0D=0A> =0D=0A>= Regards,=0D=0A> Jean-Pierre=0D=0A> =0D=0A> ---------- Initial Header ---= --------=0D=0A> =0D=0A> From : "Rod Johnson" <rod.johnson@interface2= 1.com>=0D=0A> To : <tri...@tr...>, "Ken Krebs" <kk@kktec.c= om>=0D=0A> Cc : "JP Pawlak" <jp....@ti...>, =0D=0A>= "'springframework-developer'"=0D=0A> <spr...@li...= urceforge.net>=0D=0A> Date : Thu, 10 Jul 2003 17:55:12 +0100=0D=0A> = Subject : Re: [Springframework-developer] Locale in rowmap?=0D=0A> =0D=0A= > > I would agree with Ken here - we must avoid any dependencies between = the=0D=0A> JDBC=0D=0A> > framework and the Web framework.=0D=0A> =0D=0A> = +1. I know of several companies in the UK using JDBC only at this point.=0D= =0A> It's a great route in for Spring.=0D=0A> =0D=0A> =0D=0A> =0D=0A> =0D= =0A> ********** L'ADSL A 20 EUR/MOIS**********=0D=0A> Tiscali propose l'A= DSL le moins cher du march=E9 : 20 EUR/mois et le modem ADSL=0D=0A> offer= t ! =0D=0A> Pour profiter de cette offre exceptionnelle, cliquez ici :=0D= =0A> http://register.tiscali.fr/adsl/=0D=0A> Offre soumise =E0 conditions= .=0D=0A> =0D=0A> =0D=0A> =0D=0A> =0D=0A> --------------------------------= -----------------------=0D=0A> This SF.Net email sponsored by: Parasoft=0D= =0A> Error proof Web apps, automate testing & more.=0D=0A> Download & eva= l WebKing and get a free book.=0D=0A> www.parasoft.com/bulletproofapps1=0D= =0A> _______________________________________________=0D=0A> Springframewo= rk-developer mailing list=0D=0A> Spr...@li...= rge.net=0D=0A> https://lists.sourceforge.net/lists/listinfo/springframewo= rk-developer=0D=0A> =0D=0A> =0D=0A> ********** L'ADSL A 20 EUR/MOIS******= ****=0D=0A> Tiscali propose l'ADSL le moins cher du march=E9 : 20 EUR/moi= s et le modem ADSL=0D=0A> offert ! =0D=0A> Pour profiter de cette offre e= xceptionnelle, cliquez ici :=0D=0A> http://register.tiscali.fr/adsl/=0D=0A= > Offre soumise =E0 conditions.=0D=0A> =0D=0A> =0D=0A> =0D=0A=0D=0A=0D=0A= =0D=0A=0A=0A********** L'ADSL A 20 EUR/MOIS**********=0ATiscali propose l= 'ADSL le moins cher du march=E9 : 20 EUR/mois et le modem ADSL offert ! =0A= Pour profiter de cette offre exceptionnelle, cliquez ici : http://registe= r.tiscali.fr/adsl/=0AOffre soumise =E0 conditions.=0A |