隨筆-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 定時器的使用,可以用來發(fā)送垃圾郵件,或者定時搜索東西(附源碼) 2006-06-01 15:49 | webwork
          ApplicationContext ctx=new FileSystemXmlApplicationContext("E:\\work\\Test\\bin\\spring-config.xml");

          這句是干什么用的?
          小弟才接觸這些
          請指教  回復  更多評論
            
          # re: spring 定時器的使用,可以用來發(fā)送垃圾郵件,或者定時搜索東西(附源碼) 2006-06-02 08:58 | loocky
          load spring的配置的文件  回復  更多評論
            
          主站蜘蛛池模板: 大宁县| 甘洛县| 亚东县| 思南县| 沂水县| 会同县| 安平县| 隆尧县| 乌兰浩特市| 古田县| 嘉定区| 黄龙县| 连平县| 泰兴市| 出国| 和田市| 华容县| 新绛县| 双牌县| 枣强县| 灵璧县| 定日县| 葫芦岛市| 泾川县| 尚义县| 云阳县| 温泉县| 吉水县| 观塘区| 丰台区| 明水县| 张家界市| 石泉县| 吐鲁番市| 津南区| 万全县| 芷江| 兴海县| 上林县| 民权县| 磴口县|