Polishing
This commit is contained in:
@@ -160,7 +160,7 @@ public abstract class AbstractFactoryBean<T>
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine an 'eager singleton' instance, exposed in case of a
|
||||
* Determine an 'early singleton' instance, exposed in case of a
|
||||
* circular reference. Not called in a non-circular scenario.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
|
||||
@@ -90,8 +90,14 @@ import org.springframework.util.CollectionUtils;
|
||||
public class SchedulerFactoryBean extends SchedulerAccessor implements FactoryBean<Scheduler>,
|
||||
BeanNameAware, ApplicationContextAware, InitializingBean, DisposableBean, SmartLifecycle {
|
||||
|
||||
/**
|
||||
* The thread count property.
|
||||
*/
|
||||
public static final String PROP_THREAD_COUNT = "org.quartz.threadPool.threadCount";
|
||||
|
||||
/**
|
||||
* The default thread count.
|
||||
*/
|
||||
public static final int DEFAULT_THREAD_COUNT = 10;
|
||||
|
||||
|
||||
@@ -184,7 +190,7 @@ public class SchedulerFactoryBean extends SchedulerAccessor implements FactoryBe
|
||||
private DataSource nonTransactionalDataSource;
|
||||
|
||||
@Nullable
|
||||
private Map<String, ?> schedulerContextMap;
|
||||
private Map<String, ?> schedulerContextMap;
|
||||
|
||||
@Nullable
|
||||
private ApplicationContext applicationContext;
|
||||
@@ -340,7 +346,7 @@ public class SchedulerFactoryBean extends SchedulerAccessor implements FactoryBe
|
||||
* <p>Note: When using persistent Jobs whose JobDetail will be kept in the
|
||||
* database, do not put Spring-managed beans or an ApplicationContext
|
||||
* reference into the JobDataMap but rather into the SchedulerContext.
|
||||
* @param schedulerContextAsMap Map with String keys and any objects as
|
||||
* @param schedulerContextAsMap a Map with String keys and any objects as
|
||||
* values (for example Spring-managed beans)
|
||||
* @see JobDetailFactoryBean#setJobDataAsMap
|
||||
*/
|
||||
@@ -711,7 +717,7 @@ public class SchedulerFactoryBean extends SchedulerAccessor implements FactoryBe
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
Thread.sleep(TimeUnit.SECONDS.toMillis(startupDelay));
|
||||
TimeUnit.SECONDS.sleep(startupDelay);
|
||||
}
|
||||
catch (InterruptedException ex) {
|
||||
Thread.currentThread().interrupt();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -42,8 +42,14 @@ import org.springframework.lang.Nullable;
|
||||
*/
|
||||
public class DatabaseStartupValidator implements InitializingBean {
|
||||
|
||||
/**
|
||||
* The default interval.
|
||||
*/
|
||||
public static final int DEFAULT_INTERVAL = 1;
|
||||
|
||||
/**
|
||||
* The default timeout.
|
||||
*/
|
||||
public static final int DEFAULT_TIMEOUT = 60;
|
||||
|
||||
|
||||
@@ -98,8 +104,7 @@ public class DatabaseStartupValidator implements InitializingBean {
|
||||
*/
|
||||
@Override
|
||||
public void afterPropertiesSet() {
|
||||
DataSource dataSource = this.dataSource;
|
||||
if (dataSource == null) {
|
||||
if (this.dataSource == null) {
|
||||
throw new IllegalArgumentException("Property 'dataSource' is required");
|
||||
}
|
||||
if (this.validationQuery == null) {
|
||||
@@ -116,10 +121,10 @@ public class DatabaseStartupValidator implements InitializingBean {
|
||||
Connection con = null;
|
||||
Statement stmt = null;
|
||||
try {
|
||||
con = dataSource.getConnection();
|
||||
con = this.dataSource.getConnection();
|
||||
if (con == null) {
|
||||
throw new CannotGetJdbcConnectionException("Failed to execute validation query: " +
|
||||
"DataSource returned null from getConnection(): " + dataSource);
|
||||
"DataSource returned null from getConnection(): " + this.dataSource);
|
||||
}
|
||||
stmt = con.createStatement();
|
||||
stmt.execute(this.validationQuery);
|
||||
@@ -144,7 +149,7 @@ public class DatabaseStartupValidator implements InitializingBean {
|
||||
}
|
||||
|
||||
if (!validated) {
|
||||
Thread.sleep(TimeUnit.SECONDS.toMillis(this.interval));
|
||||
TimeUnit.SECONDS.sleep(this.interval);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8396,12 +8396,12 @@ simple class that extends Spring's `ApplicationEvent` base class:
|
||||
public class BlackListEvent extends ApplicationEvent {
|
||||
|
||||
private final String address;
|
||||
private final String test;
|
||||
private final String content;
|
||||
|
||||
public BlackListEvent(Object source, String address, String test) {
|
||||
public BlackListEvent(Object source, String address, String content) {
|
||||
super(source);
|
||||
this.address = address;
|
||||
this.test = test;
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
// accessor and other methods...
|
||||
@@ -8429,10 +8429,9 @@ example demonstrates such a class:
|
||||
this.publisher = publisher;
|
||||
}
|
||||
|
||||
public void sendEmail(String address, String text) {
|
||||
public void sendEmail(String address, String content) {
|
||||
if (blackList.contains(address)) {
|
||||
BlackListEvent event = new BlackListEvent(this, address, text);
|
||||
publisher.publishEvent(event);
|
||||
publisher.publishEvent(new BlackListEvent(this, address, content));
|
||||
return;
|
||||
}
|
||||
// send email...
|
||||
|
||||
Reference in New Issue
Block a user