⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 directschedulerfactory.java

📁 Quartz is a full-featured, open source job scheduling system that can be integrated with, or used al
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
     * @throws SchedulerException     *           if the remote scheduler could not be reached.     */    public void createRemoteScheduler(String schedulerName,            String schedulerInstanceId, String rmiBindName, String rmiHost, int rmiPort)        throws SchedulerException {        SchedulingContext schedCtxt = new SchedulingContext();        schedCtxt.setInstanceId(schedulerInstanceId);        String uid = (rmiBindName != null) ? rmiBindName :             QuartzSchedulerResources.getUniqueIdentifier(                schedulerName, schedulerInstanceId);        RemoteScheduler remoteScheduler = new RemoteScheduler(schedCtxt, uid,                rmiHost, rmiPort);        SchedulerRepository schedRep = SchedulerRepository.getInstance();        schedRep.bind(remoteScheduler);    }        /**     * Creates a scheduler using the specified thread pool and job store. This     * scheduler can be retrieved via     * {@link DirectSchedulerFactory#getScheduler()}     *      * @param threadPool     *          The thread pool for executing jobs     * @param jobStore     *          The type of job store     * @throws SchedulerException     *           if initialization failed     */    public void createScheduler(ThreadPool threadPool, JobStore jobStore)        throws SchedulerException {        createScheduler(DEFAULT_SCHEDULER_NAME, DEFAULT_INSTANCE_ID,                threadPool, jobStore);        initialized = true;    }    /**     * Same as     * {@link DirectSchedulerFactory#createScheduler(ThreadPool threadPool, JobStore jobStore)},     * with the addition of specifying the scheduler name and instance ID. This     * scheduler can only be retrieved via     * {@link DirectSchedulerFactory#getScheduler(String)}     *      * @param schedulerName     *          The name for the scheduler.     * @param schedulerInstanceId     *          The instance ID for the scheduler.     * @param threadPool     *          The thread pool for executing jobs     * @param jobStore     *          The type of job store     * @throws SchedulerException     *           if initialization failed     */    public void createScheduler(String schedulerName,            String schedulerInstanceId, ThreadPool threadPool, JobStore jobStore)        throws SchedulerException {        createScheduler(schedulerName, schedulerInstanceId, threadPool,                jobStore, null, 0, -1, -1);    }    /**     * Creates a scheduler using the specified thread pool and job store and     * binds it to RMI.     *      * @param schedulerName     *          The name for the scheduler.     * @param schedulerInstanceId     *          The instance ID for the scheduler.     * @param threadPool     *          The thread pool for executing jobs     * @param jobStore     *          The type of job store     * @param rmiRegistryHost     *          The hostname to register this scheduler with for RMI. Can use     *          "null" if no RMI is required.     * @param rmiRegistryPort     *          The port for RMI. Typically 1099.     * @param idleWaitTime     *          The idle wait time in milliseconds. You can specify "-1" for     *          the default value, which is currently 30000 ms.     * @throws SchedulerException     *           if initialization failed     */    public void createScheduler(String schedulerName,            String schedulerInstanceId, ThreadPool threadPool,            JobStore jobStore, String rmiRegistryHost, int rmiRegistryPort,            long idleWaitTime, long dbFailureRetryInterval)        throws SchedulerException {        createScheduler(schedulerName,                schedulerInstanceId, threadPool,                jobStore, null, // plugins                rmiRegistryHost, rmiRegistryPort,                idleWaitTime, dbFailureRetryInterval);    }        /**     * Creates a scheduler using the specified thread pool, job store, and     * plugins, and binds it to RMI.     *      * @param schedulerName     *          The name for the scheduler.     * @param schedulerInstanceId     *          The instance ID for the scheduler.     * @param threadPool     *          The thread pool for executing jobs     * @param jobStore     *          The type of job store     * @param schedulerPluginMap     *          Map from a <code>String</code> plugin names to       *          <code>{@link org.quartz.spi.SchedulerPlugin}</code>s.  Can use     *          "null" if no plugins are required.      * @param rmiRegistryHost     *          The hostname to register this scheduler with for RMI. Can use     *          "null" if no RMI is required.     * @param rmiRegistryPort     *          The port for RMI. Typically 1099.     * @param idleWaitTime     *          The idle wait time in milliseconds. You can specify "-1" for     *          the default value, which is currently 30000 ms.     * @throws SchedulerException     *           if initialization failed     */    public void createScheduler(String schedulerName,            String schedulerInstanceId, ThreadPool threadPool,            JobStore jobStore, Map schedulerPluginMap,             String rmiRegistryHost, int rmiRegistryPort,            long idleWaitTime, long dbFailureRetryInterval)        throws SchedulerException {        // Currently only one run-shell factory is available...        JobRunShellFactory jrsf = new StdJobRunShellFactory();        // Fire everything up        // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~        SchedulingContext schedCtxt = new SchedulingContext();        schedCtxt.setInstanceId(schedulerInstanceId);        QuartzSchedulerResources qrs = new QuartzSchedulerResources();        qrs.setName(schedulerName);        qrs.setInstanceId(schedulerInstanceId);        qrs.setJobRunShellFactory(jrsf);        qrs.setThreadPool(threadPool);        qrs.setJobStore(jobStore);        qrs.setRMIRegistryHost(rmiRegistryHost);        qrs.setRMIRegistryPort(rmiRegistryPort);        // add plugins        if (schedulerPluginMap != null) {            for (Iterator pluginIter = schedulerPluginMap.values().iterator(); pluginIter.hasNext();) {                qrs.addSchedulerPlugin((SchedulerPlugin)pluginIter.next());            }        }                QuartzScheduler qs = new QuartzScheduler(qrs, schedCtxt, idleWaitTime,                dbFailureRetryInterval);        ClassLoadHelper cch = new CascadingClassLoadHelper();        cch.initialize();                jobStore.initialize(cch, qs.getSchedulerSignaler());        Scheduler scheduler = new StdScheduler(qs, schedCtxt);        // Initialize plugins now that we have a Scheduler instance.        if (schedulerPluginMap != null) {            for (Iterator pluginEntryIter = schedulerPluginMap.entrySet().iterator(); pluginEntryIter.hasNext();) {                Map.Entry pluginEntry = (Map.Entry)pluginEntryIter.next();                ((SchedulerPlugin)pluginEntry.getValue()).initialize(                        (String)pluginEntry.getKey(), scheduler);            }        }        jrsf.initialize(scheduler, schedCtxt);        getLog().info("Quartz scheduler '" + scheduler.getSchedulerName());        getLog().info("Quartz scheduler version: " + qs.getVersion());        SchedulerRepository schedRep = SchedulerRepository.getInstance();        qs.addNoGCObject(schedRep); // prevents the repository from being        // garbage collected        schedRep.bind(scheduler);    }    /*     * public void registerSchedulerForRmi(String schedulerName, String     * schedulerId, String registryHost, int registryPort) throws     * SchedulerException, RemoteException { QuartzScheduler scheduler =     * (QuartzScheduler) this.getScheduler(); scheduler.bind(registryHost,     * registryPort); }     */    /**     * <p>     * Returns a handle to the Scheduler produced by this factory.     * </p>     *      * <p>     * you must call createRemoteScheduler or createScheduler methods before     * calling getScheduler()     * </p>     */    public Scheduler getScheduler() throws SchedulerException {        if (!initialized) {             throw new SchedulerException(                "you must call createRemoteScheduler or createScheduler methods before calling getScheduler()");         }                return getScheduler(DEFAULT_SCHEDULER_NAME);    }    /**     * <p>     * Returns a handle to the Scheduler with the given name, if it exists.     * </p>     */    public Scheduler getScheduler(String schedName) throws SchedulerException {        SchedulerRepository schedRep = SchedulerRepository.getInstance();        return schedRep.lookup(schedName);    }    /**     * <p>     * Returns a handle to all known Schedulers (made by any     * StdSchedulerFactory instance.).     * </p>     */    public Collection getAllSchedulers() throws SchedulerException {        return SchedulerRepository.getInstance().lookupAll();    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -