Merge branch '1.0.x'
Conflicts: spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/CrshAutoConfiguration.java spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceAutoConfiguration.java
This commit is contained in:
commit
938609fdc0
|
|
@ -18,7 +18,6 @@ package org.springframework.boot.actuate.autoconfigure;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.net.URISyntaxException;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
@ -215,7 +214,7 @@ public class CrshAutoConfiguration {
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
public void init() throws Exception {
|
public void init() {
|
||||||
FS commandFileSystem = createFileSystem(
|
FS commandFileSystem = createFileSystem(
|
||||||
this.properties.getCommandPathPatterns(),
|
this.properties.getCommandPathPatterns(),
|
||||||
this.properties.getDisabledCommands());
|
this.properties.getDisabledCommands());
|
||||||
|
|
@ -234,8 +233,7 @@ public class CrshAutoConfiguration {
|
||||||
start(context);
|
start(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected FS createFileSystem(String[] pathPatterns, String[] filterPatterns)
|
protected FS createFileSystem(String[] pathPatterns, String[] filterPatterns) {
|
||||||
throws IOException, URISyntaxException {
|
|
||||||
Assert.notNull(pathPatterns, "PathPatterns must not be null");
|
Assert.notNull(pathPatterns, "PathPatterns must not be null");
|
||||||
Assert.notNull(filterPatterns, "FilterPatterns must not be null");
|
Assert.notNull(filterPatterns, "FilterPatterns must not be null");
|
||||||
FS fileSystem = new FS();
|
FS fileSystem = new FS();
|
||||||
|
|
|
||||||
|
|
@ -87,10 +87,15 @@ public class BasicBatchConfigurer implements BatchConfigurer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
public void initialize() throws Exception {
|
public void initialize() {
|
||||||
this.transactionManager = createTransactionManager();
|
try {
|
||||||
this.jobRepository = createJobRepository();
|
this.transactionManager = createTransactionManager();
|
||||||
this.jobLauncher = createJobLauncher();
|
this.jobRepository = createJobRepository();
|
||||||
|
this.jobLauncher = createJobLauncher();
|
||||||
|
}
|
||||||
|
catch (Exception ex) {
|
||||||
|
throw new IllegalStateException("Unable to initialize Spring Batch", ex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private JobLauncher createJobLauncher() throws Exception {
|
private JobLauncher createJobLauncher() throws Exception {
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ import org.springframework.core.env.Environment;
|
||||||
import org.springframework.core.io.ResourceLoader;
|
import org.springframework.core.io.ResourceLoader;
|
||||||
import org.springframework.jdbc.datasource.init.DatabasePopulatorUtils;
|
import org.springframework.jdbc.datasource.init.DatabasePopulatorUtils;
|
||||||
import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator;
|
import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator;
|
||||||
|
import org.springframework.jdbc.support.MetaDataAccessException;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -58,10 +59,9 @@ public class BatchDatabaseInitializer implements EnvironmentAware {
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
protected void initialize() throws Exception {
|
protected void initialize() {
|
||||||
if (this.enabled) {
|
if (this.enabled) {
|
||||||
String platform = DatabaseType.fromMetaData(this.dataSource).toString()
|
String platform = getDatabaseType();
|
||||||
.toLowerCase();
|
|
||||||
if ("hsql".equals(platform)) {
|
if ("hsql".equals(platform)) {
|
||||||
platform = "hsqldb";
|
platform = "hsqldb";
|
||||||
}
|
}
|
||||||
|
|
@ -78,4 +78,13 @@ public class BatchDatabaseInitializer implements EnvironmentAware {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getDatabaseType() {
|
||||||
|
try {
|
||||||
|
return DatabaseType.fromMetaData(this.dataSource).toString().toLowerCase();
|
||||||
|
}
|
||||||
|
catch (MetaDataAccessException ex) {
|
||||||
|
throw new IllegalStateException("Unable to detect database type", ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
package org.springframework.boot.autoconfigure.jdbc;
|
package org.springframework.boot.autoconfigure.jdbc;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -80,7 +81,7 @@ public class DataSourceAutoConfiguration {
|
||||||
private DataSourceProperties properties;
|
private DataSourceProperties properties;
|
||||||
|
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
protected void initialize() throws Exception {
|
protected void initialize() {
|
||||||
boolean initialize = this.properties.isInitialize();
|
boolean initialize = this.properties.isInitialize();
|
||||||
if (this.dataSource == null || !initialize) {
|
if (this.dataSource == null || !initialize) {
|
||||||
logger.debug("No DataSource found so not initializing");
|
logger.debug("No DataSource found so not initializing");
|
||||||
|
|
@ -96,11 +97,7 @@ public class DataSourceAutoConfiguration {
|
||||||
schema += "classpath*:data.sql";
|
schema += "classpath*:data.sql";
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Resource> resources = new ArrayList<Resource>();
|
List<Resource> resources = getSchemaResources(schema);
|
||||||
for (String schemaLocation : StringUtils.commaDelimitedListToStringArray(schema)) {
|
|
||||||
resources.addAll(Arrays.asList(this.applicationContext
|
|
||||||
.getResources(schemaLocation)));
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean continueOnError = this.properties.isContinueOnError();
|
boolean continueOnError = this.properties.isContinueOnError();
|
||||||
boolean exists = false;
|
boolean exists = false;
|
||||||
|
|
@ -119,6 +116,21 @@ public class DataSourceAutoConfiguration {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<Resource> getSchemaResources(String schema) {
|
||||||
|
List<Resource> resources = new ArrayList<Resource>();
|
||||||
|
for (String schemaLocation : StringUtils.commaDelimitedListToStringArray(schema)) {
|
||||||
|
try {
|
||||||
|
resources.addAll(Arrays.asList(this.applicationContext
|
||||||
|
.getResources(schemaLocation)));
|
||||||
|
}
|
||||||
|
catch (IOException ex) {
|
||||||
|
throw new IllegalStateException("Unable to load resource from "
|
||||||
|
+ schemaLocation, ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return resources;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines if the {@code dataSource} being used by Spring was created from
|
* Determines if the {@code dataSource} being used by Spring was created from
|
||||||
* {@link EmbeddedDataSourceConfiguration}.
|
* {@link EmbeddedDataSourceConfiguration}.
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ import com.mongodb.MongoClientOptions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link EnableAutoConfiguration Auto-configuration} for Mongo.
|
* {@link EnableAutoConfiguration Auto-configuration} for Mongo.
|
||||||
*
|
*
|
||||||
* @author Dave Syer
|
* @author Dave Syer
|
||||||
* @author Oliver Gierke
|
* @author Oliver Gierke
|
||||||
* @author Phillip Webb
|
* @author Phillip Webb
|
||||||
|
|
@ -52,7 +52,7 @@ public class MongoAutoConfiguration {
|
||||||
private Mongo mongo;
|
private Mongo mongo;
|
||||||
|
|
||||||
@PreDestroy
|
@PreDestroy
|
||||||
public void close() throws UnknownHostException {
|
public void close() {
|
||||||
if (this.mongo != null) {
|
if (this.mongo != null) {
|
||||||
this.mongo.close();
|
this.mongo.close();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue