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$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 = &quot;FooTable&quot;)<br>public class Foo{
<br>&nbsp; private int id;<br>&nbsp; private String name;<br>&nbsp; @Id(value = IdType.IDENTITY)<br>&nbsp; public void setId(int id){<br>&nbsp;&nbsp;&nbsp; <a href="http://this.id">this.id</a> = id;<br>&nbsp; }<br>&nbsp; //$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>&nbsp; @Arguments(&quot;id&quot;)<br>&nbsp; Foo get(int id);<br>}<br><br>//$B%?%9%/%/%i%9(B<br>public class FooTask extends TimerTask{<br>&nbsp; private FooDao fooDao;<br>&nbsp; public FooTask(FooDao fooDao){
<br>&nbsp;&nbsp;&nbsp; this.fooDao = fooDao;<br>&nbsp; }<br>&nbsp; public void run(){<br>&nbsp;&nbsp;&nbsp; Foo foo = fooDao.get(1);&nbsp; //$B"+$3$3$G!"(Bfoo$B$K(Bnull$B$,%;%C%H$5$l$k!#(B<br>&nbsp;&nbsp;&nbsp; if(foo == null){<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; throw new Exception();<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp; }<br>}<br><br>public interface Bar{
<br>&nbsp; void execute();<br>}<br><br>//$B%?%9%/@_Dj$N%/%i%9(B<br>public class BarImpl implements Bar{<br>&nbsp; private FooDao fooDao;<br>&nbsp; public BarImpl(FooDao fooDao){<br>&nbsp;&nbsp;&nbsp; this.fooDao = fooDao;<br>&nbsp; }<br>&nbsp; public void execute(){<br>&nbsp;&nbsp;&nbsp; FooTask task = new FooTask(fooDao);
<br>&nbsp;&nbsp;&nbsp; Timer timer = new Timer();<br>&nbsp;&nbsp;&nbsp; timer.schedule(task, 1000); //1$BIC8e$K(BFooTask$B$N(Brun$B$,<B9T$5$l$k!#(B<br>&nbsp; }<br>}<br><br>//$B%F%9%H%/%i%9(B<br>public class BarImplTest extends S2TestCase{<br>&nbsp; private Bar bar;<br>&nbsp; protected void setUp() throws Exception{
<br>&nbsp;&nbsp;&nbsp; super.setUp();<br>&nbsp;&nbsp;&nbsp; include(&quot;test.dicon&quot;);<br>&nbsp; }<br>&nbsp; public final void testExecuteTx(){<br>&nbsp;&nbsp;&nbsp; // UT0001Prepare.xls$B$K$O(BFooTable$B$N%o!<%/%7!<%H$K(Bid = 1, name = &quot;ABC&quot;$B$H$$$&9T$,EPO?$5$l$F$$$k(B<br>&nbsp;&nbsp;&nbsp; readXlsWriteDb(&quot;
UT0001Prepare.xls&quot;);<br>&nbsp;&nbsp;&nbsp; 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<br><br>-- <br>----------------------------------------------<br>Masakazu Kobayashi (<a href="mailto:masapon1967@gmail.com">
masapon1967@gmail.com</a>)