Skip to content

Commit c7f60d1

Browse files
committed
SchedulerFactoryBean always ignores local factory settings in case of an external SchedulerFactory instance (expecting it to be fully initialized)
This commit includes various javadoc fixes and related refinements. Issue: SPR-16439
1 parent 6d909b0 commit c7f60d1

File tree

4 files changed

+80
-87
lines changed

4 files changed

+80
-87
lines changed

spring-context-support/src/main/java/org/springframework/scheduling/quartz/AdaptableJobFactory.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -25,7 +25,7 @@
2525
import org.springframework.util.ReflectionUtils;
2626

2727
/**
28-
* JobFactory implementation that supports {@link java.lang.Runnable}
28+
* {@link JobFactory} implementation that supports {@link java.lang.Runnable}
2929
* objects as well as standard Quartz {@link org.quartz.Job} instances.
3030
*
3131
* <p>Compatible with Quartz 2.1.4 and higher, as of Spring 4.1.
@@ -43,7 +43,7 @@ public Job newJob(TriggerFiredBundle bundle, Scheduler scheduler) throws Schedul
4343
Object jobObject = createJobInstance(bundle);
4444
return adaptJob(jobObject);
4545
}
46-
catch (Exception ex) {
46+
catch (Throwable ex) {
4747
throw new SchedulerException("Job instantiation failed", ex);
4848
}
4949
}
@@ -78,7 +78,8 @@ else if (jobObject instanceof Runnable) {
7878
return new DelegatingJob((Runnable) jobObject);
7979
}
8080
else {
81-
throw new IllegalArgumentException("Unable to execute job class [" + jobObject.getClass().getName() +
81+
throw new IllegalArgumentException(
82+
"Unable to execute job class [" + jobObject.getClass().getName() +
8283
"]: only [org.quartz.Job] and [java.lang.Runnable] supported.");
8384
}
8485
}

spring-context-support/src/main/java/org/springframework/scheduling/quartz/LocalDataSourceJobStore.java

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2017 the original author or authors.
2+
* Copyright 2002-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -34,9 +34,9 @@
3434
import org.springframework.lang.Nullable;
3535

3636
/**
37-
* Subclass of Quartz's JobStoreCMT class that delegates to a Spring-managed
38-
* DataSource instead of using a Quartz-managed connection pool. This JobStore
39-
* will be used if SchedulerFactoryBean's "dataSource" property is set.
37+
* Subclass of Quartz's {@link JobStoreCMT} class that delegates to a Spring-managed
38+
* {@link DataSource} instead of using a Quartz-managed JDBC connection pool.
39+
* This JobStore will be used if SchedulerFactoryBean's "dataSource" property is set.
4040
*
4141
* <p>Supports both transactional and non-transactional DataSource access.
4242
* With a non-XA DataSource and local Spring transactions, a single DataSource
@@ -84,15 +84,12 @@ public class LocalDataSourceJobStore extends JobStoreCMT {
8484

8585

8686
@Override
87-
public void initialize(ClassLoadHelper loadHelper, SchedulerSignaler signaler)
88-
throws SchedulerConfigException {
89-
87+
public void initialize(ClassLoadHelper loadHelper, SchedulerSignaler signaler) throws SchedulerConfigException {
9088
// Absolutely needs thread-bound DataSource to initialize.
9189
this.dataSource = SchedulerFactoryBean.getConfigTimeDataSource();
9290
if (this.dataSource == null) {
93-
throw new SchedulerConfigException(
94-
"No local DataSource found for configuration - " +
95-
"'dataSource' property must be set on SchedulerFactoryBean");
91+
throw new SchedulerConfigException("No local DataSource found for configuration - " +
92+
"'dataSource' property must be set on SchedulerFactoryBean");
9693
}
9794

9895
// Configure transactional connection settings for Quartz.

spring-context-support/src/main/java/org/springframework/scheduling/quartz/LocalTaskExecutorThreadPool.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2017 the original author or authors.
2+
* Copyright 2002-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -28,8 +28,8 @@
2828
import org.springframework.util.Assert;
2929

3030
/**
31-
* Quartz ThreadPool adapter that delegates to a Spring-managed
32-
* TaskExecutor instance, specified on SchedulerFactoryBean.
31+
* Quartz {@link ThreadPool} adapter that delegates to a Spring-managed
32+
* {@link Executor} instance, specified on {@link SchedulerFactoryBean}.
3333
*
3434
* @author Juergen Hoeller
3535
* @since 2.0
@@ -55,12 +55,11 @@ public void setInstanceName(String schedName) {
5555

5656
@Override
5757
public void initialize() throws SchedulerConfigException {
58-
// Absolutely needs thread-bound TaskExecutor to initialize.
58+
// Absolutely needs thread-bound Executor to initialize.
5959
this.taskExecutor = SchedulerFactoryBean.getConfigTimeTaskExecutor();
6060
if (this.taskExecutor == null) {
61-
throw new SchedulerConfigException(
62-
"No local TaskExecutor found for configuration - " +
63-
"'taskExecutor' property must be set on SchedulerFactoryBean");
61+
throw new SchedulerConfigException("No local Executor found for configuration - " +
62+
"'taskExecutor' property must be set on SchedulerFactoryBean");
6463
}
6564
}
6665

0 commit comments

Comments
 (0)