Example usage for org.springframework.core.io ClassPathResource isReadable

List of usage examples for org.springframework.core.io ClassPathResource isReadable

Introduction

In this page you can find the example usage for org.springframework.core.io ClassPathResource isReadable.

Prototype

@Override
    public boolean isReadable() 

Source Link

Usage

From source file:chronos.mbeans.QuartzSchedulerAdapter.java

/**
 * @param factory//ww  w .j ava  2 s. co m
 *        {@link StdSchedulerFactory}
 * @throws SchedulerException
 *         on exception
 */
private void createOwnScheduler(final StdSchedulerFactory factory) throws SchedulerException {
    logger.debug("Creating new Quartz scheduler...");
    final ClassPathResource resource = new ClassPathResource("quartz.properties");
    if (resource.exists() && resource.isReadable()) {
        logger.debug("Configuring Quartz from resource: " + resource.getPath());
        try {
            final InputStream is = resource.getInputStream();
            try {
                factory.initialize(is);
            } finally {
                is.close();
            }
        } catch (final IOException e) {
            logger.debug("Exception initializing from resource: " + e.getMessage(), e);
        }
    } else {
        logger.debug("Using minimal default properties");
        final Properties props = new Properties();
        props.put(PROP_SCHED_INSTANCE_NAME, schedulerInstanceName);
        props.put(PROP_THREAD_POOL_CLASS, SimpleThreadPool.class.getName());
        factory.initialize(props);
    }
}