隨筆-109  評論-187  文章-25  trackbacks-0


          <beans>

          ?<bean id="timer" class="org.springframework.scheduling.timer.TimerFactoryBean">
          ??<property name="scheduledTimerTasks">
          ???<list>
          ????<ref local="testtimertask"/>
          ???</list>
          ??</property>
          ?</bean>

          ?<bean id="timerbean" class="MyTimerImpl">

          ?</bean>
          ?<bean id="testtimertask" class="org.springframework.scheduling.timer.ScheduledTimerTask">
          ??<property name="timerTask">
          ???<ref bean="timerbean" />
          ??</property>

          ??<property name="delay">
          ???<value>1000</value>
          ??</property>

          ??<property name="period">
          ???<value>1000</value>
          ??</property>

          ?</bean>

          </beans>

          MyTimerImpl

          import java.util.TimerTask;

          public class MyTimerImpl? extends TimerTask {

          ?public void run() {
          ??System.out.println("aaaaaaaa");
          ??
          ?}
          TestTimer

          import net.loocky.sowq.util.ServiceFactory;

          import org.springframework.context.ApplicationContext;
          import org.springframework.context.support.FileSystemXmlApplicationContext;

          public class TestTimer {

          ?/**
          ? * @param args
          ? */
          ?public static void main(String[] args) throws Exception {
          ??
          ????ApplicationContext ctx=new?FileSystemXmlApplicationContext("E:\\work\\Test\\bin\\spring-config.xml");
          ??Thread.sleep(100000);
          ?}

          }

          }

          posted on 2006-05-25 17:59 小小程序程序員混口飯吃 閱讀(1706) 評論(2)  編輯  收藏 所屬分類: java

          評論:
          # re: spring 定時器的使用,可以用來發送垃圾郵件,或者定時搜索東西(附源碼) 2006-06-01 15:49 | webwork
          ApplicationContext ctx=new FileSystemXmlApplicationContext("E:\\work\\Test\\bin\\spring-config.xml");

          這句是干什么用的?
          小弟才接觸這些
          請指教  回復  更多評論
            
          # re: spring 定時器的使用,可以用來發送垃圾郵件,或者定時搜索東西(附源碼) 2006-06-02 08:58 | loocky
          load spring的配置的文件  回復  更多評論
            
          主站蜘蛛池模板: 文昌市| 汕头市| 兴安盟| 扎鲁特旗| 故城县| 花莲县| 新龙县| 张家口市| 清涧县| 扎鲁特旗| 普陀区| 保山市| 韩城市| 无锡市| 耿马| 平定县| 图木舒克市| 兰州市| 安西县| 陆川县| 赣州市| 正蓝旗| 德格县| 高密市| 万荣县| 崇州市| 正镶白旗| 安康市| 多伦县| 江陵县| 景谷| 锡林郭勒盟| 贡山| 宣城市| 彭山县| 榆中县| 沙湾县| 葵青区| 扎赉特旗| 丹东市| 昔阳县|