Java 类org.quartz.SchedulerConfigException 实例源码

项目:lams    文件:AbstractTerracottaJobStore.java   
@Override
public void initialize(ClassLoadHelper loadHelper, SchedulerSignaler signaler) throws SchedulerConfigException {
  init();
  realJobStore.setInstanceId(schedInstId);
  realJobStore.setInstanceName(schedName);
  realJobStore.setTcRetryInterval(tcRetryInterval);

  if (misFireThreshold != null) {
    realJobStore.setMisfireThreshold(misFireThreshold);
  }

  if (synchWrite != null) {
    realJobStore.setSynchronousWrite(synchWrite);
  }

  if (estimatedTimeToReleaseAndAcquireTrigger != null) {
    realJobStore.setEstimatedTimeToReleaseAndAcquireTrigger(estimatedTimeToReleaseAndAcquireTrigger);
  }

  realJobStore.initialize(loadHelper, signaler);
}
项目:lams    文件:PlainTerracottaJobStore.java   
@Override
public synchronized void initialize(ClassLoadHelper loadHelper, SchedulerSignaler signaler)
    throws SchedulerConfigException {
  if (clusteredJobStore != null) { throw new IllegalStateException("already initialized"); }

  clusteredJobStore = createNewJobStoreInstance(schedName, Boolean.valueOf(synchWrite));
  clusteredJobStore.setThreadPoolSize(threadPoolSize);

  // apply deferred misfire threshold if present
  if (misfireThreshold != null) {
    clusteredJobStore.setMisfireThreshold(misfireThreshold);
    misfireThreshold = null;
  }

  if (estimatedTimeToReleaseAndAcquireTrigger != null) {
    clusteredJobStore.setEstimatedTimeToReleaseAndAcquireTrigger(estimatedTimeToReleaseAndAcquireTrigger);
    estimatedTimeToReleaseAndAcquireTrigger = null;
  }
  clusteredJobStore.setInstanceId(schedInstanceId);
  clusteredJobStore.setTcRetryInterval(tcRetryInterval);
  clusteredJobStore.initialize(loadHelper, signaler);

  // update check
  scheduleUpdateCheck();
}
项目:lams    文件:QuartzService.java   
public void setJndiName(String jndiName) throws Exception {
    String oldName = this.jndiName;
    this.jndiName = jndiName;

    if (super.getState() == STARTED) {
        unbind(oldName);

        try {
            rebind();
        } catch (NamingException ne) {
            log.error("Failed to rebind Scheduler", ne);

            throw new SchedulerConfigException(
                    "Failed to rebind Scheduler - ", ne);
        }
    }
}
项目:lams    文件:QuartzService.java   
@Override
public void stopService() throws Exception {
    log.info("Stop QuartzService(" + jndiName + ")...");

    try {
        Scheduler scheduler = schedulerFactory.getScheduler();

        scheduler.shutdown();
    } catch (Exception e) {
        log.error("Failed to shutdown Scheduler", e);

        throw new SchedulerConfigException(
                "Failed to shutdown Scheduler - ", e);
    }

    unbind(jndiName);

    log.info("QuartzService(" + jndiName + ") stopped.");
}
项目:lams    文件:JobStoreSupport.java   
/**
 * @see org.quartz.spi.JobStore#schedulerStarted()
 */
public void schedulerStarted() throws SchedulerException {

    if (isClustered()) {
        clusterManagementThread = new ClusterManager();
        if(initializersLoader != null)
            clusterManagementThread.setContextClassLoader(initializersLoader);
        clusterManagementThread.initialize();
    } else {
        try {
            recoverJobs();
        } catch (SchedulerException se) {
            throw new SchedulerConfigException(
                    "Failure occured during job recovery.", se);
        }
    }

    misfireHandler = new MisfireHandler();
    if(initializersLoader != null)
        misfireHandler.setContextClassLoader(initializersLoader);
    misfireHandler.initialize();
    schedulerRunning = true;

    getLog().debug("JobStore background threads started (as scheduler was started).");
}
项目:lams    文件:JobStoreCMT.java   
@Override
public void initialize(ClassLoadHelper loadHelper,
        SchedulerSignaler signaler) throws SchedulerConfigException {

    if (nonManagedTxDsName == null) {
        throw new SchedulerConfigException(
            "Non-ManagedTX DataSource name not set!  " +
            "If your 'org.quartz.jobStore.dataSource' is XA, then set " + 
            "'org.quartz.jobStore.nonManagedTXDataSource' to a non-XA "+ 
            "datasource (for the same DB).  " + 
            "Otherwise, you can set them to be the same.");
    }

    if (getLockHandler() == null) {
        // If the user hasn't specified an explicit lock handler, 
        // then we *must* use DB locks with CMT...
        setUseDBLocks(true);
    }

    super.initialize(loadHelper, signaler);

    getLog().info("JobStoreCMT initialized.");
}
项目:asura    文件:JobStoreSupport.java   
/**
 * @see org.quartz.spi.JobStore#schedulerStarted()
 */
