首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

在spring中治理多个job

2012-09-04 
在spring中管理多个job1:spring配置文件?? bean iddailyjob.processor??????? /??????? ref local

在spring中管理多个job

1:spring配置文件

?

? <bean id="dailyjob.processor"
??????? />
??????? <ref local="tallydone" />
??????? <ref local="discountnote" />
????????? </list>
??? </property>
? </bean>


? <bean id="jobdetail.factory"
??????? />
??? </property>
??? <property name="targetMethod">
????? <value>process</value>
??? </property>
? </bean>


? <bean id="trigger.jobdetail"
??????? />
??? </property>
??? <property name="startDelay">


????? <value>${time.jobstartdelay}</value>
??? </property>
??? <property name="repeatInterval">


????? <value>${time.jobrepeatinterval}</value>
??? </property>
? </bean>

?

2: DailyJobProcessor类

?

?*/
public class DailyJobProcessor implements Serializable {

??? private List dailyjobQueue;

??? public void process() {
??????? //按注入计划任务的顺序执行
??????? for (int i = 0; i < dailyjobQueue.size(); i++) {
??????????? try {
??????????????? DailyJob job = (DailyJob) dailyjobQueue.get(i);

??????????????? job.execute();
??????????? } catch (Exception e) {
??????????????? System.out.println(e.getMessage());
??????????????? e.printStackTrace();
??????????? }
??????? }
??? }

??? /******************?? Spring 注入?? *********************/

??? public List getDailyjobQueue() {
??????? return dailyjobQueue;
??? }

??? public void setDailyjobQueue(List dailyjobQueue) {
??????? this.dailyjobQueue = dailyjobQueue;
??? }
}

?

3:DailyJob 为interface 让几种job实现它

热点排行