QuartzのSpringでの使用
Quartzプロジェクトホームページhttp://www.quartz-scheduler.org/
SSH Job.java
appication Contect-quartz.xml
SSH Job.java
package ssh.core;
import org.apache.log4j.Logger;
/**
* SSH
* @author gary
*
*/
public class SSHJob {
Logger log = Logger.getLogger(this.getClass());
public void work(){
log.debug("SSH System job");
}
}
appication Contect-quartz.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"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
http://cxf.apache.org/jaxws
http://cxf.apache.org/schemas/jaxws.xsd"
default-lazy-init="true">
<!-- -->
<bean id="sshJob" class="ssh.core.SSHJob" />
<bean id="sshJobTask" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<!-- -->
<property name="targetObject">
<ref bean="sshJob"/>
</property>
<!-- -->
<property name="targetMethod">
<value>work</value>
</property>
</bean>
<bean id="sshJobDoTime" class="org.springframework.scheduling.quartz.CronTriggerBean">
<!-- -->
<property name="jobDetail">
<ref bean="sshJobTask"/>
</property>
<!-- cron , http://www.quartz-scheduler.org/docs/tutorials/crontrigger.html -->
<property name="cronExpression">
<value>0 0 1 ? * *</value>
</property>
</bean>
<!-- lazy-init="false" -->
<bean id="startQuartz" lazy-init="true" autowire="no"
class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
<ref bean="sshJobDoTime"/>
</list>
</property>
</bean>
</beans>