본문 바로가기
Spring

Spring Timer Sample

by 아이티.파머 2010. 12. 14.
반응형

/*
 * $Id: LawScheduleTimer.java ,v 1.1 2010. 12. 10. 오후 3:38:08 com.hynix.ecms Exp $
 * created by    : An Sang Kil
 * creation-date : 2010. 12. 10.
 * =========================================================
 * Copyright (c) 2010 ManInSoft, Inc. All rights reserved.
 */
package com.dongbu.skan.schedule;


/**
 * Law Batch job
 * @author ahn
 *
 */
public class LawScheduleTimer{
//1.2 SpingFreamWork JDK Timer 연동테스트
public void schedule(){
System.out.println("\\n\\n\\n 1.2 SpingFreamWork JDK Timer 연동테스트");
}
}



<!-- ************************************************************************************* -->
<!-- ****************************JDK Timer 지원 사용하기********************************** -->
<!-- ************************************************************************************* -->

<beans>
        <!-- Spring JDK Timer case -->
<bean id="lawScheduleTimer" class="com..dongbu.skan.schedule.LawScheduleTimer"></bean>
<bean id="generatorJobProxy"  class="org.springframework.scheduling.timer.MethodInvokingTimerTaskFactoryBean">
<property name="targetObject">
<ref local="lawScheduleTimer"/>
</property>
<property name="targetMethod">
    <value>schedule</value>
</property>
</bean>
<bean id="scheduledTask" class="org.springframework.scheduling.timer.ScheduledTimerTask">
    <!--wait 10 seconds before starting repeated execution -->
    <property name="delay" value="10000" />
    <!-- run every 50 seconds -->
            <!--task 를 단지 한번만 실행하고자 한다면, period 속성을 0(혹은 음수값)으로 바꿔주면 된다.-->
    <property name="period" value="50000" />
    <property name="timerTask" ref="generatorJobProxy" />
</bean>
<bean id="scheduler" class="org.springframework.scheduling.timer.TimerFactoryBean">
<property name="scheduledTimerTasks">
<list>
<ref local="scheduledTask"/>
</list>
</property>
</bean>
 -->
</beans>

JDK 1.3 Timer를 스프링에서 쉽게 사용할 수 있도록
Spring 에서 제공하는 Timer 사용하니 좋구나~

설명은 나중에.... 혹은 아래서 ~

reference  : spring open frame work 

반응형