随笔-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 小小程序程序员混口饭吃 阅读(1684) 评论(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的配置的文件  回复  更多评论
  

只有注册用户登录后才能发表评论。


网站导航: