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

          這句是干什么用的?
          小弟才接觸這些
          請指教  回復(fù)  更多評論
            
          # re: spring 定時器的使用,可以用來發(fā)送垃圾郵件,或者定時搜索東西(附源碼) 2006-06-02 08:58 | loocky
          load spring的配置的文件  回復(fù)  更多評論
            
          主站蜘蛛池模板: 湄潭县| 宾阳县| 高碑店市| 柘荣县| 永嘉县| 永平县| 中宁县| 宁海县| 襄城县| 鹤峰县| 赫章县| 台南市| 东辽县| 邳州市| 丹阳市| 潮安县| 沁阳市| 平阴县| 日照市| 山阴县| 镇康县| 五家渠市| 峨眉山市| 六安市| 大悟县| 泰州市| 万山特区| 新蔡县| 布尔津县| 沈丘县| 吴堡县| 鞍山市| 贺州市| 凤城市| 茂名市| 榆林市| 阿鲁科尔沁旗| 安乡县| 钟山县| 河西区| 木兰县|