0. 만약 maven을 사용한다면 pom.xml에 아래 내용 추가.
<!-- program scheduler -->
<dependency>
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz</artifactId>
<version>1.8.5</version>
</dependency>
1. 우선, web.xml에 아래 내용 추가.
2. jobContext.xml 은 내용~
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
">
<bean name="selectRequestedBookingProductJob" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<property name="targetObject" ref="selectRequestedBookingProduct" />
<property name="targetMethod" value="selectBookingCondition" />
<property name="arguments">
<list>
<value>false</value> <!-- run job -->
<value>2</value> <!-- serverTotalCount -->
<value>1</value> <!-- nowServerId -->
</list>
</property>
<property name="concurrent" value="false" />
</bean>
<bean id="selectRequestedBookingProduct" class="com.boaz.tgolf.scheduler.SelectRequestedBookingProductJob"/>
<bean id="trgSelectRequestedBookingProductJob" class="org.springframework.scheduling.quartz.SimpleTriggerBean">
<!-- see the example of method invoking job above -->
<property name="jobDetail" ref="selectRequestedBookingProductJob" />
<!-- ? seconds -->
<property name="startDelay" value="3000" />
<!-- repeat every ? seconds -->
<property name="repeatInterval" value="30000" />
</bean>
<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
<ref bean="trgSelectRequestedBookingProductJob" />
</list>
</property>
</bean>
</beans>
3. 실제 스케줄러 구현 클래스~
public class SelectRequestedBookingProductJob {
public void selectBookingCondition(boolean bRunJob, int serverTotalCount, int nowServerId) {
if( bRunJob ) {
try {
System.out.println("\n\n==== Run Job. Hello Job~ :) serverTotalCount["+ serverTotalCount +"] nowServerId["+ nowServerId +"] ====\n\n");
}catch(Exception e) {
e.printStackTrace();
}
}else {
System.out.println("\n\n==== Do not Run Job. ====\n\n");
}
}
}
4. WAS 재구동하면 정해진 트리거 조건에 따라