- 浏览: 951089 次
文章分类
- 全部博客 (428)
- Hadoop (2)
- HBase (1)
- ELK (1)
- ActiveMQ (13)
- Kafka (5)
- Redis (14)
- Dubbo (1)
- Memcached (5)
- Netty (56)
- Mina (34)
- NIO (51)
- JUC (53)
- Spring (13)
- Mybatis (17)
- MySQL (21)
- JDBC (12)
- C3P0 (5)
- Tomcat (13)
- SLF4J-log4j (9)
- P6Spy (4)
- Quartz (12)
- Zabbix (7)
- JAVA (9)
- Linux (15)
- HTML (9)
- Lucene (0)
- JS (2)
- WebService (1)
- Maven (4)
- Oracle&MSSQL (14)
- iText (11)
- Development Tools (8)
- UTILS (4)
- LIFE (8)
最新评论
-
Donald_Draper:
Donald_Draper 写道刘落落cici 写道能给我发一 ...
DatagramChannelImpl 解析三(多播) -
Donald_Draper:
刘落落cici 写道能给我发一份这个类的源码吗Datagram ...
DatagramChannelImpl 解析三(多播) -
lyfyouyun:
请问楼主,执行消息发送的时候,报错:Transport sch ...
ActiveMQ连接工厂、连接详解 -
ezlhq:
关于 PollArrayWrapper 状态含义猜测:参考 S ...
WindowsSelectorImpl解析一(FdMap,PollArrayWrapper) -
flyfeifei66:
打算使用xmemcache作为memcache的客户端,由于x ...
Memcached分布式客户端(Xmemcached)
Quartz的使用:http://donald-draper.iteye.com/blog/2321886
Quartz的Scheduler初始化源码分析:http://donald-draper.iteye.com/blog/2322730
Quartz的job、触发器的暂停与恢复源码分析:http://donald-draper.iteye.com/blog/2322823
Quartz的Job存储,触发器、任务删除,源码分析:http://donald-draper.iteye.com/blog/2322725
Quartzs的job,trriger监听器源码分析:http://donald-draper.iteye.com/blog/2322863
Quartz 任务存储JobStoreTX 持久化之RDB:http://donald-draper.iteye.com/blog/2323297
Quartz 任务存储JobStoreTX 持久化之RDB-源码分析:http://donald-draper.iteye.com/blog/2323409
Quartz任务调度源码分析:http://donald-draper.iteye.com/blog/2323118
Spring与Quartz集成详解:http://donald-draper.iteye.com/blog/2323591
Spring与Quartz集成-源码分析:http://donald-draper.iteye.com/blog/2324132
一般获取Scheduler的方式
第一种:
第二种:
下面先来看看第一种到底做了些什么
//调度器仓库
//标准执行器实际上是包装了QuartzScheduler
//调度器
//QuartzScheduler的资源管理器
从StdSchedulerFactory的getDefaultScheduler方法可以看出与getScheduler相同
总结:
从以上代码分析中,看出StdSchedulerFactory获取执行器,首先从调度器仓库获取调度器,如果为空,则配置属性cfg,如果cfg为空则初始化属性文件,如果没有配置属性文件,则加载默认属性;然后初始化调度器(线程池,存储器,job,trriger监控器,JMX,及调度器仓库,如果存储器为JobStoreTX ,则初始化数据库信息);从返回的调度器来看实际上就是QuartzScheduler
Quartz的Scheduler初始化源码分析:http://donald-draper.iteye.com/blog/2322730
Quartz的job、触发器的暂停与恢复源码分析:http://donald-draper.iteye.com/blog/2322823
Quartz的Job存储,触发器、任务删除,源码分析:http://donald-draper.iteye.com/blog/2322725
Quartzs的job,trriger监听器源码分析:http://donald-draper.iteye.com/blog/2322863
Quartz 任务存储JobStoreTX 持久化之RDB:http://donald-draper.iteye.com/blog/2323297
Quartz 任务存储JobStoreTX 持久化之RDB-源码分析:http://donald-draper.iteye.com/blog/2323409
Quartz任务调度源码分析:http://donald-draper.iteye.com/blog/2323118
Spring与Quartz集成详解:http://donald-draper.iteye.com/blog/2323591
Spring与Quartz集成-源码分析:http://donald-draper.iteye.com/blog/2324132
一般获取Scheduler的方式
第一种:
SchedulerFactory schedulerFactory = new StdSchedulerFactory(); Scheduler cronScheduler = schedulerFactory.getScheduler();
第二种:
Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler();
下面先来看看第一种到底做了些什么
public class StdSchedulerFactory implements SchedulerFactory { //获取调度器Scheduler public Scheduler getScheduler() throws SchedulerException { if(cfg == null) //初始化Quartz属性,线程池,线程数,线程优先级,job存储容器 initialize(); //获取调度器仓库单例 SchedulerRepository schedRep = SchedulerRepository.getInstance(); //根据调度器name,寻到对应的Scheduler Scheduler sched = schedRep.lookup(getSchedulerName()); if(sched != null) if(sched.isShutdown()) schedRep.remove(getSchedulerName()); else return sched; //初始化调度器 sched = instantiate(); return sched; } //从StdSchedulerFactory的getDefaultScheduler方法可以看出 //与getScheduler相同 public static Scheduler getDefaultScheduler() throws SchedulerException { StdSchedulerFactory fact = new StdSchedulerFactory(); return fact.getScheduler(); } //初始化Quartz属性,线程池,线程数,线程优先级,job存储容器配置 public void initialize() throws SchedulerException { String requestedFile; String propFileName; File propFile; Properties props; InputStream in; if(cfg != null) return; if(initException != null) throw initException; requestedFile = System.getProperty("org.quartz.properties"); propFileName = requestedFile == null ? "quartz.properties" : requestedFile; propFile = new File(propFileName); props = new Properties(); in = null; //如果propFile存在,则从文件系统,加载相应的属性文件 if(propFile.exists()) try { if(requestedFile != null) propSrc = (new StringBuilder()).append("specified file: '").append(requestedFile).append("'").toString(); else propSrc = "default file in current working dir: 'quartz.properties'"; in = new BufferedInputStream(new FileInputStream(propFileName)); props.load(in); } catch(IOException ioe) { initException = new SchedulerException((new StringBuilder()).append("Properties file: '").append(propFileName).append("' could not be read.").toString(), ioe); throw initException; } else //如果org.quartz.propertiess属性文件不为null,则从当前Thread的ClassLoader的Context加载相应的属性文件 if(requestedFile != null) { in = Thread.currentThread().getContextClassLoader().getResourceAsStream(requestedFile); if(in == null) { initException = new SchedulerException((new StringBuilder()).append("Properties file: '").append(requestedFile).append("' could not be found.").toString()); throw initException; } propSrc = (new StringBuilder()).append("specified file: '").append(requestedFile).append("' in the class resource path.").toString(); in = new BufferedInputStream(in); try { props.load(in); } catch(IOException ioe) { initException = new SchedulerException((new StringBuilder()).append("Properties file: '").append(requestedFile).append("' could not be read.").toString(), ioe); throw initException; } } else { propSrc = "default resource file in Quartz package: 'quartz.properties'"; ClassLoader cl = getClass().getClassLoader(); if(cl == null) cl = findClassloader(); if(cl == null) throw new SchedulerConfigException("Unable to find a class loader on the current thread or class."); in = cl.getResourceAsStream("quartz.properties"); if(in == null) in = cl.getResourceAsStream("/quartz.properties"); if(in == null) in = cl.getResourceAsStream("org/quartz/quartz.properties"); if(in == null) { initException = new SchedulerException("Default quartz.properties not found in class path"); throw initException; } try { props.load(in); } catch(IOException ioe) { initException = new SchedulerException("Resource properties file: 'org/quartz/quartz.properties' could not be read from the classpath.", ioe); throw initException; } } if(in != null) try { in.close(); } catch(IOException ignore) { } break MISSING_BLOCK_LABEL_502; Exception exception; exception; if(in != null) try { in.close(); } catch(IOException ignore) { } throw exception; initialize(overrideWithSysProps(props)); return; } //重载系统属性 private Properties overrideWithSysProps(Properties props) { Properties sysProps = null; try { sysProps = System.getProperties(); } catch(AccessControlException e) { getLog().warn("Skipping overriding quartz properties with System properties during initialization because of an AccessControlException. This is likely due to not having read/write access for java.util.PropertyPermission as required by java.lang.System.getProperties(). To resolve this warning, either add this permission to your policy file or use a non-default version of initialize().", e); } if(sysProps != null) props.putAll(sysProps); return props; } //初始化PropertiesParser public void initialize(Properties props) throws SchedulerException { if(propSrc == null) propSrc = "an externally provided properties instance."; cfg = new PropertiesParser(props); } //初始化Quartz属性,线程池,线程数,线程优先级,job存储容器 private Scheduler instantiate() throws SchedulerException { JobStore js;//job存储器 ThreadPool tp;// 线程池 QuartzScheduler qs; DBConnectionManager dbMgr;//数据库连接管理器 ThreadExecutor threadExecutor;//线程执行器 SchedulerRepository schedRep;//调度器仓库 boolean makeSchedulerThreadDaemon;//Scheduler调度线程方式前台,守候 boolean threadsInheritInitalizersClassLoader;//线程初始化继承属性 long batchTimeWindow; int maxBatchSize; if(cfg == null)//initialize(Properties props)已经初始化cfg initialize(); if(initException != null) throw initException; //初始化相关属性 schedRep = SchedulerRepository.getInstance(); schedName = cfg.getStringProperty("org.quartz.scheduler.instanceName", "QuartzScheduler"); threadName = cfg.getStringProperty("org.quartz.scheduler.threadName", (new StringBuilder()).append(schedName).append("_QuartzSchedulerThread").toString()); schedInstId = cfg.getStringProperty("org.quartz.scheduler.instanceId", "NON_CLUSTERED") String classLoadHelperClass = cfg.getStringProperty("org.quartz.scheduler.classLoadHelper.class", "org.quartz.simpl.CascadingClassLoadHelper"); String jobFactoryClass = cfg.getStringProperty("org.quartz.scheduler.jobFactory.class", null); batchTimeWindow = cfg.getLongProperty("org.quartz.scheduler.batchTriggerAcquisitionFireAheadTimeWindow", 0L); maxBatchSize = cfg.getIntProperty("org.quartz.scheduler.batchTriggerAcquisitionMaxCount", 1); jmxExport = cfg.getBooleanProperty("org.quartz.scheduler.jmx.export"); jmxObjectName = cfg.getStringProperty("org.quartz.scheduler.jmx.objectName"); boolean jmxProxy = cfg.getBooleanProperty("org.quartz.scheduler.jmx.proxy"); String jmxProxyClass = cfg.getStringProperty("org.quartz.scheduler.jmx.proxy.class"); loadHelper.initialize(); //初始化JMX Proxy if(jmxProxy) { if(autoId) schedInstId = "NON_CLUSTERED"; if(jmxProxyClass == null) throw new SchedulerConfigException("No JMX Proxy Scheduler class provided"); RemoteMBeanScheduler jmxScheduler = null; try { jmxScheduler = (RemoteMBeanScheduler)loadHelper.loadClass(jmxProxyClass).newInstance(); } if(jmxObjectName == null) jmxObjectName = QuartzSchedulerResources.generateJMXObjectName(schedName, schedInstId); jmxScheduler.setSchedulerObjectName(jmxObjectName); tProps = cfg.getPropertyGroup("org.quartz.scheduler.jmx.proxy", true); try { setBeanProps(jmxScheduler, tProps); } jmxScheduler.initialize(); schedRep.bind(jmxScheduler); return jmxScheduler; } jobFactory = null; //初始化jobFactory if(jobFactoryClass != null) { try { jobFactory = (jobFactory)loadHelper.loadClass(jobFactoryClass).newInstance(); } tProps = cfg.getPropertyGroup("org.quartz.scheduler.jobFactory", true); try { setBeanProps(jobFactory, tProps); } } //加载JobStore,org.quartz.jobStore.class = org.quartz.simpl.RAMJobStore try { js = (JobStore)loadHelper.loadClass(jsClass).newInstance(); } //如果org.quartz.jobStore.class = org.quartz.impl.jdbcjobstore.JobStoreTX ,配置数据库信息 String dsNames[] = cfg.getPropertyGroups("org.quartz.dataSource"); for(int i = 0; i < dsNames.length; i++) { PropertiesParser pp = new PropertiesParser(cfg.getPropertyGroup((new StringBuilder()).append("org.quartz.dataSource.").append(dsNames[i]).toString(), true)); String cpClass = pp.getStringProperty("connectionProvider.class", null); if(cpClass != null) { ConnectionProvider cp = null; try { cp = (ConnectionProvider)loadHelper.loadClass(cpClass).newInstance(); } try { pp.getUnderlyingProperties().remove("connectionProvider.class"); setBeanProps(cp, pp.getUnderlyingProperties()); cp.initialize(); } dbMgr = DBConnectionManager.getInstance(); dbMgr.addConnectionProvider(dsNames[i], cp); continue; } try { PoolingConnectionProvider cp = new PoolingConnectionProvider(pp.getUnderlyingProperties()); dbMgr = DBConnectionManager.getInstance(); dbMgr.addConnectionProvider(dsNames[i], cp); continue; } } //初始化插件 pluginNames = cfg.getPropertyGroups("org.quartz.plugin"); plugins = new SchedulerPlugin[pluginNames.length]; for(int i = 0; i < pluginNames.length; i++) { Properties pp = cfg.getPropertyGroup((new StringBuilder()).append("org.quartz.plugin.").append(pluginNames[i]).toString(), true); String plugInClass = pp.getProperty("class", null); if(plugInClass == null) { initException = new SchedulerException((new StringBuilder()).append("SchedulerPlugin class not specified for plugin '").append(pluginNames[i]).append("'").toString()); throw initException; } SchedulerPlugin plugin = null; try { plugin = (SchedulerPlugin)loadHelper.loadClass(plugInClass).newInstance(); } try { setBeanProps(plugin, pp); } plugins[i] = plugin; } //job监听器 String jobListenerNames[] = cfg.getPropertyGroups("org.quartz.jobListener"); jobListeners = new JobListener[jobListenerNames.length]; for(int i = 0; i < jobListenerNames.length; i++) { Properties lp = cfg.getPropertyGroup((new StringBuilder()).append("org.quartz.jobListener.").append(jobListenerNames[i]).toString(), true); String listenerClass = lp.getProperty("class", null); if(listenerClass == null) { initException = new SchedulerException((new StringBuilder()).append("JobListener class not specified for listener '").append(jobListenerNames[i]).append("'").toString()); throw initException; } JobListener listener = null; try { listener = (JobListener)loadHelper.loadClass(listenerClass).newInstance(); } try { Method nameSetter = null; try { nameSetter = listener.getClass().getMethod("setName", strArg); } if(nameSetter != null) nameSetter.invoke(listener, new Object[] { jobListenerNames[i] }); setBeanProps(listener, lp); } jobListeners[i] = listener; } //Trrige监听器 String triggerListenerNames[] = cfg.getPropertyGroups("org.quartz.triggerListener"); triggerListeners = new TriggerListener[triggerListenerNames.length]; for(int i = 0; i < triggerListenerNames.length; i++) { Properties lp = cfg.getPropertyGroup((new StringBuilder()).append("org.quartz.triggerListener.").append(triggerListenerNames[i]).toString(), true); String listenerClass = lp.getProperty("class", null); if(listenerClass == null) { initException = new SchedulerException((new StringBuilder()).append("TriggerListener class not specified for listener '").append(triggerListenerNames[i]).append("'").toString()); throw initException; } TriggerListener listener = null; try { listener = (TriggerListener)loadHelper.loadClass(listenerClass).newInstance(); } try { Method nameSetter = null; try { nameSetter = listener.getClass().getMethod("setName", strArg); } if(nameSetter != null) nameSetter.invoke(listener, new Object[] { triggerListenerNames[i] }); setBeanProps(listener, lp); } triggerListeners[i] = listener; } //初始化线程池执行类 String threadExecutorClass = cfg.getStringProperty("org.quartz.threadExecutor.class"); if(threadExecutorClass != null) { tProps = cfg.getPropertyGroup("org.quartz.threadExecutor", true); try { threadExecutor = (ThreadExecutor)loadHelper.loadClass(threadExecutorClass).newInstance(); log.info((new StringBuilder()).append("Using custom implementation for ThreadExecutor: ").append(threadExecutorClass).toString()); setBeanProps(threadExecutor, tProps); } } else { log.info("Using default implementation for ThreadExecutor"); threadExecutor = new DefaultThreadExecutor(); } Scheduler scheduler; //初始化job执行器 JobRunShellFactory jrsf = null; if(userTXLocation != null) UserTransactionHelper.setUserTxLocation(userTXLocation); if(wrapJobInTx) jrsf = new JTAJobRunShellFactory(); else jrsf = new JTAAnnotationAwareJobRunShellFactory(); if(autoId) try { schedInstId = "NON_CLUSTERED"; if(js.isClustered()) schedInstId = instanceIdGenerator.generateInstanceId(); } catch(Exception e) { getLog().error("Couldn't generate instance Id!", e); throw new IllegalStateException("Cannot run without an instance id."); } if(js.getClass().getName().startsWith("org.terracotta.quartz")) { try { String uuid = (String)js.getClass().getMethod("getUUID", new Class[0]).invoke(js, new Object[0]); if(schedInstId.equals("NON_CLUSTERED")) { schedInstId = (new StringBuilder()).append("TERRACOTTA_CLUSTERED,node=").append(uuid).toString(); if(jmxObjectName == null) jmxObjectName = QuartzSchedulerResources.generateJMXObjectName(schedName, schedInstId); } else if(jmxObjectName == null) jmxObjectName = QuartzSchedulerResources.generateJMXObjectName(schedName, (new StringBuilder()).append(schedInstId).append(",node=").append(uuid).toString()); } catch(Exception e) { throw new RuntimeException("Problem obtaining node id from TerracottaJobStore.", e); } if(null == cfg.getStringProperty("org.quartz.scheduler.jmx.export")) jmxExport = true; } if(js instanceof JobStoreSupport) { JobStoreSupport jjs = (JobStoreSupport)js; jjs.setDbRetryInterval(dbFailureRetry); if(threadsInheritInitalizersClassLoader) jjs.setThreadsInheritInitializersClassLoadContext(threadsInheritInitalizersClassLoader); jjs.setThreadExecutor(threadExecutor); } //QuartzScheduler资源管理器 QuartzSchedulerResources rsrcs = new QuartzSchedulerResources(); rsrcs.setName(schedName); rsrcs.setThreadName(threadName); rsrcs.setInstanceId(schedInstId); rsrcs.setJobRunShellFactory(jrsf); rsrcs.setMakeSchedulerThreadDaemon(makeSchedulerThreadDaemon); rsrcs.setThreadsInheritInitializersClassLoadContext(threadsInheritInitalizersClassLoader); rsrcs.setRunUpdateCheck(!skipUpdateCheck); rsrcs.setBatchTimeWindow(batchTimeWindow); rsrcs.setMaxBatchSize(maxBatchSize); rsrcs.setInterruptJobsOnShutdown(interruptJobsOnShutdown); rsrcs.setInterruptJobsOnShutdownWithWait(interruptJobsOnShutdownWithWait); rsrcs.setJMXExport(jmxExport); rsrcs.setJMXObjectName(jmxObjectName); if(managementRESTServiceEnabled) { ManagementRESTServiceConfiguration managementRESTServiceConfiguration = new ManagementRESTServiceConfiguration(); managementRESTServiceConfiguration.setBind(managementRESTServiceHostAndPort); managementRESTServiceConfiguration.setEnabled(managementRESTServiceEnabled); rsrcs.setManagementRESTServiceConfiguration(managementRESTServiceConfiguration); } if(rmiExport) { rsrcs.setRMIRegistryHost(rmiHost); rsrcs.setRMIRegistryPort(rmiPort); rsrcs.setRMIServerPort(rmiServerPort); rsrcs.setRMICreateRegistryStrategy(rmiCreateRegistry); rsrcs.setRMIBindName(rmiBindName); } SchedulerDetailsSetter.setDetails(tp, schedName, schedInstId); rsrcs.setThreadExecutor(threadExecutor); //线程池初始化 threadExecutor.initialize(); rsrcs.setThreadPool(tp); if((tp instanceof SimpleThreadPool) && threadsInheritInitalizersClassLoader) ((SimpleThreadPool)tp).setThreadsInheritContextClassLoaderOfInitializingThread(threadsInheritInitalizersClassLoader); tp.initialize(); tpInited = true; rsrcs.setJobStore(js); for(int i = 0; i < plugins.length; i++) rsrcs.addSchedulerPlugin(plugins[i]); //新建QuartzScheduler qs = new QuartzScheduler(rsrcs, idleWaitTime, dbFailureRetry); qsInited = true; //初始化scheduler scheduler = instantiate(rsrcs, qs); if(jobFactory != null) qs.setJobFactory(jobFactory); for(int i = 0; i < plugins.length; i++) plugins[i].initialize(pluginNames[i], scheduler, loadHelper); for(int i = 0; i < jobListeners.length; i++) qs.getListenerManager().addJobListener(jobListeners[i], EverythingMatcher.allJobs()); for(int i = 0; i < triggerListeners.length; i++) qs.getListenerManager().addTriggerListener(triggerListeners[i], EverythingMatcher.allTriggers()); Object key; String val; for(Iterator i$ = schedCtxtProps.keySet().iterator(); i$.hasNext(); scheduler.getContext().put((String)key, val)) { key = i$.next(); val = schedCtxtProps.getProperty((String)key); } js.setInstanceId(schedInstId); js.setInstanceName(schedName); js.setThreadPoolSize(tp.getPoolSize()); js.initialize(loadHelper, qs.getSchedulerSignaler()); jrsf.initialize(scheduler); qs.initialize(); getLog().info((new StringBuilder()).append("Quartz scheduler '").append(scheduler.getSchedulerName()).append("' initialized from ").append(propSrc).toString()); getLog().info((new StringBuilder()).append("Quartz scheduler version: ").append(qs.getVersion()).toString()); qs.addNoGCObject(schedRep); if(dbMgr != null) qs.addNoGCObject(dbMgr); //绑定scheduler到调度器仓库 schedRep.bind(scheduler); return scheduler;//实际为QuartzScheduler } //初始化Scheduler protected Scheduler instantiate(QuartzSchedulerResources rsrcs, QuartzScheduler qs) { Scheduler scheduler = new StdScheduler(qs); return scheduler; } //解析quartz.properties配置文件属性 private PropertiesParser cfg; }
//调度器仓库
public class SchedulerRepository { private SchedulerRepository() { schedulers = new HashMap(); } //获取调度器仓库单例 public static synchronized SchedulerRepository getInstance() { if(inst == null) inst = new SchedulerRepository(); return inst; } //添加调度器到仓库 public synchronized void bind(Scheduler sched) throws SchedulerException { if((Scheduler)schedulers.get(sched.getSchedulerName()) != null) { throw new SchedulerException((new StringBuilder()).append("Scheduler with name '").append(sched.getSchedulerName()).append("' already exists.").toString()); } else { schedulers.put(sched.getSchedulerName(), sched); return; } } public synchronized boolean remove(String schedName) { return schedulers.remove(schedName) != null; } //根据调度器name,寻到对应的Scheduler public synchronized Scheduler lookup(String schedName) { return (Scheduler)schedulers.get(schedName); } public synchronized Collection lookupAll() { return Collections.unmodifiableCollection(schedulers.values()); } private HashMap schedulers;//Hash<String,Scheduler> private static SchedulerRepository inst; }
//标准执行器实际上是包装了QuartzScheduler
public class StdScheduler implements Scheduler { public StdScheduler(QuartzScheduler sched) { this.sched = sched; } private QuartzScheduler sched; }
//调度器
public class QuartzScheduler implements RemotableQuartzScheduler { public QuartzScheduler(QuartzSchedulerResources resources, long idleWaitTime, long dbRetryInterval) throws SchedulerException { } private static String VERSION_MAJOR; private static String VERSION_MINOR; private static String VERSION_ITERATION; private QuartzSchedulerResources resources; private QuartzSchedulerThread schedThread; private ThreadGroup threadGroup; private SchedulerContext context; private ListenerManager listenerManager; private HashMap internalJobListeners; private HashMap internalTriggerListeners; private ArrayList internalSchedulerListeners; private JobFactory jobFactory; ExecutingJobsManager jobMgr; ErrorLogger errLogger; private SchedulerSignaler signaler; private Random random; private ArrayList holdToPreventGC; private boolean signalOnSchedulingChange; private volatile boolean closed; private volatile boolean shuttingDown; private boolean boundRemotely; private QuartzSchedulerMBean jmxBean; private Date initialStart; private final Timer updateTimer; private final Logger log = LoggerFactory.getLogger(getClass()); }
//QuartzScheduler的资源管理器
public class QuartzSchedulerResources { public static final String CREATE_REGISTRY_NEVER = "never"; public static final String CREATE_REGISTRY_ALWAYS = "always"; public static final String CREATE_REGISTRY_AS_NEEDED = "as_needed"; private String name; private String instanceId; private String threadName; private String rmiRegistryHost; private int rmiRegistryPort; private int rmiServerPort; private String rmiCreateRegistryStrategy; private ThreadPool threadPool; private JobStore jobStore; private JobRunShellFactory jobRunShellFactory; private List schedulerPlugins; private boolean makeSchedulerThreadDaemon; private boolean threadsInheritInitializersClassLoadContext; private String rmiBindName; private boolean jmxExport; private String jmxObjectName; private ManagementRESTServiceConfiguration managementRESTServiceConfiguration; private ThreadExecutor threadExecutor; private boolean runUpdateCheck; private long batchTimeWindow; private int maxBatchSize; private boolean interruptJobsOnShutdown; private boolean interruptJobsOnShutdownWithWait; }
从StdSchedulerFactory的getDefaultScheduler方法可以看出与getScheduler相同
总结:
从以上代码分析中,看出StdSchedulerFactory获取执行器,首先从调度器仓库获取调度器,如果为空,则配置属性cfg,如果cfg为空则初始化属性文件,如果没有配置属性文件,则加载默认属性;然后初始化调度器(线程池,存储器,job,trriger监控器,JMX,及调度器仓库,如果存储器为JobStoreTX ,则初始化数据库信息);从返回的调度器来看实际上就是QuartzScheduler
发表评论
-
TreeSet在Quartz任务调度过程中的作用
2017-08-24 23:43 681红黑树详解:http://www.cnblogs.com/sk ... -
Quartz使用与Spring集成系列教程
2016-10-26 09:48 457Quartz的使用:http://donald-draper. ... -
Spring与Quartz集成-源码分析
2016-09-13 11:50 2636在阅读以下文章之前,如果对Quartz任务调度不是很熟悉,请看 ... -
Spring与Quartz集成详解
2016-09-09 17:52 2761首先这个所有的依赖包就不需要多讲了,首先下载Quazrt发布包 ... -
Quartz 任务存储JobStoreTX 持久化之RDB-源码分析
2016-09-08 18:24 2216Quartz 任务存储JobStoreTX 持久化之RDB:h ... -
Quartz 任务存储JobStoreTX 持久化之RDB
2016-09-08 11:52 2708Quartz储存方式之JDBC JobStoreTX:http ... -
Quartz任务调度源码分析
2016-09-07 13:12 3508Quartz的使用:http://donald-draper. ... -
Quartz的job调度源码分析
2016-09-06 13:03 8Quartz的使用:http://donald ... -
Quartzs的job,trriger监听器源码分析
2016-09-06 11:15 1439Quartz的使用:http://donald-draper. ... -
Quartz的job、触发器的暂停与恢复源码分析
2016-09-06 09:01 5087Quartz的使用:http://donald-draper. ... -
Quartzs的job存储,触发器、job删除源码分析
2016-09-05 15:39 4422前言:unscheduleJob针对TriggerKey,而d ... -
Quartz的使用
2016-09-05 11:39 1744Quartz使用总结:http://www.cnblogs.c ...
相关推荐
quartz scheduler getting started 的翻译
quartz-2.2.3版本的quartz初始化sql语句
quartz-job数据库初始化表一些表结构整理
Quartz_Scheduler_Configuration_Guide.pdf Version2.2.1
Quartz is a full-featured, open source job scheduling service that can be integrated with, or ... The Quartz Scheduler includes many enterprise-class features, such as JTA transactions and clustering.
本资源是一个最新 Spring 4.2.2 集成 Quartz Scheduler 2.2.2 的一个简单的 demo,也是博客《最新 Spring 4.2.2 集成 Quartz Scheduler 2.2.2 任务调度示例》的配套示例项目,该博客地址是:...
quartz集群调度机制调研及源码分析,基于quartz 1.7版本
Winder 是一个基于 Quartz Scheduler 的简单状态机。它有助于在 Quartz Scheduler 上编写多个步骤任务。Winder 源于一种在 eBay Cloud 中广泛使用的状态机。eBay 平台即服务(PaaS)使用它来将软件部署到数十万个...
里面有个简单的quartz-scheduler java示例。
NOTE: If "org.quartz.scheduler.batchTriggerAcquisitionMaxCount" is set to > 1, and JDBC JobStore is used, then "org.quartz.jobStore.acquireTriggersWithinLock" must be set to "true" to avoid data ...
shiro+SpringMVC+Spring+mybatis+maven+mybatis 自动刷新+ Quartz scheduler 定时器管理
C# quartz.net 定时任务源码,实现了远程操控.动态追加dll,可以安装到windows服务中.
Quartz 批量下载源码,Quartz 批量下载源码Quartz 批量下载源码Quartz 批量下载源码Quartz 批量下载源码Quartz 批量下载源码Quartz 批量下载源码Quartz 批量下载源码Quartz 批量下载源码Quartz 批量下载源码
Getting_Started_with_Quartz_Scheduler.pdf Version 2.2.1
Quartz中文入门教程 前言 Quartz让任务调度简单 ...用调度器(Scheduler)调用你的作业 编程调度同声明性调度 有状态和无状态作业 Quartz框架的其他特征 Quartz下一步计划 了解更多Quartz特征
quartz-1.6.4.源码 src source 11111111111111111111111
本项目中包含实验过得一些例子,对于初学Quartz来说很有帮助.
Quartz官方API文档,最新2.2.1版
Quartz.NET Demo 项目源码,包括所需要的DLL、时间调度配置文档