<div>$BJV?.$"$j$,$H$&$4$6$$$^$9!#(B</div>
<div>okdua$B$G$9!#(B</div>
<div> </div>
<div>> $B!V(BgetComponent$B$K$h$C$F<hF@$9$k!W$H$"$j$^$9$,!"$3$l$O!"(B<br>> net.arnx.jsonic.web.extension.S2Container$B%/%i%9$N(BgetComponent$B%a%=%C%I(B<br>> $B$NCf$G9T$o$l$k=hM}$r;X$7$F$$$k$N$G$7$g$&$+!)(B<br>$B?=$7Lu$"$j$^$;$s!#(B</div>
<div>net.arnx.jsonic.web.extension.S2Container$B%/%i%9$N(BgetComponent$B$r;X$7$F$$$^$7$?!#(B</div>
<div>
<div>$B!JJdB-$G$9$,!"(Bnet.arnx.jsonic.web.RESTServlet$B$NCf$G$O!"(BS2Container$B$+$i(BSingletonS2ContainerFactory$B$X(B</div>
<div>$B0Q>y$7$F(BgetComponent$B$+$i(Bcomponent$B$r<hF@$7!"JLES8F$S=P$9%a%=%C%IL>$r7hDj$7$F$+$i!"(B</div>
<div>component$B$K(Bexecute$B$r$+$1$F$$$k$h$&$G$9!#!K(B</div> </div>
<div>> SelectDataSourceInterceptor$B$O(BS2$B%3%s%F%J$KEPO?$G$-$F$$$^$9$+!)(B</div>
<div>$B$O$$!"%Q%C%1!<%8L>(B.interceptor.SelectDataSourceInterceptor$B$H$7$F:n@.$7$F$*$j$^$9!#(B</div>
<div>$B$^$?!"(Bcreator.dicon $B$K$O!"(BInterceptorCreator $B$*$h$S(B ActionCreator$B$r(B</div>
<div>$BDj5A$7$F$*$j$^$9!#(B</div>
<div>$B!J(BService/DAO$B$K$D$$$F$b!"3:Ev$N(BCreator$B$rDj5A$7!"<+F0EPO?$rMxMQ$7$F$$$^$9!#!K(B<br></div>
<div> </div>
<div>> $B%3%s%9%H%i%/%?$H(BgetComponent$B$OJLJ*$G$9$7!"$=$l$i$NA0$K<B9T$5$;$k$H$$$&$N(B<br>> $B$H$O$A$,$&$s$8$c$J$$$G$7$g$&$+!#(B<br>ActionCreator$B$rMxMQ$7$?>l9g!"(BAction$B$O(B request $B%9%3!<%W$G:n@.$5$l$k$H(B</div>
<div>$B%j%U%!%l%s%9$K$"$j$^$7$?$N$G!"$F$C$-$j(BgetComponent$B$,%3!<%k$5$l$?;~$K(B</div>
<div>$B%$%s%9%?%s%92=$r9T$C$F$$$k$b$N$H;W$C$F$$$^$7$?!#(B</div>
<div>$B$^$?!"(BAction$B%$%s%9%?%s%92=;~$K!"(BService$B$N%$%s%9%?%s%92=$b9T$o$l!"(B</div>
<div>$B99$K$=$NCf$G(BDAO$B$N%$%s%9%?%s%92=$,9T$o$l!"!"$HEAGE$9$k$b$N$H2r<a$7$F$$$^$7$?!#(B</div>
<div>$B!J%9%3!<%W$K$h$C$F(Bsingleton$B$G=`Hw$9$k$b$N$O!"%$%s%9%?%s%92=$5$l$J$$$H$$$&0UL#(B</div>
<div>$B!!$G!"873J$K$OJLJ*$HI=8=$5$l$F$$$k$N$G$7$?$i!"$9$_$^$;$s!#!K(B<br></div>
<div> </div>
<div>$B2?8N!"%3%s%9%H%i%/%?$H;d$,;W$C$?$N$+$H$$$&$H!"(B</div>
<div>$B!&(BDAO$B$rMxMQ$9$k(BAction $B!J87L)$K$O!V(BDAO$B$rMxMQ$9$k(BService$B!W$rMxMQ$9$k(BAction$B!K(B</div>
<div>$B!&(BDAO$B$rMxMQ$7$J$$(BAction</div>
<div>$B$NFs$D$G;n$7$F$_$?$H$3$m!"8e<T$N(BDAO$B$rMxMQ$7$J$$(BAction$B$G$O!"(B</div>
<div>SelectDataSourceInterceptor.invoke()$B$,<B9T$5$l$?$?$a$G$9!#(B</div>
<div>$B!J<B9T$O%V%l!<%/%]%$%s%H!u%m%0=PNO$G3NG'$7$^$7$?!#!K(B</div>
<div>$B$^$?!"A0<T$N(BDAO$B$rMxMQ$9$k(BAction$B$N>l9g$O!"(B</div>
<div>$B2<5-$N$h$&$J%m%0$,=PNO$5$l$F$$$^$7$?!#(B</div>
<div>$B$G$9$N$G!"<B:]$N%j%/%(%9%H$KBP$9$k%a%=%C%I$N<B9T$NA0$K(BDAO$B$N%$%s%9%?%s%92=$,9T$o$l!"(B</div>
<div> Dao.constructor() $B"*(B SelectDataSourceInterceptor.invoke()</div>
<div>$B$N$h$&$K$J$C$F$7$^$$!"(BSelectDataSourceInterceptor.invoke()$B$NA0$K(BAppConfig$B$+$i(BDataSourceName$B$r(B</div>
<div>$B<hF@$7$h$&$H$7$F$$$k$N$G$O$J$$$+!)$H2r<a$7$?$?$a$G$9!#(B</div>
<div>$B$^$?!"%G%P%C%0<B9T$GDI$C$F$_$?8B$j$G$O!"(BAnyTableDaoImpl$B!J(Bdoma...AbstractDao$B!K$N%3%s%9%H%i%/%?$+$i(B</div>
<div>RuntimeConfig$B$r%$%s%9%?%s%92=$9$k:]$N(B AssertionUtil.assertNotNull(config.getDataSourceName()); $B$K$F(B</div>
<div>$BA0=R$N$h$&$K(Bnull$B$G<hF@$5$l$k$?$a!"%(%i!<$,H/@8$7$F$$$k$h$&$G$7$?!#(B</div>
<div> </div>
<div>$B$"$H0lJb$N$h$&$J5$$,$9$k$N$G$9$,!"$I$&@_Dj$9$l$P$h$$$N$+J,$+$i$J$$<!Bh$G$9!#!#(B</div>
<div>$B8@MUB-$i$:$JItJ,$b$"$k$+$H;W$$$^$9$,!"$465<($$$?$@$1$k$H9,$$$G$9!#(B</div>
<div> </div>
<div> </div>
<div>$B!Z%m%0![(B</div>
<div>... $B%/%i%9(B(foo.bar.package.action.LoginAction[login_loginAction])$B$N%3%s%]!<%M%s%HDj5A$rEPO?$7$^$9(B</div>
<div>
<div>... $B%/%i%9(B(foo.bar.package.interceptor.SelectDataSourceInterceptor[selectDataSourceInterceptor])$B$N%3%s%]!<%M%s%HDj5A$rEPO?$7$^$9(B
<div>... $B%/%i%9(B(foo.bar.package.service.LoginService[login_loginService])$B$N%3%s%]!<%M%s%HDj5A$rEPO?$7$^$9(B
<div>... $B%/%i%9(B(foo.bar.package.dao.base.impl.AnyTableDaoImpl[base_anyTableDao])$B$N%3%s%]!<%M%s%HDj5A$rEPO?$7$^$9(B</div></div></div></div>
<div> </div>
<div>$B0J>e!"$h$m$7$/$*4j$$$$$?$7$^$9!#(B</div>
<div><br> </div>
<div class="gmail_quote">2011$BG/(B10$B7n(B10$BF|(B4:29 Toshihiro Nakamura <span dir="ltr"><<a href="mailto:toshihiro.nakamura@gmail.com" target="_blank">toshihiro.nakamura@gmail.com</a>></span>:<br>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">$BCfB<(B(taedium)$B$G$9!#(B<br>
<div><br>> $B%/%i%$%"%s%H$+$i%j%/%(%9%H$,Mh$?:]!"(BAction$B$r(BgetComponent$B$K$h$C$F<hF@$9$k(B<br>> $B$N$G$9$,!"F1$8%?%$%_%s%0$G(BService/DAO$B$b%$%s%9%?%s%92=$5$l$k$3$H$r(B<br>> $B3NG'$7$^$7$?!#(B<br><br></div>$B!V(BgetComponent$B$K$h$C$F<hF@$9$k!W$H$"$j$^$9$,!"$3$l$O!"(B<br>net.arnx.jsonic.web.extension.S2Container$B%/%i%9$N(BgetComponent$B%a%=%C%I(B<br>
$B$NCf$G9T$o$l$k=hM}$r;X$7$F$$$k$N$G$7$g$&$+!)(B<br>$B%"%W%j%1!<%7%g%s$G9T$C$F$$$k=hM}$r;X$7$F$$$k$N$+(BJSONIC$B$K$h$k=hM}$r(B<br>$B;X$7$F$$$k$N$+$o$+$j$^$;$s$G$7$?!#(B<br><br>SelectDataSourceInterceptor$B$O(BS2$B%3%s%F%J$KEPO?$G$-$F$$$^$9$+!)(B<br>SMART deploy$B$r;H$C$FEPO?$9$k$N$G$"$l$P!"(B<br>SelectDataSourceInterceptor$B$,!V%k!<%H%Q%C%1!<%8L>(B.interceptor$B!W$H$$$&(B<br>
$BL>A0$N%Q%C%1!<%8$KG[CV$5$l$F$$$k$3$H$r3NG'$7$F$/$@$5$$!#(B<br>$B$5$i$K!"(Bcreator.dicon$B$K<!$N5-=R$,$"$k$3$H$r3NG'$7$F$/$@$5$$!#(B<br><component class="org.seasar.framework.container.creator.InterceptorCreator"/><br><br>creator.dicon$B$G0J2<$N5-=R$O$5$l$F$$$^$9$+!)(B<br><component class="org.seasar.framework.container.creator.ActionCreator"/><br>
$B$3$N5-=R$,$J$$$H!"(Bcustomizer.dicon$B$N(BactionCustomizer$B$N@_Dj$,H?1G$5$l$^$;$s!#(B<br>$B!J(BAction$B$r(BSMART deploy$B$GEPO?$7$F$$$k$N$G$"$l$P5-=R$5$l$F$$$k$O$:$G$9$,!K(B<br><br>> $B$7$+$7!"(BInterceptor$B$,<B9T$5$l$:!"(BDAO$B$K$F(BConfig$B$+$i(BDatasourceName$B$r<hF@(B<br>> $B$G$-$J$$$H$$$&%(%i!<$,H/@8$7$F$7$^$$$^$7$?!#(B<br><br>$BG0$N$?$a$K!"(BInterceptor$B$O<B9T$5$l$F$$$k$1$l$I$b(B<br>
DatasourceName$B$K(Bnull$B$,@_Dj$5$l$k$3$H$G%(%i!<$,H/@8$7$F$$$k!"(B<br>$B$H$$$&2DG=@-$O$J$$$+3NG'$7$F$_$k$H$h$$$+$b$7$l$^$;$s!#(B<br>
<div><br>> Interceptor$B$O!"%3%s%9%H%i%/%?!J(BgetComponent$B!K$NA0$K<B9T$5$;$k$3$H$,(B<br>> $B$G$-$J$$$N$G$7$g$&$+!)(B<br><br></div>Interceptor$B$r;H$&$HFCDj$N%a%=%C%I8F$S=P$7$NA08e$GG$0U$N=hM}$r<B9T$G$-$^$9!#(B<br>$B:#2s$d$j$?$$$3$H$O$^$5$K$=$l$@$H;W$$$^$9!J(BAction$B$N%a%=%C%I$NA08e$G=hM}$r$9$k!K!#(B<br>$B%3%s%9%H%i%/%?$H(BgetComponent$B$OJLJ*$G$9$7!"$=$l$i$NA0$K<B9T$5$;$k$H$$$&$N(B<br>
$B$H$O$A$,$&$s$8$c$J$$$G$7$g$&$+!#(B<br><br>$BMW7o$KBP$7$F!"8=:_$d$m$&$H$7$F$$$k$3$H$NJ}8~@-$O$^$A$,$C$F$$$J$$$H;W$$$^$9!#(B<br>$B2?$i$+$NM}M3$G!"(BInterceptor$B$,(BAction$B$KE,MQ$5$l$F$$$J$$$h$&$G$9$,(B<br>$BE,@Z$K@_Dj$9$l$P2r7h$G$-$k$H;W$$$^$9!#(B<br><br>2011$BG/(B10$B7n(B9$BF|(B22:00 <<a href="mailto:luck62@gmail.com" target="_blank">luck62@gmail.com</a>>:<br>
<div>
<div></div>
<div>> $B$O$8$a$^$7$F!#(B<br>> okuda$B$H?=$7$^$9!#(B<br>><br>> $B8=:_!"(BSeasar2+Doma(+JSONIC REST Servlet)$B$K$F!"3+H/$r9T$J$C$F$*$j$^$9!#(B<br>> $B%G!<%?9=B$$,F1$8$G%9%-!<%^$,0[$J$k(BDB$B$XF0E*$K@Z$jBX$($F%"%/%;%9$7$?$$$N$G(B<br>> $B$9$,!">e<j$/F0:n$7$J$/m5$$$F$*$j$^$9!#(B<br>> $BBgJQ$*<j?t$G$9$,!"$465<($$$?$@$1$k$H9,$$$G$9!#(B<br>><br>
> $B!Z4D6-![(B<br>> $B!&(BJDK 1.6u27<br>> $B!&(BTomacat 6.0.29<br>> $B!&(BSeasar2 2.4.44<br>> $B!&(BDoma 1.18.0<br>> $B!&(BJSONIC 1.2.7<br>> $B!&(BJDBC4 Postgresql Driver, Version 9.1-901<br>><br>> $B!ZMW7o![(B<br>> $B!&%j%/%(%9%H(BURI$B$K$h$C$F!"@\B3$9$k%9%-!<%^$rF0E*$KJQ99$9$k(B<br>
> $B!&(BDI$B$r9T$&:]$O(BEJB3$B=`5r$G9T$&(B<br>><br>> $B!Z;n$7$?J}K!![(B<br>> $B!&(BDoma JPetStore$B$r;29M$K!"(Bdemo.config$B%Q%C%1!<%8$N$b$N$r$=$N$^$^N.MQ(B<br>> (AppConfig,CommonsJdbcLogger,S2RequiresNewController,SqlFileRepositoryProxy)<br>> DAO$B$K$O!"(B@Dao(config = AppConfig.class)$B%"%N%F!<%7%g%s$rIUM?$7$F$$$^$9!#(B<br>
> $B!&!VF1$8<oN`$N%G!<%?%=!<%9$rF0E*$K@Z$jBX$($k!W(B<br>> <a href="http://s2container.seasar.org/2.4/ja/jdbc.html#DataSourceDynamicSwiching" target="_blank">http://s2container.seasar.org/2.4/ja/jdbc.html#DataSourceDynamicSwiching</a><br>> $B$r;29M$K!"2<5-!Z:n@.%=!<%9![$N$h$&$K(Bdicon$B$*$h$S(BInterceptor$B$r:n@.(B<br>
><br>> $B!Z<ALd![(B<br>> $B#1!%(B<br>> Interceptor$B"*(BAction$B"*(BService$B"*(BDAO$B$H(BDI$B$rMQ$$$F%"%/%;%9$7$F$$$/$3$H$r(B<br>> $BA[Dj$7$F$$$^$9!#(B<br>> $B%/%i%$%"%s%H$+$i%j%/%(%9%H$,Mh$?:]!"(BAction$B$r(BgetComponent$B$K$h$C$F<hF@$9$k(B<br>> $B$N$G$9$,!"F1$8%?%$%_%s%0$G(BService/DAO$B$b%$%s%9%?%s%92=$5$l$k$3$H$r(B<br>> $B3NG'$7$^$7$?!#(B<br>
> $B$7$+$7!"(BInterceptor$B$,<B9T$5$l$:!"(BDAO$B$K$F(BConfig$B$+$i(BDatasourceName$B$r<hF@(B<br>> $B$G$-$J$$$H$$$&%(%i!<$,H/@8$7$F$7$^$$$^$7$?!#(B<br>> Interceptor$B$O!"%3%s%9%H%i%/%?!J(BgetComponent$B!K$NA0$K<B9T$5$;$k$3$H$,(B<br>> $B$G$-$J$$$N$G$7$g$&$+!)(B<br>><br>> $B#2!%(B<br>> $B2>$K$G$-$J$$>l9g!"$I$N$h$&$J%"%W%m!<%A$r<h$k$3$H$,9%$^$7$$$N$G$7$g$&$+!)(B<br>
><br>><br>> $B!Z:n@.%=!<%9![(B<br>> [user1-jdbc.dicon $B$*$h$S(B user2-jdbc.dicon]<br>> $B!J(Buser2-jdbc.dicon$B$O(Buser2DataSource$B$H$7$F(BDataSourceImpl$B$rDj5A$7!"(B<br>>$B!!(B $B8e$O!"2<5-(Buser1-jdbc.dicon$B$HF1$8!K(B<br>> <components namespace="jdbc"><br>
> <include path="jta.dicon"/><br>> <include path="jdbc-extension.dicon"/><br>><br>> <component name="user1DataSource"<br>> class="org.seasar.extension.dbcp.impl.DataSourceImpl"/><br>
> <component class="org.seasar.extension.jdbc.impl.BasicResultSetFactory"/><br>> <component<br>> class="org.seasar.extension.jdbc.impl.ConfigurableStatementFactory"><br>> <arg><br>
> <component<br>> class="org.seasar.extension.jdbc.impl.BasicStatementFactory"/><br>> </arg><br>> <property name="fetchSize">100</property><br>> </component><br>
><br>> <!-- for PostgreSQL --><br>> <component name="xaDataSource"<br>> class="org.seasar.extension.dbcp.impl.XADataSourceImpl"><br>> <property name="driverClassName">"org.postgresql.Driver"</property><br>
> <property name="URL"><br>> "jdbc:postgresql://localhost/TEST"<br>> </property><br>> <property name="user">"user1"</property><br>
> <property name="password">"xxxx"</property><br>> </component><br>> <component name="connectionPool"<br>> class="org.seasar.extension.dbcp.impl.ConnectionPoolImpl"><br>
> <property name="timeout">600</property><br>> <property name="maxPoolSize">10</property><br>> <property name="allowLocalTx">true</property><br>
> <destroyMethod name="close"/><br>> </component><br>> </components><br>><br>> [jdbc.dicon]<br>> <components namespace="jdbc"><br>> <include path="user1-jdbc.dicon"/><br>
> <include path="user2-jdbc.dicon"/><br>><br>> <component name="dataSource"<br>> class="org.seasar.extension.datasource.impl.SelectableDataSourceProxy"/><br>> <component name="dataSourceFactory"<br>
> class="org.seasar.extension.datasource.impl.DataSourceFactoryImpl"/><br>> </components><br>><br>> [SelectDataSourceInterceptor]<br>> public class SelectDataSourceInterceptor implements MethodInterceptor {<br>
> @Resource<br>> public DataSourceFactory dataSourceFactory;<br>> @Resource<br>> private HttpServletRequest request;<br>><br>> @Override<br>> public Object invoke(MethodInvocation invocation) throws Throwable {<br>
> String currentName =<br>> dataSourceFactory.getSelectableDataSourceName();<br>> try {<br>> String dataSourceName = getDataSourceName();<br>> dataSourceFactory.setSelectableDataSourceName(dataSourceName);<br>
> return invocation.proceed();<br>> } finally {<br>> dataSourceFactory.setSelectableDataSourceName(currentName);<br>> }<br>> }<br>><br>> public String getDataSourceName() {<br>
> // request $B$+$i(BURI$B$r<hF@$7!"BP>](BDataSource$BL>(B("user1" or "user2")<br>> // $B$r7hDj(B<br>> }<br>> }<br>><br>> [customizer.dicon$BH4?h(B]<br>> <component name="actionCustomizer"<br>
> class="org.seasar.framework.container.customizer.CustomizerChain"><br>> <initMethod name="addAspectCustomizer"><br>> <arg>"selectDataSourceInterceptor"</arg><br>
> </initMethod><br>> ....<br>> </component><br>><br>><br>> $B0J>e!"$h$m$7$/$*4j$$$$$?$7$^$9!#(B<br>><br></div></div>> _______________________________________________<br>> Seasar-user mailing list<br>
> <a href="mailto:Seasar-user@ml.seasar.org" target="_blank">Seasar-user@ml.seasar.org</a><br>> <a href="https://ml.seasar.org/mailman/listinfo/seasar-user" target="_blank">https://ml.seasar.org/mailman/listinfo/seasar-user</a><br>
><br><font color="#888888"><br><br><br>--<br>Toshihiro Nakamura<br>_______________________________________________<br>Seasar-user mailing list<br><a href="mailto:Seasar-user@ml.seasar.org" target="_blank">Seasar-user@ml.seasar.org</a><br>
<a href="https://ml.seasar.org/mailman/listinfo/seasar-user" target="_blank">https://ml.seasar.org/mailman/listinfo/seasar-user</a><br></font></blockquote></div><br>