org.springframework.boot.autoconfigure.quartz.SchedulerFactoryBeanCustomizer Java Examples

The following examples show how to use org.springframework.boot.autoconfigure.quartz.SchedulerFactoryBeanCustomizer. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ApiBootQuartzAutoConfiguration.java    From beihu-boot with Apache License 2.0 5 votes vote down vote up
public ApiBootQuartzAutoConfiguration(ApiBootQuartzProperties properties, ObjectProvider<SchedulerFactoryBeanCustomizer> customizers, JobDetail[] jobDetails, Map<String, Calendar> calendars, Trigger[] triggers, ApplicationContext applicationContext) {
    this.properties = properties;
    this.customizers = customizers;
    this.jobDetails = jobDetails;
    this.calendars = calendars;
    this.triggers = triggers;
    this.applicationContext = applicationContext;
}
 
Example #2
Source File: ApiBootQuartzAutoConfiguration.java    From beihu-boot with Apache License 2.0 5 votes vote down vote up
/**
 * properties needed to initialize Jdbc mode
 *
 * @param properties ApiBoot Quartz Properties
 * @return SchedulerFactoryBeanCustomizer
 */
@Bean
@Order(0)
public SchedulerFactoryBeanCustomizer jobPropertiesCustomizer(ApiBootQuartzProperties properties) {
    return schedulerFactoryBean -> {
        // jdbc away
        if (properties.getJobStoreType() == JobStoreType.JDBC) {

            ApiBootQuartzProperties.Prop prop = properties.getProp();
            // get prop class declared fields
            Field[] fields = prop.getClass().getDeclaredFields();
            Arrays.stream(fields).forEach(field -> {
                try {
                    field.setAccessible(true);
                    String value = String.valueOf(field.get(prop));
                    PropKey propKey = field.getDeclaredAnnotation(PropKey.class);

                    // put prop to quartz properties
                    properties.getProperties().put(propKey.value(), value);
                } catch (IllegalAccessException e) {
                    e.printStackTrace();
                }

            });
        }
    };
}
 
Example #3
Source File: ApiBootQuartzAutoConfiguration.java    From beihu-boot with Apache License 2.0 5 votes vote down vote up
@Bean
@Order(1)
public SchedulerFactoryBeanCustomizer jobDataSourceCustomizer(ApiBootQuartzProperties properties, DataSource dataSource, @QuartzDataSource ObjectProvider<DataSource> quartzDataSource, ObjectProvider<PlatformTransactionManager> transactionManager) {
    return (schedulerFactoryBean) -> {
        if (properties.getJobStoreType() == JobStoreType.JDBC) {
            DataSource dataSourceToUse = this.getDataSource(dataSource, quartzDataSource);
            schedulerFactoryBean.setDataSource(dataSourceToUse);
            PlatformTransactionManager txManager = transactionManager.getIfUnique();
            if (txManager != null) {
                schedulerFactoryBean.setTransactionManager(txManager);
            }
        }

    };
}
 
Example #4
Source File: ApiBootQuartzAutoConfiguration.java    From api-boot with Apache License 2.0 5 votes vote down vote up
public ApiBootQuartzAutoConfiguration(ApiBootQuartzProperties properties, ObjectProvider<SchedulerFactoryBeanCustomizer> customizers, JobDetail[] jobDetails, Map<String, Calendar> calendars, Trigger[] triggers, ApplicationContext applicationContext) {
    this.properties = properties;
    this.customizers = customizers;
    this.jobDetails = jobDetails;
    this.calendars = calendars;
    this.triggers = triggers;
    this.applicationContext = applicationContext;
}
 
Example #5
Source File: ApiBootQuartzAutoConfiguration.java    From api-boot with Apache License 2.0 5 votes vote down vote up
/**
 * properties needed to initialize Jdbc mode
 *
 * @param properties ApiBoot Quartz Properties
 * @return SchedulerFactoryBeanCustomizer
 */
@Bean
@Order(0)
public SchedulerFactoryBeanCustomizer jobPropertiesCustomizer(ApiBootQuartzProperties properties) {
    return schedulerFactoryBean -> {
        // jdbc away
        if (properties.getJobStoreType() == JobStoreType.JDBC) {

            ApiBootQuartzProperties.Prop prop = properties.getProp();
            // get prop class declared fields
            Field[] fields = prop.getClass().getDeclaredFields();
            Arrays.stream(fields).forEach(field -> {
                try {
                    field.setAccessible(true);
                    String value = String.valueOf(field.get(prop));
                    PropKey propKey = field.getDeclaredAnnotation(PropKey.class);

                    // put prop to quartz properties
                    properties.getProperties().put(propKey.value(), value);
                } catch (IllegalAccessException e) {
                    e.printStackTrace();
                }

            });
        }
    };
}
 
Example #6
Source File: ApiBootQuartzAutoConfiguration.java    From api-boot with Apache License 2.0 5 votes vote down vote up
@Bean
@Order(1)
public SchedulerFactoryBeanCustomizer jobDataSourceCustomizer(ApiBootQuartzProperties properties, DataSource dataSource, @QuartzDataSource ObjectProvider<DataSource> quartzDataSource, ObjectProvider<PlatformTransactionManager> transactionManager) {
    return (schedulerFactoryBean) -> {
        if (properties.getJobStoreType() == JobStoreType.JDBC) {
            DataSource dataSourceToUse = this.getDataSource(dataSource, quartzDataSource);
            schedulerFactoryBean.setDataSource(dataSourceToUse);
            PlatformTransactionManager txManager = transactionManager.getIfUnique();
            if (txManager != null) {
                schedulerFactoryBean.setTransactionManager(txManager);
            }
        }

    };
}
 
Example #7
Source File: SchedulerFactoryConfig.java    From cloudbreak with Apache License 2.0 4 votes vote down vote up
@Bean
public SchedulerFactoryBeanCustomizer schedulerFactoryBeanCustomizer() {
    return bean -> {
        bean.setAutoStartup(properties.isAutoSyncEnabled());
    };
}