public void schedulerStarted() throws SchedulerException {

    if (isClustered()) {
        clusterManagementThread = new ClusterManager();
        if(initializersLoader != null)
            clusterManagementThread.setContextClassLoader(initializersLoader);
        clusterManagementThread.initialize();
    } else {
        try {
            recoverJobs();
        } catch (SchedulerException se) {
            throw new SchedulerConfigException(
                    "Failure occured during job recovery.", se);
        }
    }

    misfireHandler = new MisfireHandler();
    if(initializersLoader != null)
        misfireHandler.setContextClassLoader(initializersLoader);
    misfireHandler.initialize();
}
项目:asura    文件:JobStoreCMT.java   
public void initialize(ClassLoadHelper loadHelper,
        SchedulerSignaler signaler) throws SchedulerConfigException {

    if (nonManagedTxDsName == null) {
        throw new SchedulerConfigException(
            "Non-ManagedTX DataSource name not set!  " +
            "If your 'org.quartz.jobStore.dataSource' is XA, then set " + 
            "'org.quartz.jobStore.nonManagedTXDataSource' to a non-XA "+ 
            "datasource (for the same DB).  " + 
            "Otherwise, you can set them to be the same.");
    }

    if (getLockHandler() == null) {
        // If the user hasn't specified an explicit lock handler, 
        // then we *must* use DB locks with CMT...
        setUseDBLocks(true);
    }

    super.initialize(loadHelper, signaler);

    getLog().info("JobStoreCMT initialized.");
}
项目:redis-quartz    文件:RedisJobStore.java   
@Override
public void initialize(ClassLoadHelper loadHelper,
        SchedulerSignaler signaler) throws SchedulerConfigException {

    this.loadHelper = loadHelper;
    this.signaler = signaler;       

    // initializing a connection pool
    JedisPoolConfig config = new JedisPoolConfig();
    if (password != null)
        pool = new JedisPool(config, host, port, Protocol.DEFAULT_TIMEOUT, password);               
    else
        pool = new JedisPool(config, host, port, Protocol.DEFAULT_TIMEOUT);

    // initializing a locking connection pool with a longer timeout
    if (lockTimeout == 0)
        lockTimeout = 10 * 60 * 1000; // 10 Minutes locking timeout

     lockPool = new JedisLock(pool.getResource(), "JobLock", lockTimeout);

}
项目:quartz-dynamodb    文件:DynamoDbJobStore.java   
@Override
public void initialize(ClassLoadHelper loadHelper, SchedulerSignaler schedulerSignaler) throws SchedulerConfigException {
    this.loadHelper = loadHelper;
    this.schedulerSignaler = schedulerSignaler;

    if (dynamoDbUrl == null) {
        throw new SchedulerConfigException("DynamoDB location must be set");
    }

    log.info(String.format("DynamoDb: location: '%s', table prefix: '%s'", dynamoDbUrl, quartzPrefix));

    configureAwsCredentials();
    configureClient();

    createClient();

    ensureTables();
}
项目:lams    文件:LocalTaskExecutorThreadPool.java   
@Override
public void initialize() throws SchedulerConfigException {
    // Absolutely needs thread-bound TaskExecutor to initialize.
    this.taskExecutor = SchedulerFactoryBean.getConfigTimeTaskExecutor();
    if (this.taskExecutor == null) {
        throw new SchedulerConfigException(
            "No local TaskExecutor found for configuration - " +
            "'taskExecutor' property must be set on SchedulerFactoryBean");
    }
}
项目:lams    文件:AbstractTerracottaJobStore.java   
private void init() throws SchedulerConfigException {
  if (realJobStore != null) { return; }

  if ((tcConfig != null) && (tcConfigUrl != null)) {
    //
    throw new SchedulerConfigException("Both " + TC_CONFIG_PROP + " and " + TC_CONFIGURL_PROP
                                       + " are set in your properties. Please define only one of them");
  }

  if ((tcConfig == null) && (tcConfigUrl == null)) {
    //
    throw new SchedulerConfigException("Neither " + TC_CONFIG_PROP + " or " + TC_CONFIGURL_PROP
                                       + " are set in your properties. Please define one of them");
  }

  final boolean isURLConfig = tcConfig == null;
  TerracottaToolkitBuilder toolkitBuilder = new TerracottaToolkitBuilder();
  if (isURLConfig) {
    toolkitBuilder.setTCConfigUrl(tcConfigUrl);
  } else {
    toolkitBuilder.setTCConfigSnippet(tcConfig);
  }
  if (rejoin != null) {
    toolkitBuilder.setRejoin(rejoin);
  }
  toolkitBuilder.addTunnelledMBeanDomain("quartz");
  toolkit = (ToolkitInternal) toolkitBuilder.buildToolkit();

  try {
    realJobStore = getRealStore(toolkit);
  } catch (Exception e) {
    throw new SchedulerConfigException("Unable to create Terracotta client", e);
  }
}
项目:lams    文件:QuartzService.java   
@Override
public void createService() throws Exception {
    log.info("Create QuartzService(" + jndiName + ")...");

    if (error) {
        log
                .error("Must specify only one of 'Properties' or 'PropertiesFile'");

        throw new Exception(
                "Must specify only one of 'Properties' or 'PropertiesFile'");
    }

    schedulerFactory = new StdSchedulerFactory();

    try {
        if (useProperties) {
            schedulerFactory.initialize(properties);
        }

        if (usePropertiesFile) {
            schedulerFactory.initialize(propertiesFile);
        }
    } catch (Exception e) {
        log.error("Failed to initialize Scheduler", e);

        throw new SchedulerConfigException(
                "Failed to initialize Scheduler - ", e);
    }

    log.info("QuartzService(" + jndiName + ") created.");
}
项目:lams    文件:QuartzService.java   
@Override
public void startService() throws Exception {
    log.info("Start QuartzService(" + jndiName + ")...");

    try {
        rebind();
    } catch (NamingException ne) {
        log.error("Failed to rebind Scheduler", ne);

        throw new SchedulerConfigException("Failed to rebind Scheduler - ",
                ne);
    }

    try {
        Scheduler scheduler = schedulerFactory.getScheduler();

        if (startScheduler) {
            scheduler.start();
        } else {
            log.info("Skipping starting the scheduler (will not run jobs).");
        }
    } catch (Exception e) {
        log.error("Failed to start Scheduler", e);

        throw new SchedulerConfigException("Failed to start Scheduler - ",
                e);
    }

    log.info("QuartzService(" + jndiName + ") started.");
}
项目:lams    文件:JobStoreTX.java   
@Override
public void initialize(ClassLoadHelper classLoadHelper,
        SchedulerSignaler schedSignaler) throws SchedulerConfigException {

    super.initialize(classLoadHelper, schedSignaler);

    getLog().info("JobStoreTX initialized.");
}
项目:lams    文件:StdSchedulerFactory.java   
private Class<?> loadClass(String className) throws ClassNotFoundException, SchedulerConfigException {

        try {
            ClassLoader cl = findClassloader();
            if(cl != null)
                return cl.loadClass(className);
            throw new SchedulerConfigException("Unable to find a class loader on the current thread or class.");
        } catch (ClassNotFoundException e) {
            if(getClass().getClassLoader() != null)
                return getClass().getClassLoader().loadClass(className);
            throw e;
        }
    }
项目:asura    文件:StdSchedulerFactory.java   
private Class loadClass(String className) throws ClassNotFoundException, SchedulerConfigException {

        try {
            ClassLoader cl = findClassloader();
            if(cl != null)
                return cl.loadClass(className);
            throw new SchedulerConfigException("Unable to find a class loader on the current thread or class.");
        } catch (ClassNotFoundException e) {
            if(getClass().getClassLoader() != null)
                return getClass().getClassLoader().loadClass(className);
            throw e;
        }
    }
项目:spring4-understanding    文件:LocalTaskExecutorThreadPool.java   
@Override
public void initialize() throws SchedulerConfigException {
    // Absolutely needs thread-bound TaskExecutor to initialize.
    this.taskExecutor = SchedulerFactoryBean.getConfigTimeTaskExecutor();
    if (this.taskExecutor == null) {
        throw new SchedulerConfigException(
            "No local TaskExecutor found for configuration - " +
            "'taskExecutor' property must be set on SchedulerFactoryBean");
    }
}
项目:awplab-core    文件:ResizableThreadPool.java   
@Override
public void initialize() throws SchedulerConfigException {
    if (threadPoolExecutor == null) {
        threadPoolExecutor = (ThreadPoolExecutor) Executors.newFixedThreadPool(initialThreadPoolSize, new ResizableThreadPoolFactory());
    }

}
项目:nexus-public    文件:JobStoreImpl.java   
@Override
public void initialize(final ClassLoadHelper loadHelper, final SchedulerSignaler signaler)
    throws SchedulerConfigException
{
  log.info("Instance name: {}; ID: {}", instanceName, instanceId);

  // TODO: Should we consider using ClassLoadHelper?
  this.signaler = checkNotNull(signaler);

  log.info("Initialized");
}
项目:quartz-scheduler-hazelcast-jobstore    文件:HazelcastJobStore.java   
@Override
public void initialize(ClassLoadHelper loadHelper, SchedulerSignaler signaler)
  throws SchedulerConfigException {

  LOG.debug("Initializing Hazelcast Job Store..");

  this.schedSignaler = signaler;

  if (hazelcastClient == null) {
    LOG.warn("Starting new local hazelcast client since not hazelcast instance setted before starting scheduler.");
    hazelcastClient = Hazelcast.newHazelcastInstance();
  }

  // initializing hazelcast maps
  LOG.debug("Initializing hazelcast maps...");
  jobsByKey = getMap(HC_JOB_STORE_MAP_JOB);
  triggersByKey = getMap(HC_JOB_STORE_TRIGGER_BY_KEY_MAP);
  jobsByGroup = getMultiMap(HC_JOB_STORE_MAP_JOB_BY_GROUP_MAP);
  triggersByGroup = getMultiMap(HC_JOB_STORE_TRIGGER_KEY_BY_GROUP_MAP);
  pausedTriggerGroups = getSet(HC_JOB_STORE_PAUSED_TRIGGER_GROUPS);
  pausedJobGroups = getSet(HC_JOB_STORE_PAUSED_JOB_GROUPS);
  calendarsByName = getMap(HC_JOB_CALENDAR_MAP);

  triggersByKey.addIndex("nextFireTime", true);

  LOG.debug("Hazelcast Job Store Initialized.");
}
项目:openMAXIMS    文件:DocumentsConversionJobImpl.java   
private void convertDocuments(String pathToReadFile) throws JobExecutionException, FileNotFoundException, IOException, SchedulerConfigException 
{   
    for (int i = 0; i < cache.size(); i++) 
    {   
        convertDocument(cache.get(i), pathToReadFile);
    }
}
项目:class-guard    文件:LocalTaskExecutorThreadPool.java   
public void initialize() throws SchedulerConfigException {
    // Absolutely needs thread-bound TaskExecutor to initialize.
    this.taskExecutor = SchedulerFactoryBean.getConfigTimeTaskExecutor();
    if (this.taskExecutor == null) {
        throw new SchedulerConfigException(
            "No local TaskExecutor found for configuration - " +
            "'taskExecutor' property must be set on SchedulerFactoryBean");
    }
}
项目:quartz-hazelcast-jobstore    文件:HazelcastJobStore.java   
@Override
public void initialize(ClassLoadHelper loadHelper, SchedulerSignaler signaler)
    throws SchedulerConfigException {
  log.info("Initializing HazelcastJobStore..");

  final ClientConfig clientConfig = new ClientConfig();
  final ClientNetworkConfig networkConfig = clientConfig.getNetworkConfig();
  networkConfig.addAddress("127.0.0.1:5701");

  hazelcastClient = HazelcastClient.newHazelcastClient(clientConfig);

  // initializing hazelcast maps
  jobsByKey = hazelcastClient.getMap(HC_JOB_STORE_MAP_JOB);
  triggersByKey = hazelcastClient.getMap(HC_JOB_STORE_TRIGGER_BY_KEY_MAP);
  jobsByGroup = hazelcastClient
      .getMultiMap(HC_JOB_STORE_MAP_JOB_BY_GROUP_MAP);
  triggersByGroup = hazelcastClient
      .getMultiMap(HC_JOB_STORE_TRIGGER_KEY_BY_GROUP_MAP);
  pausedTriggerGroups = hazelcastClient
      .getSet(HC_JOB_STORE_PAUSED_TRIGGER_GROUPS);
  pausedJobGroups = hazelcastClient.getSet(HC_JOB_STORE_PAUSED_JOB_GROUPS);
  calendarsByName = hazelcastClient.getMap(HC_JOB_CALENDAR_MAP);

  this.schedSignaler = signaler;

  triggersByKey.addIndex("nextFireTime", true);
  log.info("HazelcastJobStore Initialized.");
}
项目:Runway-SDK    文件:SchedulerManager.java   
/**
 * Constructor to initialize the scheduler factory and default instance.
 */
