lundi 23 février 2015

Upgrading to Spring 4.1 Breaks Quartz Persistence due to removed JobDetailAwareTrigger

I am upgrading from Spring 3.2.x to Spring 4.1.x and am using Quartz 2.2.1. We dynamically create jobs and have been persisting them using the solution described in this stackoverlow answer.


The solution in that answer depends on a constant defined by JobDetailAwareTrigger.JOB_DETAIL_KEY, however that interface has been removed from the code base as a result of the work done for Spring JIRA 11262, and now my code does not compile.


I investigated the github commit that removed the interface and found that internal Spring code now directly references "jobDetail" literals when needed rather than a constant. Should I follow suit and create my own jobDetail constant that is defined within my application, and then reference that everywhere where I had previously referenced JobDetailAwareTrigger.JOB_DETAIL_KEY? If I do that, am I now making my application vulnerable to an unlikely future Spring change to the definition of "jobDetail"?


EDIT:


I created my own final static String JOB_DETAIL_KEY = "jobDetail" constant for use in my code and everything functioned with that change. I still feel uneasy about defining a constant that was pulled from a value used internally within the Spring code



public interface JobService {
public static final String JOB_DETAIL_KEY = "jobDetail";
....
}

public class PersistableCronTriggerFactoryBean extends CronTriggerFactoryBean {

@Override
public void afterPropertiesSet() throws ParseException {
//We run everything on UTC.
setTimeZone(DateTimeZone.UTC.toTimeZone());
super.afterPropertiesSet();

//Remove the JobDetail element
//Note that Quartz useProperties is set to true
getJobDataMap().remove(JobService.JOB_DETAIL_KEY);
}


}


Aucun commentaire:

Enregistrer un commentaire