📄 quartzschedulerresources.java
字号:
/* * Copyright James House (c) 2001-2004 * * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: 1. * Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. 2. Redistributions in * binary form must reproduce the above copyright notice, this list of * conditions and the following disclaimer in the documentation and/or other * materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */package org.quartz.core;import org.quartz.spi.JobStore;import org.quartz.spi.ThreadPool;/** * <p> * Contains all of the resources (<code>JobStore</code>,<code>ThreadPool</code>, * etc.) necessary to create a <code>{@link QuartzScheduler}</code> instance. * </p> * * @see QuartzScheduler * * @author James House */public class QuartzSchedulerResources { /* * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * * Data members. * * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ 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 = null; private int rmiRegistryPort = 1099; private String rmiCreateRegistryStrategy = CREATE_REGISTRY_NEVER; private ThreadPool threadPool; private JobStore jobStore; private JobRunShellFactory jobRunShellFactory; /* * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * * Constructors. * * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ /** * <p> * Create an instance with no properties initialized. * </p> */ public QuartzSchedulerResources() { // do nothing... } /* * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * * Interface. * * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ /** * <p> * Get the name for the <code>{@link QuartzScheduler}</code>. * </p> */ public String getName() { return name; } /** * <p> * Set the name for the <code>{@link QuartzScheduler}</code>. * </p> * * @exception IllegalArgumentException * if name is null or empty. */ public void setName(String name) { if (name == null || name.trim().length() == 0) throw new IllegalArgumentException( "Scheduler name cannot be empty."); this.name = name; if (threadName == null) { // thread name not already set, use default thread name setThreadName(name + "_QuartzSchedulerThread"); } } /** * <p> * Get the instance Id for the <code>{@link QuartzScheduler}</code>. * </p> */ public String getInstanceId() { return instanceId; } /** * <p> * Set the name for the <code>{@link QuartzScheduler}</code>. * </p> * * @exception IllegalArgumentException * if name is null or empty. */ public void setInstanceId(String instanceId) { if (instanceId == null || instanceId.trim().length() == 0) throw new IllegalArgumentException( "Scheduler instanceId cannot be empty."); this.instanceId = instanceId; } public static String getUniqueIdentifier(String schedName, String schedInstId) { return schedName + "_$_" + schedInstId; } public String getUniqueIdentifier() { return getUniqueIdentifier(name, instanceId); } /** * <p> * Get the host name of the RMI Registry that the scheduler should export * itself to. * </p> */ public String getRMIRegistryHost() { return rmiRegistryHost; } /** * <p> * Set the host name of the RMI Registry that the scheduler should export * itself to. * </p> */ public void setRMIRegistryHost(String hostName) { this.rmiRegistryHost = hostName; } /** * <p> * Get the port number of the RMI Registry that the scheduler should export * itself to. * </p> */ public int getRMIRegistryPort() { return rmiRegistryPort; } /** * <p> * Set the port number of the RMI Registry that the scheduler should export * itself to. * </p> */ public void setRMIRegistryPort(int port) { this.rmiRegistryPort = port; } /** * <p> * Get the setting of whether or not Quartz should create an RMI Registry, * and if so, how. * </p> */ public String getRMICreateRegistryStrategy() { return rmiCreateRegistryStrategy; } /** * <p> * Get the name for the <code>{@link QuartzSchedulerThread}</code>. * </p> */ public String getThreadName() { return threadName; } /** * <p> * Set the name for the <code>{@link QuartzSchedulerThread}</code>. * </p> * * @exception IllegalArgumentException * if name is null or empty. */ public void setThreadName(String threadName) { if (threadName == null || threadName.trim().length() == 0) throw new IllegalArgumentException( "Scheduler thread name cannot be empty."); this.threadName = threadName; } /** * <p> * Set whether or not Quartz should create an RMI Registry, and if so, how. * </p> * * @see #CREATE_REGISTRY_ALWAYS * @see #CREATE_REGISTRY_AS_NEEDED * @see #CREATE_REGISTRY_NEVER */ public void setRMICreateRegistryStrategy(String rmiCreateRegistryStrategy) { if (rmiCreateRegistryStrategy == null || rmiCreateRegistryStrategy.trim().length() == 0) rmiCreateRegistryStrategy = CREATE_REGISTRY_NEVER; else if (rmiCreateRegistryStrategy.equalsIgnoreCase("true")) rmiCreateRegistryStrategy = CREATE_REGISTRY_AS_NEEDED; else if (rmiCreateRegistryStrategy.equalsIgnoreCase("false")) rmiCreateRegistryStrategy = CREATE_REGISTRY_NEVER; else if (rmiCreateRegistryStrategy .equalsIgnoreCase(CREATE_REGISTRY_ALWAYS)) rmiCreateRegistryStrategy = CREATE_REGISTRY_ALWAYS; else if (rmiCreateRegistryStrategy .equalsIgnoreCase(CREATE_REGISTRY_AS_NEEDED)) rmiCreateRegistryStrategy = CREATE_REGISTRY_AS_NEEDED; else if (rmiCreateRegistryStrategy .equalsIgnoreCase(CREATE_REGISTRY_NEVER)) rmiCreateRegistryStrategy = CREATE_REGISTRY_NEVER; else throw new IllegalArgumentException( "Faild to set RMICreateRegistryStrategy - strategy unknown: '" + rmiCreateRegistryStrategy + "'"); this.rmiCreateRegistryStrategy = rmiCreateRegistryStrategy; } /** * <p> * Get the <code>{@link ThreadPool}</code> for the <code>{@link QuartzScheduler}</code> * to use. * </p> */ public ThreadPool getThreadPool() { return threadPool; } /** * <p> * Set the <code>{@link ThreadPool}</code> for the <code>{@link QuartzScheduler}</code> * to use. * </p> * * @exception IllegalArgumentException * if threadPool is null. */ public void setThreadPool(ThreadPool threadPool) { if (threadPool == null) throw new IllegalArgumentException("ThreadPool cannot be null."); this.threadPool = threadPool; } /** * <p> * Get the <code>{@link JobStore}</code> for the <code>{@link QuartzScheduler}</code> * to use. * </p> */ public JobStore getJobStore() { return jobStore; } /** * <p> * Set the <code>{@link JobStore}</code> for the <code>{@link QuartzScheduler}</code> * to use. * </p> * * @exception IllegalArgumentException * if jobStore is null. */ public void setJobStore(JobStore jobStore) { if (jobStore == null) throw new IllegalArgumentException("JobStore cannot be null."); this.jobStore = jobStore; } /** * <p> * Get the <code>{@link JobRunShellFactory}</code> for the <code>{@link QuartzScheduler}</code> * to use. * </p> */ public JobRunShellFactory getJobRunShellFactory() { return jobRunShellFactory; } /** * <p> * Set the <code>{@link JobRunShellFactory}</code> for the <code>{@link QuartzScheduler}</code> * to use. * </p> * * @exception IllegalArgumentException * if jobRunShellFactory is null. */ public void setJobRunShellFactory(JobRunShellFactory jobRunShellFactory) { if (jobRunShellFactory == null) throw new IllegalArgumentException( "JobRunShellFactory cannot be null."); this.jobRunShellFactory = jobRunShellFactory; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -