masapon1967$B$G$9!#(B<br><br>java.util.TimerTask$B$r;HMQ$7$F!"%G!<%?%Y!<%9$K%G!<%?$r=q$-9~$`%W%m%0%i%`$r%F%9%H$7$F$$$k$N$G(B<div>$B$9$,!"(B<br>$B%F!<%V%k$+$i%G!<%?$rFI$_9~$`$3$H$,$G$-$^$;$s!#(B<br><br>TimerTask$B$G<B9T$5$l$k$N$,%F%9%H%1!<%9$H$OJL$N%9%l%C%I$N$?$a$@$H$O;W$&$N$G$9$,!"$I$&$9$l$P$h$$$+$,(B<br>$BJ,$+$j$^$;$s!#2r7hJ}K!$,$*J,$+$j$NJ}$,$$$i$C$7$c$l$P!"$*65$(4j$$$^$9!#(B
<br><br>-S2 2.3.14
<br>-S2Dao 1.0.37<br>-S2Dao tiger 1.0.35<br>-MySQL Connection/J 5.0.3<br>-MySQL Server 5.0.24a<br><br>table FooTable<br>- id int<br>- name varchar<br><br>//$B%(%s%F%#%F%#%/%i%9(B<br>@Bean(table = "FooTable")<br>public class Foo{
<br> private int id;<br> private String name;<br> @Id(value = IdType.IDENTITY)<br> public void setId(int id){<br> <a href="http://this.id/" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">this.id
</a> = id;<br> }<br> //$B0J2<(Bid, name$B$N(Bsetter, getter<br>}<br clear="all">
<br>//DAO$B%/%i%9(B<br>@S2Dao(bean = Foo.class)<br>public interface FooDao{<br> @Arguments("id")<br> Foo get(int id);<br>}<br><br>//$B%?%9%/%/%i%9(B<br>public class FooTask extends TimerTask{<br> private FooDao fooDao;<br> public FooTask(FooDao fooDao){
<br> this.fooDao = fooDao;<br> }<br> public void run(){<br> Foo foo = fooDao.get(1); //$B"+$3$3$G!"(Bfoo$B$K(Bnull$B$,%;%C%H$5$l$k!#(B<br> if(foo == null){<br> throw new Exception();<br> }<br> }<br>}<br><br>public interface Bar{
<br> void execute();<br>}<br><br>//$B%?%9%/@_Dj$N%/%i%9(B<br>public class BarImpl implements Bar{<br> private FooDao fooDao;<br> public BarImpl(FooDao fooDao){<br> this.fooDao = fooDao;<br> }<br> public void execute(){<br> FooTask task = new FooTask(fooDao);
<br> Timer timer = new Timer();<br> timer.schedule(task, 1000); //1$BIC8e$K(BFooTask$B$N(Brun$B$,<B9T$5$l$k!#(B<br> }<br>}<br><br>//$B%F%9%H%/%i%9(B<br>public class BarImplTest extends S2TestCase{<br> private Bar bar;<br> protected void setUp() throws Exception{
<br> super.setUp();<br> include("test.dicon");<br> }<br> public final void testExecuteTx(){<br> // UT0001Prepare.xls$B$K$O(BFooTable$B$N%o!<%/%7!<%H$K(Bid = 1, name = "ABC"$B$H$$$&9T$,EPO?$5$l$F$$$k(B<br> readXlsWriteDb("
UT0001Prepare.xls");<br> bar.execute(); //FooTask.run()$B$G(BFoo$B%*%V%8%'%/%H$,<hF@$G$-$J$$$?$a!"Nc30$,H/@8$9$k!#(B<br>}<br><br>test.dicon$B$K$O(BBarDao$B$H(BBarImpl$B$,EPO?$5$l$F$$$F!"(BBarDao$B$K$O(Bdao.interceptor$B$r!"(BBarImpl$B$K$O(Bj2ee.requiredTx$B$,(B<br>$B?%$j9~$^$l$F$$$^$9!#(B<br>testExecute(Tx)$B$H$7$F$$$k$?$a!"$3$3$G3+;O$5$l$?%H%i%s%6%/%7%g%s$H!"(BFooTask$B$,<B9T$5$l$k%9%l%C%I$N(B
<br>$B%H%i%s%6%/%7%g%s$,0[$J$k$N$@$H;W$$$^$9!#(B<br>$B<B:]!"(BtestExecute$B$H(BTx$B$r30$7$F<B9T$7$?$H$3$m!"(BFooTask$B$N(Brun$B%a%=%C%I$G!"(BFoo$B%*%V%8%'%/%H$,FI$_9~$^$l$^$9!#(B<br>$B2r7hJ}K!$,J,$+$kJ}!"$h$m$7$/8f4j$$$7$^$9!#(B</div><br clear="all"><br>-- <br>----------------------------------------------<br>Masakazu Kobayashi (
<a href="mailto:masapon1967@gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">masapon1967@gmail.com</a>)