日期:2014-05-17  浏览次数:20903 次

quartz动态加载,并实现有状态的任务执行
<?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:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
    http://www.springframework.org/schema/beans 
    http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
    http://www.springframework.org/schema/tx
    http://www.springframework.org/schema/tx/spring-tx-2.0.xsd
    http://www.springframework.org/schema/aop
    http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">

<import resource="applicationContext_sqlIMSKING.xml" />

<!-- 属性文件读入 -->
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:db_IMSKING.properties</value>
</list>
</property>
</bean>

<!-- 数据源定义,使用c3p0 连接池 -->
<bean id="quartzdataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
destroy-method="close">
<property name="driverClass" value="${imsking.jdbc.driverClassName}" />
<property name="jdbcUrl" value="${imsking.jdbc.url}" />
<property name="user" value="${imsking.jdbc.username}" />
<property name="password" value="${imsking.jdbc.password}" />
<property name="initialPoolSize" value="${cpool.minPoolSize}" />
<property name="minPoolSize" value="${cpool.minPoolSize}" />
<property name="maxPoolSize" value="${cpool.maxPoolSize}" />
<property name="acquireIncrement" value="${cpool.acquireIncrement}" />
<property name="maxIdleTime" value="${cpool.maxIdleTime}" />
</bean>
<bean name="quartzScheduler"
class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="dataSource" ref="quartzdataSource" />
<property name="applicationContextSchedulerContextKey" value="applicationContextKey" />
<property name="configLocation" value="classpath:quartz.properties" />
</bean>
<bean name="simpleService" class="optima.frame.plan.model.SimpleService">

</bean>
<bean id="jobDetail" class="org.springframework.scheduling.quartz.JobDetailBean">
<property name="jobClass">
<value>
optima.frame.plan.model.MyQuartzJobBean
</value>
</property>
<property name="jobDataAsMap">
<map>
<entry key="simpleService">
<ref bean="simpleService" />
</entry>
</map>
</property>
</bean>

<!-- 排程管理 -->
<bean name="quartzDao" class="optima.frame.plan.dao.impl.QuartzDaoImpl">
<property name="hibernateTemplate" ref="hibernateTemplate"></property>
</bean>
<bean name="schedulerModel" class="optima.frame.plan.model.SchedulerModelImpl">
<property name="jobDetail">
<ref bean="jobDetail" />
</property>
<pro