A
Alessandro
Hi all,
I'm adding a new job (CoraxJob) to a Spring application already
working and using a single job (FinecoJob).
Result: my new job doesn't start and I don't get any error.
MyScheduler is the main class which loads context
//START
myconfig.xml
<!-- *** INIZIO SCHEDULER *** -->
<bean class="org.springframework.scheduling.quartz.JobDe tailBean"
id="jobDetailBean">
<property name="jobClass" value="FinecoJob"></property>
<property name="jobDataAsMap">
<map>
<entry key="message" value="Welcome at Fineco Job"></entry>
</map>
</property>
</bean>
<bean class="org.springframework.scheduling.quartz.JobDe tailBean"
id="jobDetailCoraxBean">
<property name="jobClass" value="CoraxJob"></property>
<property name="jobDataAsMap">
<map>
<entry key="message" value="Welcome at Corax Job"></entry>
</map>
</property>
</bean>
<bean id="myCronTrigger"
class="org.springframework.scheduling.quartz.CronT riggerBean">
<property name="jobDetail" ref="jobDetailBean"></property>
<property name="cronExpression" value="00 54 19 ? * TUE-SAT *"></
property>
</bean>
<bean id="myCoraxTrigger"
class="org.springframework.scheduling.quartz.CronT riggerBean">
<property name="jobDetail" ref="jobDetailCoraxBean"></property>
<property name="cronExpression" value="00 45 16 ? * MON-FRI *"></
property>
</bean>
<bean class="org.springframework.scheduling.quartz.Sched
ulerFactoryBean">
<property name="triggers">
<list>
<ref bean="myCronTrigger" />
<ref bean="myCoraxTrigger" />
</list>
</property>
</bean>
<!-- *** FINE SCHEDULER *** -->
MyScheduler.java
public class MyScheduler {
public static ApplicationContext context;
public static void main(String[] args) throws SchedulerException{
try{
context=new FileSystemXmlApplicationContext(myconfig.xml);
}
catch(Throwable ex){
}
}
FinecoJob.java
public class FinecoJob extends QuartzJobBean implements
StatefulJob,Costants {
public static ApplicationContext context;
protected void executeInternal(JobExecutionContext ctx)
throws JobExecutionException {
context=MyScheduler.context;
.....
//MY JOB ...
CoraxJob.java
public class CoraxJob implements Costants{
public static ApplicationContext context;
protected void executeInternal(JobExecutionContext ctx)
throws JobExecutionException {
//MY JOB
//END
Is anything wrong in what I have done ? I thought it was just simply
adding the new job ad CronTriggerBean and JobDetailBean.
They will be two jobs starting in different hours and using a
different method executeInternal().
Thanks for any help and best regards,
Ale
I'm adding a new job (CoraxJob) to a Spring application already
working and using a single job (FinecoJob).
Result: my new job doesn't start and I don't get any error.
MyScheduler is the main class which loads context
//START
myconfig.xml
<!-- *** INIZIO SCHEDULER *** -->
<bean class="org.springframework.scheduling.quartz.JobDe tailBean"
id="jobDetailBean">
<property name="jobClass" value="FinecoJob"></property>
<property name="jobDataAsMap">
<map>
<entry key="message" value="Welcome at Fineco Job"></entry>
</map>
</property>
</bean>
<bean class="org.springframework.scheduling.quartz.JobDe tailBean"
id="jobDetailCoraxBean">
<property name="jobClass" value="CoraxJob"></property>
<property name="jobDataAsMap">
<map>
<entry key="message" value="Welcome at Corax Job"></entry>
</map>
</property>
</bean>
<bean id="myCronTrigger"
class="org.springframework.scheduling.quartz.CronT riggerBean">
<property name="jobDetail" ref="jobDetailBean"></property>
<property name="cronExpression" value="00 54 19 ? * TUE-SAT *"></
property>
</bean>
<bean id="myCoraxTrigger"
class="org.springframework.scheduling.quartz.CronT riggerBean">
<property name="jobDetail" ref="jobDetailCoraxBean"></property>
<property name="cronExpression" value="00 45 16 ? * MON-FRI *"></
property>
</bean>
<bean class="org.springframework.scheduling.quartz.Sched
ulerFactoryBean">
<property name="triggers">
<list>
<ref bean="myCronTrigger" />
<ref bean="myCoraxTrigger" />
</list>
</property>
</bean>
<!-- *** FINE SCHEDULER *** -->
MyScheduler.java
public class MyScheduler {
public static ApplicationContext context;
public static void main(String[] args) throws SchedulerException{
try{
context=new FileSystemXmlApplicationContext(myconfig.xml);
}
catch(Throwable ex){
}
}
FinecoJob.java
public class FinecoJob extends QuartzJobBean implements
StatefulJob,Costants {
public static ApplicationContext context;
protected void executeInternal(JobExecutionContext ctx)
throws JobExecutionException {
context=MyScheduler.context;
.....
//MY JOB ...
CoraxJob.java
public class CoraxJob implements Costants{
public static ApplicationContext context;
protected void executeInternal(JobExecutionContext ctx)
throws JobExecutionException {
//MY JOB
//END
Is anything wrong in what I have done ? I thought it was just simply
adding the new job ad CronTriggerBean and JobDetailBean.
They will be two jobs starting in different hours and using a
different method executeInternal().
Thanks for any help and best regards,
Ale