private SchedulerManager()
{
  factory = new StdSchedulerFactory();

  try
  {
    scheduler = factory.getScheduler();
  }
  catch (SchedulerException e)
  {
    Throwable cause = e.getUnderlyingException();

    if (cause instanceof SchedulerConfigException)
    {
      SchedulerConfigException sceOriginal = (SchedulerConfigException) cause;

      ProgrammingErrorException sceWrapper = new ProgrammingErrorException(sceOriginal.getLocalizedMessage(), sceOriginal);

      throw sceWrapper;
    }
    else
    {
      throw new ProgrammingErrorException("Error occurred when initializing the Scheduler Manager.", e);
    }
  }

  faillAllRunning();

  initialized = true;
}
项目:lams    文件:LocalDataSourceJobStore.java   
@Override
public void initialize(ClassLoadHelper loadHelper, SchedulerSignaler signaler)
        throws SchedulerConfigException {

    // Absolutely needs thread-bound DataSource to initialize.
    this.dataSource = SchedulerFactoryBean.getConfigTimeDataSource();
    if (this.dataSource == null) {
        throw new SchedulerConfigException(
            "No local DataSource found for configuration - " +
            "'dataSource' property must be set on SchedulerFactoryBean");
    }

    // Configure transactional connection settings for Quartz.
    setDataSource(TX_DATA_SOURCE_PREFIX + getInstanceName());
    setDontSetAutoCommitFalse(true);

    // Register transactional ConnectionProvider for Quartz.
    DBConnectionManager.getInstance().addConnectionProvider(
            TX_DATA_SOURCE_PREFIX + getInstanceName(),
            new ConnectionProvider() {
                @Override
                public Connection getConnection() throws SQLException {
                    // Return a transactional Connection, if any.
                    return DataSourceUtils.doGetConnection(dataSource);
                }
                @Override
                public void shutdown() {
                    // Do nothing - a Spring-managed DataSource has its own lifecycle.
                }
                /* Quartz 2.2 initialize method */
                public void initialize() {
                    // Do nothing - a Spring-managed DataSource has its own lifecycle.
                }
            }
    );

    // Non-transactional DataSource is optional: fall back to default
    // DataSource if not explicitly specified.
    DataSource nonTxDataSource = SchedulerFactoryBean.getConfigTimeNonTransactionalDataSource();
    final DataSource nonTxDataSourceToUse = (nonTxDataSource != null ? nonTxDataSource : this.dataSource);

    // Configure non-transactional connection settings for Quartz.
    setNonManagedTXDataSource(NON_TX_DATA_SOURCE_PREFIX + getInstanceName());

    // Register non-transactional ConnectionProvider for Quartz.
    DBConnectionManager.getInstance().addConnectionProvider(
            NON_TX_DATA_SOURCE_PREFIX + getInstanceName(),
            new ConnectionProvider() {
                @Override
                public Connection getConnection() throws SQLException {
                    // Always return a non-transactional Connection.
                    return nonTxDataSourceToUse.getConnection();
                }
                @Override
                public void shutdown() {
                    // Do nothing - a Spring-managed DataSource has its own lifecycle.
                }
                /* Quartz 2.2 initialize method */
                public void initialize() {
                    // Do nothing - a Spring-managed DataSource has its own lifecycle.
                }
            }
    );

    // No, if HSQL is the platform, we really don't want to use locks...
    try {
        String productName = JdbcUtils.extractDatabaseMetaData(this.dataSource, "getDatabaseProductName").toString();
        productName = JdbcUtils.commonDatabaseName(productName);
        if (productName != null && productName.toLowerCase().contains("hsql")) {
            setUseDBLocks(false);
            setLockHandler(new SimpleSemaphore());
        }
    }
    catch (MetaDataAccessException ex) {
        logWarnIfNonZero(1, "Could not detect database type. Assuming locks can be taken.");
    }

    super.initialize(loadHelper, signaler);

}
项目:lams    文件:SimpleThreadPoolTaskExecutor.java   
@Override
public void afterPropertiesSet() throws SchedulerConfigException {
    initialize();
}
项目:lams    文件:SimpleThreadPool.java   
public void initialize() throws SchedulerConfigException {

        if(workers != null && workers.size() > 0) // already initialized...
            return;

        if (count <= 0) {
            throw new SchedulerConfigException(
                    "Thread count must be > 0");
        }
        if (prio <= 0 || prio > 9) {
            throw new SchedulerConfigException(
                    "Thread priority must be > 0 and <= 9");
        }

        if(isThreadsInheritGroupOfInitializingThread()) {
            threadGroup = Thread.currentThread().getThreadGroup();
        } else {
            // follow the threadGroup tree to the root thread group.
            threadGroup = Thread.currentThread().getThreadGroup();
            ThreadGroup parent = threadGroup;
            while ( !parent.getName().equals("main") ) {
                threadGroup = parent;
                parent = threadGroup.getParent();
            }
            threadGroup = new ThreadGroup(parent, schedulerInstanceName + "-SimpleThreadPool");
            if (isMakeThreadsDaemons()) {
                threadGroup.setDaemon(true);
            }
        }


        if (isThreadsInheritContextClassLoaderOfInitializingThread()) {
            getLog().info(
                    "Job execution threads will use class loader of thread: "
                            + Thread.currentThread().getName());
        }

        // create the worker threads and start them
        Iterator<WorkerThread> workerThreads = createWorkerThreads(count).iterator();
        while(workerThreads.hasNext()) {
            WorkerThread wt = workerThreads.next();
            wt.start();
            availWorkers.add(wt);
        }
    }
项目:lams    文件:ZeroSizeThreadPool.java   
public void initialize() throws SchedulerConfigException {
}
项目:lams    文件:SimpleTimeBroker.java   
public void initialize() throws SchedulerConfigException {
    // do nothing...
}
项目:lams    文件:JobStoreSupport.java   
/**
 * <p>
 * Called by the QuartzScheduler before the <code>JobStore</code> is
 * used, in order to give it a chance to initialize.
 * </p>
 */
public void initialize(ClassLoadHelper loadHelper,
        SchedulerSignaler signaler) throws SchedulerConfigException {

    if (dsName == null) { 
        throw new SchedulerConfigException("DataSource name not set."); 
    }

    classLoadHelper = loadHelper;
    if(isThreadsInheritInitializersClassLoadContext()) {
        log.info("JDBCJobStore threads will inherit ContextClassLoader of thread: " + Thread.currentThread().getName());
        initializersLoader = Thread.currentThread().getContextClassLoader();
    }

    this.schedSignaler = signaler;

    // If the user hasn't specified an explicit lock handler, then 
    // choose one based on CMT/Clustered/UseDBLocks.
    if (getLockHandler() == null) {

        // If the user hasn't specified an explicit lock handler, 
        // then we *must* use DB locks with clustering
        if (isClustered()) {
            setUseDBLocks(true);
        }

        if (getUseDBLocks()) {
            if(getDriverDelegateClass() != null && getDriverDelegateClass().equals(MSSQLDelegate.class.getName())) {
                if(getSelectWithLockSQL() == null) {
                    String msSqlDflt = "SELECT * FROM {0}LOCKS WITH (UPDLOCK,ROWLOCK) WHERE " + COL_SCHEDULER_NAME + " = {1} AND LOCK_NAME = ?";
                    getLog().info("Detected usage of MSSQLDelegate class - defaulting 'selectWithLockSQL' to '" + msSqlDflt + "'.");
                    setSelectWithLockSQL(msSqlDflt);
                }
            }
            getLog().info("Using db table-based data access locking (synchronization).");
            setLockHandler(new StdRowLockSemaphore(getTablePrefix(), getInstanceName(), getSelectWithLockSQL()));
        } else {
            getLog().info(
                "Using thread monitor-based data access locking (synchronization).");
            setLockHandler(new SimpleSemaphore());
        }
    }

}
项目:asura    文件:SimpleThreadPool.java   
public void initialize() throws SchedulerConfigException {

        if(workers != null && workers.size() > 0) // already initialized...
            return;

        if (count <= 0) {
            throw new SchedulerConfigException(
                    "Thread count must be > 0");
        }
        if (prio <= 0 || prio > 9) {
            throw new SchedulerConfigException(
                    "Thread priority must be > 0 and <= 9");
        }

        if(isThreadsInheritGroupOfInitializingThread()) {
            threadGroup = Thread.currentThread().getThreadGroup();
        } else {
            // follow the threadGroup tree to the root thread group.
            threadGroup = Thread.currentThread().getThreadGroup();
            ThreadGroup parent = threadGroup;
            while ( !parent.getName().equals("main") ) {
                threadGroup = parent;
                parent = threadGroup.getParent();
            }
            threadGroup = new ThreadGroup(parent, schedulerInstanceName + "-SimpleThreadPool");
            if (isMakeThreadsDaemons()) {
                threadGroup.setDaemon(true);
            }
        }


        if (isThreadsInheritContextClassLoaderOfInitializingThread()) {
            getLog().info(
                    "Job execution threads will use class loader of thread: "
                            + Thread.currentThread().getName());
        }

        // create the worker threads and start them
        Iterator workerThreads = createWorkerThreads(count).iterator();
        while(workerThreads.hasNext()) {
            WorkerThread wt = (WorkerThread) workerThreads.next();
            wt.start();
            availWorkers.add(wt);
        }
    }
