隨筆-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 小小程序程序員混口飯吃 閱讀(1701) 評論(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的配置的文件  回復  更多評論
            
          主站蜘蛛池模板: 新建县| 邵阳县| 桐城市| 逊克县| 芷江| 无棣县| 道孚县| 石城县| 齐河县| 宜阳县| 多伦县| 太保市| 嘉黎县| 蚌埠市| 纳雍县| 循化| 永新县| 海伦市| 子洲县| 沙河市| 平江县| 仲巴县| 神池县| 广丰县| 武汉市| 兴山县| 乐至县| 祁连县| 闸北区| 商都县| 渝北区| 沂水县| 纳雍县| 韶山市| 湖南省| 成安县| 革吉县| 安吉县| 酒泉市| 平南县| 扬州市|