Merge branch '1.5.x'
This commit is contained in:
@@ -42,7 +42,8 @@ public abstract class AbstractDatabaseInitializer {
|
||||
|
||||
private final ResourceLoader resourceLoader;
|
||||
|
||||
protected AbstractDatabaseInitializer(DataSource dataSource, ResourceLoader resourceLoader) {
|
||||
protected AbstractDatabaseInitializer(DataSource dataSource,
|
||||
ResourceLoader resourceLoader) {
|
||||
Assert.notNull(dataSource, "DataSource must not be null");
|
||||
Assert.notNull(resourceLoader, "ResourceLoader must not be null");
|
||||
this.dataSource = dataSource;
|
||||
@@ -51,17 +52,18 @@ public abstract class AbstractDatabaseInitializer {
|
||||
|
||||
@PostConstruct
|
||||
protected void initialize() {
|
||||
if (isEnabled()) {
|
||||
ResourceDatabasePopulator populator = new ResourceDatabasePopulator();
|
||||
String schemaLocation = getSchemaLocation();
|
||||
if (schemaLocation.contains(PLATFORM_PLACEHOLDER)) {
|
||||
String platform = getDatabaseName();
|
||||
schemaLocation = schemaLocation.replace(PLATFORM_PLACEHOLDER, platform);
|
||||
}
|
||||
populator.addScript(this.resourceLoader.getResource(schemaLocation));
|
||||
populator.setContinueOnError(true);
|
||||
DatabasePopulatorUtils.execute(populator, this.dataSource);
|
||||
if (!isEnabled()) {
|
||||
return;
|
||||
}
|
||||
ResourceDatabasePopulator populator = new ResourceDatabasePopulator();
|
||||
String schemaLocation = getSchemaLocation();
|
||||
if (schemaLocation.contains(PLATFORM_PLACEHOLDER)) {
|
||||
String platform = getDatabaseName();
|
||||
schemaLocation = schemaLocation.replace(PLATFORM_PLACEHOLDER, platform);
|
||||
}
|
||||
populator.addScript(this.resourceLoader.getResource(schemaLocation));
|
||||
populator.setContinueOnError(true);
|
||||
DatabasePopulatorUtils.execute(populator, this.dataSource);
|
||||
}
|
||||
|
||||
protected abstract boolean isEnabled();
|
||||
@@ -70,11 +72,10 @@ public abstract class AbstractDatabaseInitializer {
|
||||
|
||||
protected String getDatabaseName() {
|
||||
try {
|
||||
String databaseProductName = JdbcUtils.extractDatabaseMetaData(
|
||||
this.dataSource, "getDatabaseProductName").toString();
|
||||
databaseProductName = JdbcUtils.commonDatabaseName(databaseProductName);
|
||||
DatabaseDriver databaseDriver = DatabaseDriver.fromProductName(
|
||||
databaseProductName);
|
||||
String productName = JdbcUtils.commonDatabaseName(JdbcUtils
|
||||
.extractDatabaseMetaData(this.dataSource, "getDatabaseProductName")
|
||||
.toString());
|
||||
DatabaseDriver databaseDriver = DatabaseDriver.fromProductName(productName);
|
||||
if (databaseDriver == DatabaseDriver.UNKNOWN) {
|
||||
throw new IllegalStateException("Unable to detect database type");
|
||||
}
|
||||
|
||||
@@ -32,8 +32,8 @@ public class BatchDatabaseInitializer extends AbstractDatabaseInitializer {
|
||||
|
||||
private final BatchProperties properties;
|
||||
|
||||
public BatchDatabaseInitializer(DataSource dataSource,
|
||||
ResourceLoader resourceLoader, BatchProperties properties) {
|
||||
public BatchDatabaseInitializer(DataSource dataSource, ResourceLoader resourceLoader,
|
||||
BatchProperties properties) {
|
||||
super(dataSource, resourceLoader);
|
||||
Assert.notNull(properties, "BatchProperties must not be null");
|
||||
this.properties = properties;
|
||||
|
||||
@@ -65,8 +65,7 @@ public class RepositoryRestProperties {
|
||||
/**
|
||||
* Strategy to use to determine which repositories get exposed.
|
||||
*/
|
||||
private RepositoryDetectionStrategies detectionStrategy =
|
||||
RepositoryDetectionStrategies.DEFAULT;
|
||||
private RepositoryDetectionStrategies detectionStrategy = RepositoryDetectionStrategies.DEFAULT;
|
||||
|
||||
/**
|
||||
* Content type to use as a default when none is specified.
|
||||
|
||||
@@ -41,7 +41,7 @@ import org.springframework.jms.support.destination.DestinationResolver;
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@Configuration
|
||||
@ConditionalOnClass({Message.class, JmsTemplate.class})
|
||||
@ConditionalOnClass({ Message.class, JmsTemplate.class })
|
||||
@ConditionalOnBean(ConnectionFactory.class)
|
||||
@EnableConfigurationProperties(JmsProperties.class)
|
||||
@Import(JmsAnnotationDrivenConfiguration.class)
|
||||
|
||||
@@ -135,8 +135,8 @@ public class JmsProperties {
|
||||
public static class Template {
|
||||
|
||||
/**
|
||||
* Default destination to use on send/receive operations that do not
|
||||
* have a destination parameter.
|
||||
* Default destination to use on send/receive operations that do not have a
|
||||
* destination parameter.
|
||||
*/
|
||||
private String defaultDestination;
|
||||
|
||||
@@ -156,16 +156,14 @@ public class JmsProperties {
|
||||
private Integer priority;
|
||||
|
||||
/**
|
||||
* Time-to-live of a message when sending in milliseconds. Enable
|
||||
* QoS when set.
|
||||
* Time-to-live of a message when sending in milliseconds. Enable QoS when set.
|
||||
*/
|
||||
private Long timeToLive;
|
||||
|
||||
/**
|
||||
* Enable explicit QoS when sending a message. When enabled, the
|
||||
* delivery mode, priority and time-to-live properties will be
|
||||
* used when sending a message. QoS is automatically enabled when
|
||||
* at least one of those settings is customized.
|
||||
* Enable explicit QoS when sending a message. When enabled, the delivery mode,
|
||||
* priority and time-to-live properties will be used when sending a message. QoS
|
||||
* is automatically enabled when at least one of those settings is customized.
|
||||
*/
|
||||
private Boolean qosEnabled;
|
||||
|
||||
@@ -291,8 +289,8 @@ public class JmsProperties {
|
||||
NON_PERSISTENT(1),
|
||||
|
||||
/*
|
||||
* Instructs the JMS provider to log the message to stable storage as part of
|
||||
* the client's send operation.
|
||||
* Instructs the JMS provider to log the message to stable storage as part of the
|
||||
* client's send operation.
|
||||
*/
|
||||
PERSISTENT(2);
|
||||
|
||||
|
||||
@@ -658,15 +658,15 @@ public class ServerProperties
|
||||
private Charset uriEncoding;
|
||||
|
||||
/**
|
||||
* Maximum number of connections that the server will accept and process
|
||||
* at any given time. Once the limit has been reached, the operating system
|
||||
* may still accept connections based on the "acceptCount" property.
|
||||
* Maximum number of connections that the server will accept and process at any
|
||||
* given time. Once the limit has been reached, the operating system may still
|
||||
* accept connections based on the "acceptCount" property.
|
||||
*/
|
||||
private int maxConnections = 0;
|
||||
|
||||
/**
|
||||
* Maximum queue length for incoming connection requests when all possible
|
||||
* request processing threads are in use.
|
||||
* Maximum queue length for incoming connection requests when all possible request
|
||||
* processing threads are in use.
|
||||
*/
|
||||
private int acceptCount = 0;
|
||||
|
||||
@@ -827,34 +827,37 @@ public class ServerProperties
|
||||
public void customize(Connector connector) {
|
||||
ProtocolHandler handler = connector.getProtocolHandler();
|
||||
if (handler instanceof AbstractProtocol) {
|
||||
AbstractProtocol protocol = (AbstractProtocol) handler;
|
||||
AbstractProtocol<?> protocol = (AbstractProtocol<?>) handler;
|
||||
protocol.setBacklog(Tomcat.this.acceptCount);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
private void customizeMaxConnections(TomcatEmbeddedServletContainerFactory factory) {
|
||||
private void customizeMaxConnections(
|
||||
TomcatEmbeddedServletContainerFactory factory) {
|
||||
factory.addConnectorCustomizers(new TomcatConnectorCustomizer() {
|
||||
|
||||
@Override
|
||||
public void customize(Connector connector) {
|
||||
ProtocolHandler handler = connector.getProtocolHandler();
|
||||
if (handler instanceof AbstractProtocol) {
|
||||
AbstractProtocol protocol = (AbstractProtocol) handler;
|
||||
AbstractProtocol<?> protocol = (AbstractProtocol<?>) handler;
|
||||
protocol.setMaxConnections(Tomcat.this.maxConnections);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
private void customizeConnectionTimeout(
|
||||
TomcatEmbeddedServletContainerFactory factory, int connectionTimeout) {
|
||||
for (Connector connector : factory.getAdditionalTomcatConnectors()) {
|
||||
if (connector.getProtocolHandler() instanceof AbstractProtocol) {
|
||||
AbstractProtocol<?> handler = (AbstractProtocol<?>) connector
|
||||
.getProtocolHandler();
|
||||
handler.setConnectionTimeout(connectionTimeout);
|
||||
ProtocolHandler handler = connector.getProtocolHandler();
|
||||
if (handler instanceof AbstractProtocol) {
|
||||
AbstractProtocol<?> protocol = (AbstractProtocol<?>) handler;
|
||||
protocol.setConnectionTimeout(connectionTimeout);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1108,6 +1111,7 @@ public class ServerProperties
|
||||
JettyEmbeddedServletContainerFactory factory,
|
||||
final int connectionTimeout) {
|
||||
factory.addServerCustomizers(new JettyServerCustomizer() {
|
||||
|
||||
@Override
|
||||
public void customize(Server server) {
|
||||
for (org.eclipse.jetty.server.Connector connector : server
|
||||
@@ -1118,6 +1122,7 @@ public class ServerProperties
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@ package org.springframework.boot.autoconfigure.data.cassandra;
|
||||
import java.util.Set;
|
||||
|
||||
import com.datastax.driver.core.Session;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Test;
|
||||
|
||||
|
||||
@@ -191,7 +191,8 @@ public class NoSuchBeanDefinitionFailureAnalyzerTests {
|
||||
|
||||
private void assertClassDisabled(FailureAnalysis analysis, String description,
|
||||
String methodName) {
|
||||
String expected = String.format("Bean method '%s' not loaded because", methodName);
|
||||
String expected = String.format("Bean method '%s' not loaded because",
|
||||
methodName);
|
||||
assertThat(analysis.getDescription()).contains(expected);
|
||||
assertThat(analysis.getDescription()).contains(description);
|
||||
}
|
||||
|
||||
@@ -56,14 +56,13 @@ public class EmbeddedDataSourceConfigurationTests {
|
||||
@Test
|
||||
public void generateUniqueName() throws Exception {
|
||||
this.context = load("spring.datasource.generate-unique-name=true");
|
||||
AnnotationConfigApplicationContext context2 =
|
||||
load("spring.datasource.generate-unique-name=true");
|
||||
AnnotationConfigApplicationContext context2 = load(
|
||||
"spring.datasource.generate-unique-name=true");
|
||||
try {
|
||||
DataSource dataSource = this.context.getBean(DataSource.class);
|
||||
DataSource dataSource2 = context2.getBean(DataSource.class);
|
||||
assertThat(getDatabaseName(dataSource))
|
||||
.isNotEqualTo(getDatabaseName(dataSource2));
|
||||
System.out.println(dataSource2);
|
||||
}
|
||||
finally {
|
||||
context2.close();
|
||||
|
||||
@@ -259,8 +259,7 @@ public class JmsAutoConfigurationTests {
|
||||
"spring.jms.template.default-destination=testQueue",
|
||||
"spring.jms.template.delivery-delay=500",
|
||||
"spring.jms.template.delivery-mode=non-persistent",
|
||||
"spring.jms.template.priority=6",
|
||||
"spring.jms.template.time-to-live=6000",
|
||||
"spring.jms.template.priority=6", "spring.jms.template.time-to-live=6000",
|
||||
"spring.jms.template.receive-timeout=2000");
|
||||
JmsTemplate jmsTemplate = this.context.getBean(JmsTemplate.class);
|
||||
assertThat(jmsTemplate.getMessageConverter())
|
||||
|
||||
@@ -444,9 +444,9 @@ public class ServerPropertiesTests {
|
||||
|
||||
TomcatEmbeddedServletContainerFactory container = new TomcatEmbeddedServletContainerFactory();
|
||||
this.properties.customize(container);
|
||||
TomcatEmbeddedServletContainer embeddedContainer =
|
||||
(TomcatEmbeddedServletContainer) container.getEmbeddedServletContainer();
|
||||
assertThat(((AbstractProtocol) embeddedContainer.getTomcat().getConnector()
|
||||
TomcatEmbeddedServletContainer embeddedContainer = (TomcatEmbeddedServletContainer) container
|
||||
.getEmbeddedServletContainer();
|
||||
assertThat(((AbstractProtocol<?>) embeddedContainer.getTomcat().getConnector()
|
||||
.getProtocolHandler()).getBacklog()).isEqualTo(10);
|
||||
}
|
||||
|
||||
@@ -458,9 +458,9 @@ public class ServerPropertiesTests {
|
||||
|
||||
TomcatEmbeddedServletContainerFactory container = new TomcatEmbeddedServletContainerFactory();
|
||||
this.properties.customize(container);
|
||||
TomcatEmbeddedServletContainer embeddedContainer =
|
||||
(TomcatEmbeddedServletContainer) container.getEmbeddedServletContainer();
|
||||
assertThat(((AbstractProtocol) embeddedContainer.getTomcat().getConnector()
|
||||
TomcatEmbeddedServletContainer embeddedContainer = (TomcatEmbeddedServletContainer) container
|
||||
.getEmbeddedServletContainer();
|
||||
assertThat(((AbstractProtocol<?>) embeddedContainer.getTomcat().getConnector()
|
||||
.getProtocolHandler()).getMaxConnections()).isEqualTo(5);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user