项目:asura    文件:ZeroSizeThreadPool.java   
public void initialize() throws SchedulerConfigException {
}
项目:asura    文件:SimpleTimeBroker.java   
public void initialize() throws SchedulerConfigException {
    // do nothing...
}
项目:asura    文件:JobStoreSupport.java   
/**
 * <p>
 * Called by the QuartzScheduler before the <code>JobStore</code> is
 * used, in order to give it a chance to initialize.
 * </p>
 */
public void initialize(ClassLoadHelper loadHelper,
        SchedulerSignaler signaler) throws SchedulerConfigException {

    if (dsName == null) { 
        throw new SchedulerConfigException("DataSource name not set."); 
    }

    classLoadHelper = loadHelper;
    if(isThreadsInheritInitializersClassLoadContext()) {
        log.info("JDBCJobStore threads will inherit ContextClassLoader of thread: " + Thread.currentThread().getName());
        initializersLoader = Thread.currentThread().getContextClassLoader();
    }

    this.schedSignaler = signaler;

    // If the user hasn't specified an explicit lock handler, then 
    // choose one based on CMT/Clustered/UseDBLocks.
    if (getLockHandler() == null) {

        // If the user hasn't specified an explicit lock handler, 
        // then we *must* use DB locks with clustering
        if (isClustered()) {
            setUseDBLocks(true);
        }

        if (getUseDBLocks()) {
            if(getDriverDelegateClass() != null && getDriverDelegateClass().equals(MSSQLDelegate.class.getName())) {
                if(getSelectWithLockSQL() == null) {
                    String msSqlDflt = "SELECT * FROM {0}LOCKS UPDLOCK WHERE LOCK_NAME = ?";
                    getLog().info("Detected usage of MSSQLDelegate class - defaulting 'selectWithLockSQL' to '" + msSqlDflt + "'.");
                    setSelectWithLockSQL(msSqlDflt);
                }
            }
            getLog().info("Using db table-based data access locking (synchronization).");
            setLockHandler(new StdRowLockSemaphore(getTablePrefix(), getSelectWithLockSQL()));
        } else {
            getLog().info(
                "Using thread monitor-based data access locking (synchronization).");
            setLockHandler(new SimpleSemaphore());
        }
    }

    if (!isClustered()) {
        try {
            cleanVolatileTriggerAndJobs();
        } catch (SchedulerException se) {
            throw new SchedulerConfigException(
                    "Failure occured during job recovery.", se);
        }
    }
}
项目:spring4-understanding    文件:LocalDataSourceJobStore.java   
@Override
public void initialize(ClassLoadHelper loadHelper, SchedulerSignaler signaler)
        throws SchedulerConfigException {

    // Absolutely needs thread-bound DataSource to initialize.
    this.dataSource = SchedulerFactoryBean.getConfigTimeDataSource();
    if (this.dataSource == null) {
        throw new SchedulerConfigException(
            "No local DataSource found for configuration - " +
            "'dataSource' property must be set on SchedulerFactoryBean");
    }

    // Configure transactional connection settings for Quartz.
    setDataSource(TX_DATA_SOURCE_PREFIX + getInstanceName());
    setDontSetAutoCommitFalse(true);

    // Register transactional ConnectionProvider for Quartz.
    DBConnectionManager.getInstance().addConnectionProvider(
            TX_DATA_SOURCE_PREFIX + getInstanceName(),
            new ConnectionProvider() {
                @Override
                public Connection getConnection() throws SQLException {
                    // Return a transactional Connection, if any.
                    return DataSourceUtils.doGetConnection(dataSource);
                }
                @Override
                public void shutdown() {
                    // Do nothing - a Spring-managed DataSource has its own lifecycle.
                }
                /* Quartz 2.2 initialize method */
                public void initialize() {
                    // Do nothing - a Spring-managed DataSource has its own lifecycle.
                }
            }
    );

    // Non-transactional DataSource is optional: fall back to default
    // DataSource if not explicitly specified.
    DataSource nonTxDataSource = SchedulerFactoryBean.getConfigTimeNonTransactionalDataSource();
    final DataSource nonTxDataSourceToUse = (nonTxDataSource != null ? nonTxDataSource : this.dataSource);

    // Configure non-transactional connection settings for Quartz.
    setNonManagedTXDataSource(NON_TX_DATA_SOURCE_PREFIX + getInstanceName());

    // Register non-transactional ConnectionProvider for Quartz.
    DBConnectionManager.getInstance().addConnectionProvider(
            NON_TX_DATA_SOURCE_PREFIX + getInstanceName(),
            new ConnectionProvider() {
                @Override
                public Connection getConnection() throws SQLException {
                    // Always return a non-transactional Connection.
                    return nonTxDataSourceToUse.getConnection();
                }
                @Override
                public void shutdown() {
                    // Do nothing - a Spring-managed DataSource has its own lifecycle.
                }
                /* Quartz 2.2 initialize method */
                public void initialize() {
                    // Do nothing - a Spring-managed DataSource has its own lifecycle.
                }
            }
    );

    // No, if HSQL is the platform, we really don't want to use locks...
    try {
        String productName = JdbcUtils.extractDatabaseMetaData(this.dataSource, "getDatabaseProductName").toString();
        productName = JdbcUtils.commonDatabaseName(productName);
        if (productName != null && productName.toLowerCase().contains("hsql")) {
            setUseDBLocks(false);
            setLockHandler(new SimpleSemaphore());
        }
    }
    catch (MetaDataAccessException ex) {
        logWarnIfNonZero(1, "Could not detect database type. Assuming locks can be taken.");
    }

    super.initialize(loadHelper, signaler);

}
项目:spring4-understanding    文件:SimpleThreadPoolTaskExecutor.java   
@Override
public void afterPropertiesSet() throws SchedulerConfigException {
    initialize();
}
项目:awplab-core    文件:IPOJOJobRunShellFactory.java   
@Override
public void initialize(Scheduler scheduler) throws SchedulerConfigException {
    this.scheduler = scheduler;
}