일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
Tags
- Struts
- jsr 296
- tomcat
- oracle
- JSON
- appspresso
- PLSQL
- MFC
- JDOM
- Eclipse
- node.js
- 가우스
- swingx
- iBATIS
- GPS
- rowspan
- WebLogic
- Spring
- ibsheet
- jQuery
- sencha touch
- phonegap
- MySQL
- Google Map
- 전자정부프레임워크
- Ajax
- PHP
- dock
- Android
- 선택적조인
Archives
- Today
- Total
Where The Streets Have No Name
Spring Job Scheduling 서비스 본문
<?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-2.5.xsd">
<bean id="jobDetailBean"
class="org.springframework.scheduling.quartz.JobDetailBean">
<property name="jobClass" value="egovframework.rte.job.SayHelloJob" />
<property name="jobDataAsMap">
<map>
<entry key="name" value="JobDetail"/>
</map>
</property>
</bean>
<bean id="cronJob" class="org.springframework.scheduling.quartz.CronTriggerBean">
<property name="jobDetail" ref="jobDetailBean" />
<property name="cronExpression" value="*/10 * * * * ?" />
</bean>
<bean id="scheduler" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
<ref bean="cronJob" />
</list>
</property>
</bean>
</beans>
package egovframework.rte.job;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.scheduling.quartz.QuartzJobBean;
import org.springframework.stereotype.Service;
public class SayHelloJob extends QuartzJobBean {
private String name;
public void setName (String name) {
this.name = name;
}
@Override
protected void executeInternal(JobExecutionContext arg0) throws JobExecutionException {
long now = System.currentTimeMillis();
SimpleDateFormat sdfNow = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String strNow = sdfNow.format(new Date(now));
System.out.println("Hello, " + name + ", " + strNow);
}
}