📄 jobschedulingdataprocessor.java
字号:
throw new SchedulerException("A Job defined without any triggers must be durable"); } sched.addJob(detail, true); for (Iterator iter = job.getTriggers().iterator(); iter.hasNext(); ) { Trigger trigger = (Trigger)iter.next(); Trigger dupeT = sched.getTrigger(trigger.getName(), trigger.getGroup()); trigger.setJobName(detail.getName()); trigger.setJobGroup(detail.getGroup()); if(trigger.getStartTime() == null) trigger.setStartTime(new Date()); if (dupeT != null) { getLog().debug( "Rescheduling job: " + detail.getFullName() + " with updated trigger: " + trigger.getFullName()); if(!dupeT.getJobGroup().equals(trigger.getJobGroup()) || !dupeT.getJobName().equals(trigger.getJobName())) getLog().warn("Possibly duplicately named triggers in jobs xml file!"); sched.rescheduleJob(trigger.getName(), trigger.getGroup(), trigger); } else { getLog().debug( "Scheduling job: " + detail.getFullName() + " with trigger: " + trigger.getFullName()); sched.scheduleJob(trigger); } } addScheduledJob(job); } } /** * Adds a scheduled job. * * @param job * job wrapper. */ protected void addScheduledJob(JobSchedulingBundle job) { scheduledJobs.put(job.getFullName(), job); } /** * Adds a calendar. * * @param calendarBundle calendar bundle. * @throws SchedulerException if the Calendar cannot be added to the Scheduler, or * there is an internal Scheduler error. */ public void addCalendar(Scheduler sched, CalendarBundle calendarBundle) throws SchedulerException { sched.addCalendar( calendarBundle.getCalendarName(), calendarBundle.getCalendar(), calendarBundle.getReplace(), true); } /** * EntityResolver interface. * <p/> * Allow the application to resolve external entities. * <p/> * Until <code>quartz.dtd</code> has a public ID, it must resolved as a * system ID. Here's the order of resolution (if one fails, continue to the * next). * <ol> * <li>Tries to resolve the <code>systemId</code> with <code>ClassLoader.getResourceAsStream(String)</code>. * </li> * <li>If the <code>systemId</code> starts with <code>QUARTZ_SYSTEM_ID_PREFIX</code>, * then resolve the part after <code>QUARTZ_SYSTEM_ID_PREFIX</code> with * <code>ClassLoader.getResourceAsStream(String)</code>.</li> * <li>Else try to resolve <code>systemId</code> as a URL. * <li>If <code>systemId</code> has a colon in it, create a new <code>URL</code> * </li> * <li>Else resolve <code>systemId</code> as a <code>File</code> and * then call <code>File.toURL()</code>.</li> * </li> * </ol> * <p/> * If the <code>publicId</code> does exist, resolve it as a URL. If the * <code>publicId</code> is the Quartz public ID, then resolve it locally. * * @param publicId * The public identifier of the external entity being referenced, * or null if none was supplied. * @param systemId * The system identifier of the external entity being referenced. * @return An InputSource object describing the new input source, or null * to request that the parser open a regular URI connection to the * system identifier. * @exception SAXException * Any SAX exception, possibly wrapping another exception. * @exception IOException * A Java-specific IO exception, possibly the result of * creating a new InputStream or Reader for the InputSource. */ public InputSource resolveEntity(String publicId, String systemId) { InputSource inputSource = null; InputStream is = null; URL url = null; try { if (publicId == null) { if (systemId != null) { // resolve Quartz Schema locally if (QUARTZ_SCHEMA.equals(systemId)) { is = getClass().getResourceAsStream(QUARTZ_DTD); } else { is = getInputStream(systemId); if (is == null) { int start = systemId.indexOf(QUARTZ_SYSTEM_ID_PREFIX); if (start > -1) { String fileName = systemId .substring(QUARTZ_SYSTEM_ID_PREFIX.length()); is = getInputStream(fileName); } else { if (systemId.indexOf(':') == -1) { File file = new java.io.File(systemId); url = file.toURL(); } else { url = new URL(systemId); } is = url.openStream(); } } } } } else { // resolve Quartz DTD locally if (QUARTZ_PUBLIC_ID.equals(publicId)) { is = getClass().getResourceAsStream(QUARTZ_DTD); } else { url = new URL(systemId); is = url.openStream(); } } } catch (Exception e) { e.printStackTrace(); } finally { if (is != null) { inputSource = new InputSource(is); inputSource.setPublicId(publicId); inputSource.setSystemId(systemId); } } return inputSource; } /** * ErrorHandler interface. * * Receive notification of a warning. * * @param exception * The error information encapsulated in a SAX parse exception. * @exception SAXException * Any SAX exception, possibly wrapping another exception. */ public void warning(SAXParseException e) throws SAXException { addValidationException(e); } /** * ErrorHandler interface. * * Receive notification of a recoverable error. * * @param exception * The error information encapsulated in a SAX parse exception. * @exception SAXException * Any SAX exception, possibly wrapping another exception. */ public void error(SAXParseException e) throws SAXException { addValidationException(e); } /** * ErrorHandler interface. * * Receive notification of a non-recoverable error. * * @param exception * The error information encapsulated in a SAX parse exception. * @exception SAXException * Any SAX exception, possibly wrapping another exception. */ public void fatalError(SAXParseException e) throws SAXException { addValidationException(e); } /** * Adds a detected validation exception. * * @param SAXException * SAX exception. */ protected void addValidationException(SAXException e) { validationExceptions.add(e); } /** * Resets the the number of detected validation exceptions. */ protected void clearValidationExceptions() { validationExceptions.clear(); } /** * Throws a ValidationException if the number of validationExceptions * detected is greater than zero. * * @exception ValidationException * DTD validation exception. */ protected void maybeThrowValidationException() throws ValidationException { if (validationExceptions.size() > 0) { throw new ValidationException(validationExceptions); } } /** * RuleSet for common Calendar tags. * * @author <a href="mailto:bonhamcm@thirdeyeconsulting.com">Chris Bonham</a> */ public class CalendarRuleSet extends RuleSetBase { protected String prefix; protected String setNextMethodName; public CalendarRuleSet(String prefix, String setNextMethodName) { super(); this.prefix = prefix; this.setNextMethodName = setNextMethodName; } public void addRuleInstances(Digester digester) { digester.addObjectCreate(prefix, CalendarBundle.class); digester.addSetProperties(prefix, TAG_CLASS_NAME, "className"); digester.addBeanPropertySetter(prefix + "/" + TAG_NAME, "calendarName"); digester.addBeanPropertySetter(prefix + "/" + TAG_DESCRIPTION, "description"); digester.addSetNext(prefix, setNextMethodName); } } /** * RuleSet for common Trigger tags. * * @author <a href="mailto:bonhamcm@thirdeyeconsulting.com">Chris Bonham</a> */ public class TriggerRuleSet extends RuleSetBase { protected String prefix; protected Class clazz; public TriggerRuleSet(String prefix, Class clazz) { super(); this.prefix = prefix; if (!Trigger.class.isAssignableFrom(clazz)) { throw new IllegalArgumentException("Class must be an instance of Trigger"); } this.clazz = clazz; } public void addRuleInstances(Digester digester) { digester.addObjectCreate(prefix, clazz); digester.addBeanPropertySetter(prefix + "/" + TAG_NAME, "name"); digester.addBeanPropertySetter(prefix + "/" + TAG_GROUP, "group"); digester.addBeanPropertySetter(prefix + "/" + TAG_DESCRIPTION, "description"); digester.addBeanPropertySetter(prefix + "/" + TAG_VOLATILITY, "volatility"); digester.addRule(prefix + "/" + TAG_MISFIRE_INSTRUCTION, new MisfireInstructionRule("misfireInstruction")); digester.addBeanPropertySetter(prefix + "/" + TAG_CALENDAR_NAME, "calendarName"); digester.addBeanPropertySetter(prefix + "/" + TAG_JOB_NAME, "jobName"); digester.addBeanPropertySetter(prefix + "/" + TAG_JOB_GROUP, "jobGroup"); Converter converter = new DateConverter(new String[] { XSD_DATE_FORMAT, DTD_DATE_FORMAT }); digester.addRule(prefix + "/" + TAG_START_TIME, new SimpleConverterRule("startTime", converter, Date.class)); digester.addRule(prefix + "/" + TAG_END_TIME, new SimpleConverterRule("endTime", converter, Date.class)); } } /** * This rule is needed to fix <a href="http://jira.opensymphony.com/browse/QUARTZ-153">QUARTZ-153</a>. * <p> * Since the Jakarta Commons BeanUtils 1.6.x <code>ConvertUtils</code> class uses static utility * methods, the <code>DateConverter</code> and <code>TimeZoneConverter</code> were * overriding any previously registered converters for <code>java.util.Date</code> and * <code>java.util.TimeZone</code>. * <p> * Jakarta Commons BeanUtils 1.7.x fixes this issue by internally using per-context-classloader * pseudo-singletons (see <a href="http://jakarta.apache.org/commons/beanutils/commons-beanutils-1.7.0/RELEASE-NOTES.txt"> * http://jakarta.apache.org/commons/beanutils/commons-beanutils-1.7.0/RELEASE-NOTES.txt</a>). * This ensures web applications in the same JVM are using independent converters * based on their classloaders. However, the environment for QUARTZ-153 started Quartz * using the <code>QuartzInitializationServlet</code> which started <code>JobInitializationPlugin</code>. * In this case, the web classloader instances would be the same. * <p> * To make sure the converters aren't overridden by the <code>JobSchedulingDataProcessor</code>, * it's easier to just override <code>BeanPropertySetterRule.end()</code> to convert the * body text to the specified class using the specified converter. * * @author <a href="mailto:bonhamcm@thirdeyeconsulting.com">Chris Bonham</a> */ public class SimpleConverterRule extends BeanPropertySetterRule { private Converter converter; private Class clazz; /** * <p>Construct rule that sets the given property from the body text.</p> * * @param propertyName name of property to set * @param converter converter to use * @param clazz class to convert to
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -