Merge branch '1.2.x'
This commit is contained in:
@@ -110,8 +110,8 @@ public abstract class AutoConfigurationPackages {
|
||||
|
||||
private static String[] addBasePackages(
|
||||
ConstructorArgumentValues constructorArguments, String[] packageNames) {
|
||||
String[] existing = (String[]) constructorArguments.getIndexedArgumentValue(0,
|
||||
String[].class).getValue();
|
||||
String[] existing = (String[]) constructorArguments
|
||||
.getIndexedArgumentValue(0, String[].class).getValue();
|
||||
Set<String> merged = new LinkedHashSet<String>();
|
||||
merged.addAll(Arrays.asList(existing));
|
||||
merged.addAll(Arrays.asList(packageNames));
|
||||
|
||||
@@ -155,8 +155,8 @@ class AutoConfigurationSorter {
|
||||
}
|
||||
|
||||
private Set<String> getAnnotationValue(Class<?> annotation) {
|
||||
Map<String, Object> attributes = this.metadata.getAnnotationAttributes(
|
||||
annotation.getName(), true);
|
||||
Map<String, Object> attributes = this.metadata
|
||||
.getAnnotationAttributes(annotation.getName(), true);
|
||||
if (attributes == null) {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
@@ -43,30 +43,25 @@ import com.rabbitmq.client.Channel;
|
||||
* <P>
|
||||
* Registers the following beans:
|
||||
* <ul>
|
||||
* <li>
|
||||
* {@link org.springframework.amqp.rabbit.core.RabbitTemplate RabbitTemplate} if there is
|
||||
* no other bean of the same type in the context.</li>
|
||||
* <li>
|
||||
* {@link org.springframework.amqp.rabbit.connection.CachingConnectionFactory
|
||||
* <li>{@link org.springframework.amqp.rabbit.core.RabbitTemplate RabbitTemplate} if there
|
||||
* is no other bean of the same type in the context.</li>
|
||||
* <li>{@link org.springframework.amqp.rabbit.connection.CachingConnectionFactory
|
||||
* CachingConnectionFactory} instance if there is no other bean of the same type in the
|
||||
* context.</li>
|
||||
* <li>
|
||||
* {@link org.springframework.amqp.core.AmqpAdmin } instance as long as
|
||||
* <li>{@link org.springframework.amqp.core.AmqpAdmin } instance as long as
|
||||
* {@literal spring.rabbitmq.dynamic=true}.</li>
|
||||
* </ul>
|
||||
* <p>
|
||||
* The {@link org.springframework.amqp.rabbit.connection.CachingConnectionFactory} honors
|
||||
* the following properties:
|
||||
* <ul>
|
||||
* <li>
|
||||
* {@literal spring.rabbitmq.port} is used to specify the port to which the client should
|
||||
* connect, and defaults to 5672.</li>
|
||||
* <li>
|
||||
* {@literal spring.rabbitmq.username} is used to specify the (optional) username.</li>
|
||||
* <li>
|
||||
* {@literal spring.rabbitmq.password} is used to specify the (optional) password.</li>
|
||||
* <li>
|
||||
* {@literal spring.rabbitmq.host} is used to specify the host, and defaults to
|
||||
* <li>{@literal spring.rabbitmq.port} is used to specify the port to which the client
|
||||
* should connect, and defaults to 5672.</li>
|
||||
* <li>{@literal spring.rabbitmq.username} is used to specify the (optional) username.
|
||||
* </li>
|
||||
* <li>{@literal spring.rabbitmq.password} is used to specify the (optional) password.
|
||||
* </li>
|
||||
* <li>{@literal spring.rabbitmq.host} is used to specify the host, and defaults to
|
||||
* {@literal localhost}.</li>
|
||||
* <li>{@literal spring.rabbitmq.virtualHost} is used to specify the (optional) virtual
|
||||
* host to which the client should connect.</li>
|
||||
|
||||
@@ -142,8 +142,8 @@ public class RabbitProperties {
|
||||
}
|
||||
result.add(address);
|
||||
}
|
||||
return (result.isEmpty() ? null : StringUtils
|
||||
.collectionToCommaDelimitedString(result));
|
||||
return (result.isEmpty() ? null
|
||||
: StringUtils.collectionToCommaDelimitedString(result));
|
||||
}
|
||||
|
||||
public void setPort(int port) {
|
||||
|
||||
@@ -137,7 +137,8 @@ class BasicBatchConfigurer implements BatchConfigurer {
|
||||
JobRepositoryFactoryBean factory = new JobRepositoryFactoryBean();
|
||||
factory.setDataSource(this.dataSource);
|
||||
if (this.entityManagerFactory != null) {
|
||||
logger.warn("JPA does not support custom isolation levels, so locks may not be taken when launching Jobs");
|
||||
logger.warn(
|
||||
"JPA does not support custom isolation levels, so locks may not be taken when launching Jobs");
|
||||
factory.setIsolationLevelForCreate("ISOLATION_DEFAULT");
|
||||
}
|
||||
String tablePrefix = this.properties.getTablePrefix();
|
||||
|
||||
@@ -28,8 +28,8 @@ import org.springframework.context.ApplicationListener;
|
||||
*
|
||||
* @author Dave Syer
|
||||
*/
|
||||
public class JobExecutionExitCodeGenerator implements
|
||||
ApplicationListener<JobExecutionEvent>, ExitCodeGenerator {
|
||||
public class JobExecutionExitCodeGenerator
|
||||
implements ApplicationListener<JobExecutionEvent>, ExitCodeGenerator {
|
||||
|
||||
private final List<JobExecution> executions = new ArrayList<JobExecution>();
|
||||
|
||||
|
||||
@@ -62,8 +62,8 @@ import org.springframework.util.StringUtils;
|
||||
* @author Jean-Pierre Bergamin
|
||||
*/
|
||||
@Component
|
||||
public class JobLauncherCommandLineRunner implements CommandLineRunner,
|
||||
ApplicationEventPublisherAware {
|
||||
public class JobLauncherCommandLineRunner
|
||||
implements CommandLineRunner, ApplicationEventPublisherAware {
|
||||
|
||||
private static Log logger = LogFactory.getLog(JobLauncherCommandLineRunner.class);
|
||||
|
||||
@@ -81,7 +81,8 @@ public class JobLauncherCommandLineRunner implements CommandLineRunner,
|
||||
|
||||
private ApplicationEventPublisher publisher;
|
||||
|
||||
public JobLauncherCommandLineRunner(JobLauncher jobLauncher, JobExplorer jobExplorer) {
|
||||
public JobLauncherCommandLineRunner(JobLauncher jobLauncher,
|
||||
JobExplorer jobExplorer) {
|
||||
this.jobLauncher = jobLauncher;
|
||||
this.jobExplorer = jobExplorer;
|
||||
}
|
||||
@@ -123,7 +124,8 @@ public class JobLauncherCommandLineRunner implements CommandLineRunner,
|
||||
executeRegisteredJobs(jobParameters);
|
||||
}
|
||||
|
||||
private JobParameters getNextJobParameters(Job job, JobParameters additionalParameters) {
|
||||
private JobParameters getNextJobParameters(Job job,
|
||||
JobParameters additionalParameters) {
|
||||
String name = job.getName();
|
||||
JobParameters parameters = new JobParameters();
|
||||
List<JobInstance> lastInstances = this.jobExplorer.getJobInstances(name, 0, 1);
|
||||
@@ -165,7 +167,8 @@ public class JobLauncherCommandLineRunner implements CommandLineRunner,
|
||||
}
|
||||
|
||||
private void removeNonIdentifying(Map<String, JobParameter> parameters) {
|
||||
HashMap<String, JobParameter> copy = new HashMap<String, JobParameter>(parameters);
|
||||
HashMap<String, JobParameter> copy = new HashMap<String, JobParameter>(
|
||||
parameters);
|
||||
for (Map.Entry<String, JobParameter> parameter : copy.entrySet()) {
|
||||
if (!parameter.getValue().isIdentifying()) {
|
||||
parameters.remove(parameter.getKey());
|
||||
|
||||
@@ -96,8 +96,8 @@ abstract class BeanTypeRegistry {
|
||||
}
|
||||
|
||||
private Class<?> doGetFactoryBeanGeneric(ConfigurableListableBeanFactory beanFactory,
|
||||
BeanDefinition definition, String name) throws Exception,
|
||||
ClassNotFoundException, LinkageError {
|
||||
BeanDefinition definition, String name)
|
||||
throws Exception, ClassNotFoundException, LinkageError {
|
||||
if (StringUtils.hasLength(definition.getFactoryBeanName())
|
||||
&& StringUtils.hasLength(definition.getFactoryMethodName())) {
|
||||
return getConfigurationClassFactoryBeanGeneric(beanFactory, definition, name);
|
||||
@@ -116,8 +116,8 @@ abstract class BeanTypeRegistry {
|
||||
.as(FactoryBean.class).resolveGeneric();
|
||||
if ((generic == null || generic.equals(Object.class))
|
||||
&& definition.hasAttribute(FACTORY_BEAN_OBJECT_TYPE)) {
|
||||
generic = getTypeFromAttribute(definition
|
||||
.getAttribute(FACTORY_BEAN_OBJECT_TYPE));
|
||||
generic = getTypeFromAttribute(
|
||||
definition.getAttribute(FACTORY_BEAN_OBJECT_TYPE));
|
||||
}
|
||||
return generic;
|
||||
}
|
||||
@@ -132,12 +132,12 @@ abstract class BeanTypeRegistry {
|
||||
.getIntrospectedMethod();
|
||||
}
|
||||
}
|
||||
BeanDefinition factoryDefinition = beanFactory.getBeanDefinition(definition
|
||||
.getFactoryBeanName());
|
||||
BeanDefinition factoryDefinition = beanFactory
|
||||
.getBeanDefinition(definition.getFactoryBeanName());
|
||||
Class<?> factoryClass = ClassUtils.forName(factoryDefinition.getBeanClassName(),
|
||||
beanFactory.getBeanClassLoader());
|
||||
return ReflectionUtils
|
||||
.findMethod(factoryClass, definition.getFactoryMethodName());
|
||||
return ReflectionUtils.findMethod(factoryClass,
|
||||
definition.getFactoryMethodName());
|
||||
}
|
||||
|
||||
private Class<?> getDirectFactoryBeanGeneric(
|
||||
@@ -145,12 +145,12 @@ abstract class BeanTypeRegistry {
|
||||
String name) throws ClassNotFoundException, LinkageError {
|
||||
Class<?> factoryBeanClass = ClassUtils.forName(definition.getBeanClassName(),
|
||||
beanFactory.getBeanClassLoader());
|
||||
Class<?> generic = ResolvableType.forClass(factoryBeanClass)
|
||||
.as(FactoryBean.class).resolveGeneric();
|
||||
Class<?> generic = ResolvableType.forClass(factoryBeanClass).as(FactoryBean.class)
|
||||
.resolveGeneric();
|
||||
if ((generic == null || generic.equals(Object.class))
|
||||
&& definition.hasAttribute(FACTORY_BEAN_OBJECT_TYPE)) {
|
||||
generic = getTypeFromAttribute(definition
|
||||
.getAttribute(FACTORY_BEAN_OBJECT_TYPE));
|
||||
generic = getTypeFromAttribute(
|
||||
definition.getAttribute(FACTORY_BEAN_OBJECT_TYPE));
|
||||
}
|
||||
return generic;
|
||||
}
|
||||
@@ -195,8 +195,8 @@ abstract class BeanTypeRegistry {
|
||||
@Override
|
||||
public Set<String> getNamesForType(Class<?> type) {
|
||||
Set<String> result = new LinkedHashSet<String>();
|
||||
result.addAll(Arrays.asList(this.beanFactory.getBeanNamesForType(type, true,
|
||||
false)));
|
||||
result.addAll(Arrays
|
||||
.asList(this.beanFactory.getBeanNamesForType(type, true, false)));
|
||||
if (this.beanFactory instanceof ConfigurableListableBeanFactory) {
|
||||
collectBeanNamesForTypeFromFactoryBeans(result,
|
||||
(ConfigurableListableBeanFactory) this.beanFactory, type);
|
||||
@@ -225,8 +225,8 @@ abstract class BeanTypeRegistry {
|
||||
* {@link BeanTypeRegistry} optimized for {@link DefaultListableBeanFactory}
|
||||
* implementations that allow eager class loading.
|
||||
*/
|
||||
static class OptimizedBeanTypeRegistry extends BeanTypeRegistry implements
|
||||
SmartInitializingSingleton {
|
||||
static class OptimizedBeanTypeRegistry extends BeanTypeRegistry
|
||||
implements SmartInitializingSingleton {
|
||||
|
||||
private static final String BEAN_NAME = BeanTypeRegistry.class.getName();
|
||||
|
||||
@@ -249,7 +249,8 @@ abstract class BeanTypeRegistry {
|
||||
|
||||
@Override
|
||||
public Set<String> getNamesForType(Class<?> type) {
|
||||
if (this.lastBeanDefinitionCount != this.beanFactory.getBeanDefinitionCount()) {
|
||||
if (this.lastBeanDefinitionCount != this.beanFactory
|
||||
.getBeanDefinitionCount()) {
|
||||
Iterator<String> names = this.beanFactory.getBeanNamesIterator();
|
||||
while (names.hasNext()) {
|
||||
String name = names.next();
|
||||
@@ -315,8 +316,8 @@ abstract class BeanTypeRegistry {
|
||||
|
||||
private boolean requiresEagerInit(String factoryBeanName) {
|
||||
return (factoryBeanName != null
|
||||
&& this.beanFactory.isFactoryBean(factoryBeanName) && !this.beanFactory
|
||||
.containsSingleton(factoryBeanName));
|
||||
&& this.beanFactory.isFactoryBean(factoryBeanName)
|
||||
&& !this.beanFactory.containsSingleton(factoryBeanName));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -112,7 +112,8 @@ public final class ConditionEvaluationReport {
|
||||
*/
|
||||
public Map<String, ConditionAndOutcomes> getConditionAndOutcomesBySource() {
|
||||
if (!this.addedAncestorOutcomes) {
|
||||
for (Map.Entry<String, ConditionAndOutcomes> entry : this.outcomes.entrySet()) {
|
||||
for (Map.Entry<String, ConditionAndOutcomes> entry : this.outcomes
|
||||
.entrySet()) {
|
||||
if (!entry.getValue().isFullMatch()) {
|
||||
addNoMatchOutcomeToAncestors(entry.getKey());
|
||||
}
|
||||
@@ -126,8 +127,8 @@ public final class ConditionEvaluationReport {
|
||||
String prefix = source + "$";
|
||||
for (Entry<String, ConditionAndOutcomes> entry : this.outcomes.entrySet()) {
|
||||
if (entry.getKey().startsWith(prefix)) {
|
||||
ConditionOutcome outcome = new ConditionOutcome(false, "Ancestor '"
|
||||
+ source + "' did not match");
|
||||
ConditionOutcome outcome = new ConditionOutcome(false,
|
||||
"Ancestor '" + source + "' did not match");
|
||||
entry.getValue().add(ANCESTOR_CONDITION, outcome);
|
||||
}
|
||||
}
|
||||
@@ -250,8 +251,8 @@ public final class ConditionEvaluationReport {
|
||||
}
|
||||
ConditionAndOutcome other = (ConditionAndOutcome) obj;
|
||||
return (ObjectUtils.nullSafeEquals(this.condition.getClass(),
|
||||
other.condition.getClass()) && ObjectUtils.nullSafeEquals(
|
||||
this.outcome, other.outcome));
|
||||
other.condition.getClass())
|
||||
&& ObjectUtils.nullSafeEquals(this.outcome, other.outcome));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -92,8 +92,8 @@ public class ConditionOutcome {
|
||||
}
|
||||
if (getClass() == obj.getClass()) {
|
||||
ConditionOutcome other = (ConditionOutcome) obj;
|
||||
return (this.match == other.match && ObjectUtils.nullSafeEquals(this.message,
|
||||
other.message));
|
||||
return (this.match == other.match
|
||||
&& ObjectUtils.nullSafeEquals(this.message, other.message));
|
||||
}
|
||||
return super.equals(obj);
|
||||
}
|
||||
|
||||
@@ -57,15 +57,15 @@ class OnClassCondition extends SpringBootCondition {
|
||||
+ StringUtils.collectionToCommaDelimitedString(missing));
|
||||
}
|
||||
matchMessage.append("@ConditionalOnClass classes found: "
|
||||
+ StringUtils.collectionToCommaDelimitedString(getMatchingClasses(
|
||||
onClasses, MatchType.PRESENT, context)));
|
||||
+ StringUtils.collectionToCommaDelimitedString(
|
||||
getMatchingClasses(onClasses, MatchType.PRESENT, context)));
|
||||
}
|
||||
|
||||
MultiValueMap<String, Object> onMissingClasses = getAttributes(metadata,
|
||||
ConditionalOnMissingClass.class);
|
||||
if (onMissingClasses != null) {
|
||||
List<String> present = getMatchingClasses(onMissingClasses,
|
||||
MatchType.PRESENT, context);
|
||||
List<String> present = getMatchingClasses(onMissingClasses, MatchType.PRESENT,
|
||||
context);
|
||||
if (!present.isEmpty()) {
|
||||
return ConditionOutcome
|
||||
.noMatch("required @ConditionalOnMissing classes found: "
|
||||
|
||||
@@ -39,8 +39,9 @@ class OnExpressionCondition extends SpringBootCondition {
|
||||
public ConditionOutcome getMatchOutcome(ConditionContext context,
|
||||
AnnotatedTypeMetadata metadata) {
|
||||
|
||||
String expression = (String) metadata.getAnnotationAttributes(
|
||||
ConditionalOnExpression.class.getName()).get("value");
|
||||
String expression = (String) metadata
|
||||
.getAnnotationAttributes(ConditionalOnExpression.class.getName())
|
||||
.get("value");
|
||||
String rawExpression = expression;
|
||||
if (!expression.startsWith("#{")) {
|
||||
// For convenience allow user to provide bare expression with no #{} wrapper
|
||||
@@ -51,8 +52,8 @@ class OnExpressionCondition extends SpringBootCondition {
|
||||
expression = context.getEnvironment().resolvePlaceholders(expression);
|
||||
ConfigurableListableBeanFactory beanFactory = context.getBeanFactory();
|
||||
BeanExpressionResolver resolver = beanFactory.getBeanExpressionResolver();
|
||||
BeanExpressionContext expressionContext = (beanFactory != null) ? new BeanExpressionContext(
|
||||
beanFactory, null) : null;
|
||||
BeanExpressionContext expressionContext = (beanFactory != null)
|
||||
? new BeanExpressionContext(beanFactory, null) : null;
|
||||
if (resolver == null) {
|
||||
resolver = new StandardBeanExpressionResolver();
|
||||
}
|
||||
|
||||
@@ -55,9 +55,10 @@ class OnJavaCondition extends SpringBootCondition {
|
||||
return new ConditionOutcome(match, getMessage(range, runningVersion, version));
|
||||
}
|
||||
|
||||
private String getMessage(Range range, JavaVersion runningVersion, JavaVersion version) {
|
||||
String expected = String.format(range == Range.EQUAL_OR_NEWER ? "%s or newer"
|
||||
: "older than %s", version);
|
||||
private String getMessage(Range range, JavaVersion runningVersion,
|
||||
JavaVersion version) {
|
||||
String expected = String.format(
|
||||
range == Range.EQUAL_OR_NEWER ? "%s or newer" : "older than %s", version);
|
||||
return "Required JVM version " + expected + " found " + runningVersion;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,8 +41,8 @@ class OnJndiCondition extends SpringBootCondition {
|
||||
@Override
|
||||
public ConditionOutcome getMatchOutcome(ConditionContext context,
|
||||
AnnotatedTypeMetadata metadata) {
|
||||
AnnotationAttributes annotationAttributes = AnnotationAttributes.fromMap(metadata
|
||||
.getAnnotationAttributes(ConditionalOnJndi.class.getName()));
|
||||
AnnotationAttributes annotationAttributes = AnnotationAttributes.fromMap(
|
||||
metadata.getAnnotationAttributes(ConditionalOnJndi.class.getName()));
|
||||
String[] locations = annotationAttributes.getStringArray("value");
|
||||
try {
|
||||
return getMatchOutcome(locations);
|
||||
@@ -62,9 +62,9 @@ class OnJndiCondition extends SpringBootCondition {
|
||||
JndiLocator locator = getJndiLocator(locations);
|
||||
String location = locator.lookupFirstLocation();
|
||||
if (location != null) {
|
||||
return ConditionOutcome.match("JNDI location '" + location
|
||||
+ "' found from candidates "
|
||||
+ StringUtils.arrayToCommaDelimitedString(locations));
|
||||
return ConditionOutcome
|
||||
.match("JNDI location '" + location + "' found from candidates "
|
||||
+ StringUtils.arrayToCommaDelimitedString(locations));
|
||||
}
|
||||
return ConditionOutcome.noMatch("No JNDI location found from candidates "
|
||||
+ StringUtils.arrayToCommaDelimitedString(locations));
|
||||
|
||||
@@ -44,8 +44,8 @@ class OnPropertyCondition extends SpringBootCondition {
|
||||
public ConditionOutcome getMatchOutcome(ConditionContext context,
|
||||
AnnotatedTypeMetadata metadata) {
|
||||
|
||||
AnnotationAttributes annotationAttributes = AnnotationAttributes.fromMap(metadata
|
||||
.getAnnotationAttributes(ConditionalOnProperty.class.getName()));
|
||||
AnnotationAttributes annotationAttributes = AnnotationAttributes.fromMap(
|
||||
metadata.getAnnotationAttributes(ConditionalOnProperty.class.getName()));
|
||||
|
||||
String prefix = annotationAttributes.getString("prefix").trim();
|
||||
if (StringUtils.hasText(prefix) && !prefix.endsWith(".")) {
|
||||
|
||||
@@ -40,11 +40,11 @@ class OnResourceCondition extends SpringBootCondition {
|
||||
@Override
|
||||
public ConditionOutcome getMatchOutcome(ConditionContext context,
|
||||
AnnotatedTypeMetadata metadata) {
|
||||
MultiValueMap<String, Object> attributes = metadata.getAllAnnotationAttributes(
|
||||
ConditionalOnResource.class.getName(), true);
|
||||
MultiValueMap<String, Object> attributes = metadata
|
||||
.getAllAnnotationAttributes(ConditionalOnResource.class.getName(), true);
|
||||
if (attributes != null) {
|
||||
ResourceLoader loader = context.getResourceLoader() == null ? this.defaultResourceLoader
|
||||
: context.getResourceLoader();
|
||||
ResourceLoader loader = context.getResourceLoader() == null
|
||||
? this.defaultResourceLoader : context.getResourceLoader();
|
||||
List<String> locations = new ArrayList<String>();
|
||||
collectValues(locations, attributes.get("resources"));
|
||||
Assert.isTrue(locations.size() > 0,
|
||||
|
||||
@@ -39,7 +39,8 @@ public abstract class SpringBootCondition implements Condition {
|
||||
private final Log logger = LogFactory.getLog(getClass());
|
||||
|
||||
@Override
|
||||
public final boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
|
||||
public final boolean matches(ConditionContext context,
|
||||
AnnotatedTypeMetadata metadata) {
|
||||
String classOrMethodName = getClassOrMethodName(metadata);
|
||||
try {
|
||||
ConditionOutcome outcome = getMatchOutcome(context, metadata);
|
||||
@@ -55,8 +56,8 @@ public abstract class SpringBootCondition implements Condition {
|
||||
+ "in the default package by mistake)", ex);
|
||||
}
|
||||
catch (RuntimeException ex) {
|
||||
throw new IllegalStateException("Error processing condition on "
|
||||
+ getName(metadata), ex);
|
||||
throw new IllegalStateException(
|
||||
"Error processing condition on " + getName(metadata), ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,7 +89,8 @@ public abstract class SpringBootCondition implements Condition {
|
||||
}
|
||||
}
|
||||
|
||||
private StringBuilder getLogMessage(String classOrMethodName, ConditionOutcome outcome) {
|
||||
private StringBuilder getLogMessage(String classOrMethodName,
|
||||
ConditionOutcome outcome) {
|
||||
StringBuilder message = new StringBuilder();
|
||||
message.append("Condition ");
|
||||
message.append(ClassUtils.getShortName(getClass()));
|
||||
|
||||
@@ -42,8 +42,8 @@ import org.springframework.data.repository.config.RepositoryConfigurationExtensi
|
||||
* @author Dave Syer
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
public abstract class AbstractRepositoryConfigurationSourceSupport implements
|
||||
BeanFactoryAware, ImportBeanDefinitionRegistrar, ResourceLoaderAware,
|
||||
public abstract class AbstractRepositoryConfigurationSourceSupport
|
||||
implements BeanFactoryAware, ImportBeanDefinitionRegistrar, ResourceLoaderAware,
|
||||
EnvironmentAware {
|
||||
|
||||
private ResourceLoader resourceLoader;
|
||||
@@ -55,9 +55,9 @@ public abstract class AbstractRepositoryConfigurationSourceSupport implements
|
||||
@Override
|
||||
public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata,
|
||||
BeanDefinitionRegistry registry) {
|
||||
new RepositoryConfigurationDelegate(getConfigurationSource(),
|
||||
this.resourceLoader, this.environment).registerRepositoriesIn(registry,
|
||||
getRepositoryConfigurationExtension());
|
||||
new RepositoryConfigurationDelegate(getConfigurationSource(), this.resourceLoader,
|
||||
this.environment).registerRepositoriesIn(registry,
|
||||
getRepositoryConfigurationExtension());
|
||||
}
|
||||
|
||||
private AnnotationRepositoryConfigurationSource getConfigurationSource() {
|
||||
|
||||
@@ -32,8 +32,8 @@ import org.springframework.data.repository.config.RepositoryConfigurationExtensi
|
||||
* @author Mohsin Husen
|
||||
* @since 1.1.0
|
||||
*/
|
||||
class ElasticsearchRepositoriesRegistrar extends
|
||||
AbstractRepositoryConfigurationSourceSupport {
|
||||
class ElasticsearchRepositoriesRegistrar
|
||||
extends AbstractRepositoryConfigurationSourceSupport {
|
||||
|
||||
@Override
|
||||
protected Class<? extends Annotation> getAnnotation() {
|
||||
|
||||
@@ -31,8 +31,8 @@ import org.springframework.data.repository.config.RepositoryConfigurationExtensi
|
||||
* @author Phillip Webb
|
||||
* @author Dave Syer
|
||||
*/
|
||||
class JpaRepositoriesAutoConfigureRegistrar extends
|
||||
AbstractRepositoryConfigurationSourceSupport {
|
||||
class JpaRepositoriesAutoConfigureRegistrar
|
||||
extends AbstractRepositoryConfigurationSourceSupport {
|
||||
|
||||
@Override
|
||||
protected Class<? extends Annotation> getAnnotation() {
|
||||
|
||||
@@ -125,8 +125,8 @@ public class MongoDataAutoConfiguration implements BeanClassLoaderAware {
|
||||
MappingMongoConverter mappingConverter = new MappingMongoConverter(dbRefResolver,
|
||||
context);
|
||||
try {
|
||||
mappingConverter.setCustomConversions(beanFactory
|
||||
.getBean(CustomConversions.class));
|
||||
mappingConverter
|
||||
.setCustomConversions(beanFactory.getBean(CustomConversions.class));
|
||||
}
|
||||
catch (NoSuchBeanDefinitionException ex) {
|
||||
// Ignore
|
||||
@@ -183,8 +183,9 @@ public class MongoDataAutoConfiguration implements BeanClassLoaderAware {
|
||||
@ConditionalOnMissingBean
|
||||
public GridFsTemplate gridFsTemplate(MongoDbFactory mongoDbFactory,
|
||||
MongoTemplate mongoTemplate) {
|
||||
return new GridFsTemplate(new GridFsMongoDbFactory(mongoDbFactory,
|
||||
this.properties), mongoTemplate.getConverter());
|
||||
return new GridFsTemplate(
|
||||
new GridFsMongoDbFactory(mongoDbFactory, this.properties),
|
||||
mongoTemplate.getConverter());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -30,8 +30,8 @@ import org.springframework.data.repository.config.RepositoryConfigurationExtensi
|
||||
*
|
||||
* @author Dave Syer
|
||||
*/
|
||||
class MongoRepositoriesAutoConfigureRegistrar extends
|
||||
AbstractRepositoryConfigurationSourceSupport {
|
||||
class MongoRepositoriesAutoConfigureRegistrar
|
||||
extends AbstractRepositoryConfigurationSourceSupport {
|
||||
|
||||
@Override
|
||||
protected Class<? extends Annotation> getAnnotation() {
|
||||
|
||||
@@ -83,8 +83,9 @@ public class FlywayAutoConfiguration {
|
||||
Assert.state(!this.properties.getLocations().isEmpty(),
|
||||
"Migration script locations not configured");
|
||||
boolean exists = hasAtLeastOneLocation();
|
||||
Assert.state(exists, "Cannot find migrations location in: "
|
||||
+ this.properties.getLocations()
|
||||
Assert.state(exists,
|
||||
"Cannot find migrations location in: " + this.properties
|
||||
.getLocations()
|
||||
+ " (please add migrations or check your Flyway configuration)");
|
||||
}
|
||||
}
|
||||
@@ -104,8 +105,8 @@ public class FlywayAutoConfiguration {
|
||||
Flyway flyway = new Flyway();
|
||||
if (this.properties.isCreateDataSource()) {
|
||||
flyway.setDataSource(this.properties.getUrl(), this.properties.getUser(),
|
||||
this.properties.getPassword(), this.properties.getInitSqls()
|
||||
.toArray(new String[0]));
|
||||
this.properties.getPassword(),
|
||||
this.properties.getInitSqls().toArray(new String[0]));
|
||||
}
|
||||
else if (this.flywayDataSource != null) {
|
||||
flyway.setDataSource(this.flywayDataSource);
|
||||
@@ -147,8 +148,8 @@ public class FlywayAutoConfiguration {
|
||||
@Configuration
|
||||
@ConditionalOnClass(LocalContainerEntityManagerFactoryBean.class)
|
||||
@ConditionalOnBean(AbstractEntityManagerFactoryBean.class)
|
||||
protected static class FlywayJpaDependencyConfiguration extends
|
||||
EntityManagerFactoryDependsOnPostProcessor {
|
||||
protected static class FlywayJpaDependencyConfiguration
|
||||
extends EntityManagerFactoryDependsOnPostProcessor {
|
||||
|
||||
public FlywayJpaDependencyConfiguration() {
|
||||
super("flyway");
|
||||
|
||||
@@ -29,8 +29,8 @@ import org.springframework.util.ClassUtils;
|
||||
* @author Andy Wilkinson
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public class FreeMarkerTemplateAvailabilityProvider implements
|
||||
TemplateAvailabilityProvider {
|
||||
public class FreeMarkerTemplateAvailabilityProvider
|
||||
implements TemplateAvailabilityProvider {
|
||||
|
||||
@Override
|
||||
public boolean isTemplateAvailable(String view, Environment environment,
|
||||
|
||||
@@ -52,12 +52,13 @@ public class GroovyTemplateResolver implements TemplateResolver {
|
||||
public URL resolveTemplate(final String templatePath) throws IOException {
|
||||
MarkupTemplateEngine.TemplateResource templateResource = MarkupTemplateEngine.TemplateResource
|
||||
.parse(templatePath);
|
||||
URL resource = this.templateClassLoader.getResource(templateResource.withLocale(
|
||||
LocaleContextHolder.getLocale().toString().replace("-", "_")).toString());
|
||||
URL resource = this.templateClassLoader.getResource(templateResource
|
||||
.withLocale(LocaleContextHolder.getLocale().toString().replace("-", "_"))
|
||||
.toString());
|
||||
if (resource == null) {
|
||||
// no resource found with the default locale, try without any locale
|
||||
resource = this.templateClassLoader.getResource(templateResource.withLocale(
|
||||
null).toString());
|
||||
resource = this.templateClassLoader
|
||||
.getResource(templateResource.withLocale(null).toString());
|
||||
}
|
||||
if (resource == null) {
|
||||
throw new IOException("Unable to load template:" + templatePath);
|
||||
|
||||
@@ -88,8 +88,8 @@ public class HypermediaAutoConfiguration {
|
||||
* {@link BeanPostProcessor} to apply any {@link Jackson2ObjectMapperBuilder}
|
||||
* configuration to the HAL {@link ObjectMapper}.
|
||||
*/
|
||||
private static class HalObjectMapperConfigurer implements BeanPostProcessor,
|
||||
BeanFactoryAware {
|
||||
private static class HalObjectMapperConfigurer
|
||||
implements BeanPostProcessor, BeanFactoryAware {
|
||||
|
||||
private BeanFactory beanFactory;
|
||||
|
||||
|
||||
@@ -78,8 +78,8 @@ public class DataSourceAutoConfiguration {
|
||||
ConfigurableListableBeanFactory beanFactory) {
|
||||
try {
|
||||
BeanDefinition beanDefinition = beanFactory.getBeanDefinition("dataSource");
|
||||
return EmbeddedDataSourceConfiguration.class.getName().equals(
|
||||
beanDefinition.getFactoryBeanName());
|
||||
return EmbeddedDataSourceConfiguration.class.getName()
|
||||
.equals(beanDefinition.getFactoryBeanName());
|
||||
}
|
||||
catch (NoSuchBeanDefinitionException ex) {
|
||||
return false;
|
||||
@@ -117,8 +117,7 @@ public class DataSourceAutoConfiguration {
|
||||
DataSourceBuilder factory = DataSourceBuilder
|
||||
.create(this.properties.getClassLoader())
|
||||
.driverClassName(this.properties.getDriverClassName())
|
||||
.url(this.properties.getUrl())
|
||||
.username(this.properties.getUsername())
|
||||
.url(this.properties.getUrl()).username(this.properties.getUsername())
|
||||
.password(this.properties.getPassword());
|
||||
if (this.properties.getType() != null) {
|
||||
factory.type(this.properties.getType());
|
||||
@@ -212,8 +211,8 @@ public class DataSourceAutoConfiguration {
|
||||
return ConditionOutcome
|
||||
.noMatch("existing non-embedded database detected");
|
||||
}
|
||||
EmbeddedDatabaseType type = EmbeddedDatabaseConnection.get(
|
||||
context.getClassLoader()).getType();
|
||||
EmbeddedDatabaseType type = EmbeddedDatabaseConnection
|
||||
.get(context.getClassLoader()).getType();
|
||||
if (type == null) {
|
||||
return ConditionOutcome.noMatch("no embedded database detected");
|
||||
}
|
||||
|
||||
@@ -63,7 +63,8 @@ class DataSourceInitializer implements ApplicationListener<DataSourceInitialized
|
||||
logger.debug("Initialization disabled (not running DDL scripts)");
|
||||
return;
|
||||
}
|
||||
if (this.applicationContext.getBeanNamesForType(DataSource.class, false, false).length > 0) {
|
||||
if (this.applicationContext.getBeanNamesForType(DataSource.class, false,
|
||||
false).length > 0) {
|
||||
this.dataSource = this.applicationContext.getBean(DataSource.class);
|
||||
}
|
||||
if (this.dataSource == null) {
|
||||
@@ -78,8 +79,8 @@ class DataSourceInitializer implements ApplicationListener<DataSourceInitialized
|
||||
if (!scripts.isEmpty()) {
|
||||
runScripts(scripts);
|
||||
try {
|
||||
this.applicationContext.publishEvent(new DataSourceInitializedEvent(
|
||||
this.dataSource));
|
||||
this.applicationContext
|
||||
.publishEvent(new DataSourceInitializedEvent(this.dataSource));
|
||||
// The listener might not be registered yet, so don't rely on it.
|
||||
if (!this.initialized) {
|
||||
runDataScripts();
|
||||
@@ -132,8 +133,8 @@ class DataSourceInitializer implements ApplicationListener<DataSourceInitialized
|
||||
}
|
||||
}
|
||||
catch (IOException ex) {
|
||||
throw new IllegalStateException("Unable to load resource from "
|
||||
+ location, ex);
|
||||
throw new IllegalStateException(
|
||||
"Unable to load resource from " + location, ex);
|
||||
}
|
||||
}
|
||||
return resources;
|
||||
|
||||
@@ -33,6 +33,7 @@ class DriverClassNameProvider {
|
||||
private static final String JDBC_URL_PREFIX = "jdbc";
|
||||
|
||||
private static final Map<String, String> DRIVERS;
|
||||
|
||||
static {
|
||||
Map<String, String> drivers = new HashMap<String, String>();
|
||||
drivers.put("derby", "org.apache.derby.jdbc.EmbeddedDriver");
|
||||
@@ -59,8 +60,8 @@ class DriverClassNameProvider {
|
||||
*/
|
||||
String getDriverClassName(final String jdbcUrl) {
|
||||
Assert.notNull(jdbcUrl, "JdbcUrl must not be null");
|
||||
Assert.isTrue(jdbcUrl.startsWith(JDBC_URL_PREFIX), "JdbcUrl must start with '"
|
||||
+ JDBC_URL_PREFIX + "'");
|
||||
Assert.isTrue(jdbcUrl.startsWith(JDBC_URL_PREFIX),
|
||||
"JdbcUrl must start with '" + JDBC_URL_PREFIX + "'");
|
||||
String urlWithoutPrefix = jdbcUrl.substring(JDBC_URL_PREFIX.length());
|
||||
for (Map.Entry<String, String> driver : DRIVERS.entrySet()) {
|
||||
if (urlWithoutPrefix.startsWith(":" + driver.getKey() + ":")) {
|
||||
|
||||
@@ -107,10 +107,9 @@ public enum EmbeddedDatabaseConnection {
|
||||
* @return true if the driver class is one of the embedded types
|
||||
*/
|
||||
public static boolean isEmbedded(String driverClass) {
|
||||
return driverClass != null
|
||||
&& (driverClass.equals(HSQL.driverClass)
|
||||
|| driverClass.equals(H2.driverClass) || driverClass
|
||||
.equals(DERBY.driverClass));
|
||||
return driverClass != null && (driverClass.equals(HSQL.driverClass)
|
||||
|| driverClass.equals(H2.driverClass)
|
||||
|| driverClass.equals(DERBY.driverClass));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -141,8 +140,8 @@ public enum EmbeddedDatabaseConnection {
|
||||
return override;
|
||||
}
|
||||
for (EmbeddedDatabaseConnection candidate : EmbeddedDatabaseConnection.values()) {
|
||||
if (candidate != NONE
|
||||
&& ClassUtils.isPresent(candidate.getDriverClassName(), classLoader)) {
|
||||
if (candidate != NONE && ClassUtils.isPresent(candidate.getDriverClassName(),
|
||||
classLoader)) {
|
||||
return candidate;
|
||||
}
|
||||
}
|
||||
@@ -155,8 +154,8 @@ public enum EmbeddedDatabaseConnection {
|
||||
private static class IsEmbedded implements ConnectionCallback<Boolean> {
|
||||
|
||||
@Override
|
||||
public Boolean doInConnection(Connection connection) throws SQLException,
|
||||
DataAccessException {
|
||||
public Boolean doInConnection(Connection connection)
|
||||
throws SQLException, DataAccessException {
|
||||
String productName = connection.getMetaData().getDatabaseProductName();
|
||||
if (productName == null) {
|
||||
return false;
|
||||
|
||||
@@ -25,8 +25,8 @@ import javax.sql.DataSource;
|
||||
* @author Stephane Nicoll
|
||||
* @since 1.2.0
|
||||
*/
|
||||
public abstract class AbstractDataSourcePoolMetadata<T extends DataSource> implements
|
||||
DataSourcePoolMetadata {
|
||||
public abstract class AbstractDataSourcePoolMetadata<T extends DataSource>
|
||||
implements DataSourcePoolMetadata {
|
||||
|
||||
private final T dataSource;
|
||||
|
||||
|
||||
@@ -26,8 +26,8 @@ import org.apache.commons.dbcp.BasicDataSource;
|
||||
* @author Stephane Nicoll
|
||||
* @since 1.2.0
|
||||
*/
|
||||
public class CommonsDbcpDataSourcePoolMetadata extends
|
||||
AbstractDataSourcePoolMetadata<BasicDataSource> {
|
||||
public class CommonsDbcpDataSourcePoolMetadata
|
||||
extends AbstractDataSourcePoolMetadata<BasicDataSource> {
|
||||
|
||||
public CommonsDbcpDataSourcePoolMetadata(BasicDataSource dataSource) {
|
||||
super(dataSource);
|
||||
|
||||
@@ -33,7 +33,8 @@ public interface DataSourcePoolMetadata {
|
||||
* <ul>
|
||||
* <li>1 means that the maximum number of connections have been allocated</li>
|
||||
* <li>0 means that no connection is currently active</li>
|
||||
* <li>-1 means there is not limit to the number of connections that can be allocated</li>
|
||||
* <li>-1 means there is not limit to the number of connections that can be allocated
|
||||
* </li>
|
||||
* </ul>
|
||||
* This may also return {@code null} if the data source does not provide the necessary
|
||||
* information to compute the poll usage.
|
||||
|
||||
@@ -29,8 +29,8 @@ import com.zaxxer.hikari.pool.HikariPool;
|
||||
* @author Stephane Nicoll
|
||||
* @since 1.2.0
|
||||
*/
|
||||
public class HikariDataSourcePoolMetadata extends
|
||||
AbstractDataSourcePoolMetadata<HikariDataSource> {
|
||||
public class HikariDataSourcePoolMetadata
|
||||
extends AbstractDataSourcePoolMetadata<HikariDataSource> {
|
||||
|
||||
public HikariDataSourcePoolMetadata(HikariDataSource dataSource) {
|
||||
super(dataSource);
|
||||
|
||||
@@ -24,8 +24,8 @@ import org.apache.tomcat.jdbc.pool.DataSource;
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
public class TomcatDataSourcePoolMetadata extends
|
||||
AbstractDataSourcePoolMetadata<DataSource> {
|
||||
public class TomcatDataSourcePoolMetadata
|
||||
extends AbstractDataSourcePoolMetadata<DataSource> {
|
||||
|
||||
public TomcatDataSourcePoolMetadata(DataSource dataSource) {
|
||||
super(dataSource);
|
||||
|
||||
@@ -57,8 +57,7 @@ import org.springframework.web.filter.RequestContextFilter;
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
@Configuration
|
||||
@ConditionalOnClass(name = {
|
||||
"org.glassfish.jersey.server.spring.SpringComponentProvider",
|
||||
@ConditionalOnClass(name = { "org.glassfish.jersey.server.spring.SpringComponentProvider",
|
||||
"javax.servlet.ServletRegistration" })
|
||||
@ConditionalOnBean(type = "org.glassfish.jersey.server.ResourceConfig")
|
||||
@ConditionalOnWebApplication
|
||||
|
||||
@@ -53,7 +53,8 @@ import org.springframework.util.StringUtils;
|
||||
public class JndiConnectionFactoryAutoConfiguration {
|
||||
|
||||
// Keep these in sync with the condition below
|
||||
private static String[] JNDI_LOCATIONS = { "java:/JmsXA", "java:/XAConnectionFactory" };
|
||||
private static String[] JNDI_LOCATIONS = { "java:/JmsXA",
|
||||
"java:/XAConnectionFactory" };
|
||||
|
||||
@Autowired
|
||||
private JmsProperties properties;
|
||||
|
||||
@@ -46,8 +46,8 @@ class ActiveMQConnectionFactoryFactory {
|
||||
return doCreateConnectionFactory(factoryClass);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
throw new IllegalStateException("Unable to create "
|
||||
+ "ActiveMQConnectionFactory", ex);
|
||||
throw new IllegalStateException(
|
||||
"Unable to create " + "ActiveMQConnectionFactory", ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -62,8 +62,8 @@ class HornetQConnectionFactoryFactory {
|
||||
return doCreateConnectionFactory(factoryClass);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
throw new IllegalStateException("Unable to create "
|
||||
+ "HornetQConnectionFactory", ex);
|
||||
throw new IllegalStateException(
|
||||
"Unable to create " + "HornetQConnectionFactory", ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,12 +106,12 @@ class HornetQConnectionFactoryFactory {
|
||||
Class<T> factoryClass) throws Exception {
|
||||
try {
|
||||
TransportConfiguration transportConfiguration = new TransportConfiguration(
|
||||
InVMConnectorFactory.class.getName(), this.properties.getEmbedded()
|
||||
.generateTransportParameters());
|
||||
InVMConnectorFactory.class.getName(),
|
||||
this.properties.getEmbedded().generateTransportParameters());
|
||||
ServerLocator serviceLocator = HornetQClient
|
||||
.createServerLocatorWithoutHA(transportConfiguration);
|
||||
return factoryClass.getConstructor(ServerLocator.class).newInstance(
|
||||
serviceLocator);
|
||||
return factoryClass.getConstructor(ServerLocator.class)
|
||||
.newInstance(serviceLocator);
|
||||
}
|
||||
catch (NoClassDefFoundError ex) {
|
||||
throw new IllegalStateException("Unable to create InVM "
|
||||
|
||||
@@ -106,16 +106,15 @@ class HornetQEmbeddedServerConfiguration {
|
||||
private void addQueues(JMSConfiguration configuration, String[] queues) {
|
||||
boolean persistent = this.properties.getEmbedded().isPersistent();
|
||||
for (String queue : queues) {
|
||||
configuration.getQueueConfigurations().add(
|
||||
new JMSQueueConfigurationImpl(queue, null, persistent, "/queue/"
|
||||
+ queue));
|
||||
configuration.getQueueConfigurations().add(new JMSQueueConfigurationImpl(
|
||||
queue, null, persistent, "/queue/" + queue));
|
||||
}
|
||||
}
|
||||
|
||||
private void addTopics(JMSConfiguration configuration, String[] topics) {
|
||||
for (String topic : topics) {
|
||||
configuration.getTopicConfigurations().add(
|
||||
new TopicConfigurationImpl(topic, "/topic/" + topic));
|
||||
configuration.getTopicConfigurations()
|
||||
.add(new TopicConfigurationImpl(topic, "/topic/" + topic));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -46,10 +46,10 @@ class HornetQXAConnectionFactoryConfiguration {
|
||||
@Bean(name = { "jmsConnectionFactory", "xaJmsConnectionFactory" })
|
||||
public ConnectionFactory jmsConnectionFactory(ListableBeanFactory beanFactory,
|
||||
HornetQProperties properties, XAConnectionFactoryWrapper wrapper)
|
||||
throws Exception {
|
||||
return wrapper.wrapConnectionFactory(new HornetQConnectionFactoryFactory(
|
||||
beanFactory, properties)
|
||||
.createConnectionFactory(HornetQXAConnectionFactory.class));
|
||||
throws Exception {
|
||||
return wrapper.wrapConnectionFactory(
|
||||
new HornetQConnectionFactoryFactory(beanFactory, properties)
|
||||
.createConnectionFactory(HornetQXAConnectionFactory.class));
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
||||
@@ -36,8 +36,8 @@ import org.springframework.util.ObjectUtils;
|
||||
* @author Dave Syer
|
||||
* @since 1.1.1
|
||||
*/
|
||||
public class ParentAwareNamingStrategy extends MetadataNamingStrategy implements
|
||||
ApplicationContextAware {
|
||||
public class ParentAwareNamingStrategy extends MetadataNamingStrategy
|
||||
implements ApplicationContextAware {
|
||||
|
||||
private ApplicationContext applicationContext;
|
||||
|
||||
@@ -51,7 +51,8 @@ public class ParentAwareNamingStrategy extends MetadataNamingStrategy implements
|
||||
* Set if unique runtime object names should be ensured.
|
||||
* @param ensureUniqueRuntimeObjectNames {@code true} if unique names should ensured.
|
||||
*/
|
||||
public void setEnsureUniqueRuntimeObjectNames(boolean ensureUniqueRuntimeObjectNames) {
|
||||
public void setEnsureUniqueRuntimeObjectNames(
|
||||
boolean ensureUniqueRuntimeObjectNames) {
|
||||
this.ensureUniqueRuntimeObjectNames = ensureUniqueRuntimeObjectNames;
|
||||
}
|
||||
|
||||
|
||||
@@ -80,15 +80,16 @@ public class LiquibaseAutoConfiguration {
|
||||
@PostConstruct
|
||||
public void checkChangelogExists() {
|
||||
if (this.properties.isCheckChangeLogLocation()) {
|
||||
Resource resource = this.resourceLoader.getResource(this.properties
|
||||
.getChangeLog());
|
||||
Assert.state(resource.exists(), "Cannot find changelog location: "
|
||||
+ resource + " (please add changelog or check your Liquibase "
|
||||
+ "configuration)");
|
||||
Resource resource = this.resourceLoader
|
||||
.getResource(this.properties.getChangeLog());
|
||||
Assert.state(resource.exists(),
|
||||
"Cannot find changelog location: " + resource
|
||||
+ " (please add changelog or check your Liquibase "
|
||||
+ "configuration)");
|
||||
}
|
||||
ServiceLocator serviceLocator = ServiceLocator.getInstance();
|
||||
serviceLocator.addPackageToScan(CommonsLoggingLiquibaseLogger.class
|
||||
.getPackage().getName());
|
||||
serviceLocator.addPackageToScan(
|
||||
CommonsLoggingLiquibaseLogger.class.getPackage().getName());
|
||||
}
|
||||
|
||||
@Bean
|
||||
@@ -122,8 +123,8 @@ public class LiquibaseAutoConfiguration {
|
||||
@Configuration
|
||||
@ConditionalOnClass(LocalContainerEntityManagerFactoryBean.class)
|
||||
@ConditionalOnBean(AbstractEntityManagerFactoryBean.class)
|
||||
protected static class LiquibaseJpaDependencyConfiguration extends
|
||||
EntityManagerFactoryDependsOnPostProcessor {
|
||||
protected static class LiquibaseJpaDependencyConfiguration
|
||||
extends EntityManagerFactoryDependsOnPostProcessor {
|
||||
|
||||
public LiquibaseJpaDependencyConfiguration() {
|
||||
super("liquibase");
|
||||
|
||||
@@ -116,8 +116,8 @@ public class DeviceDelegatingViewResolverAutoConfiguration {
|
||||
@EnableConfigurationProperties(DeviceDelegatingViewResolverProperties.class)
|
||||
@ConditionalOnMissingBean(name = "thymeleafViewResolver")
|
||||
@ConditionalOnBean(InternalResourceViewResolver.class)
|
||||
protected static class InternalResourceViewResolverDelegateConfiguration extends
|
||||
AbstractDelegateConfiguration {
|
||||
protected static class InternalResourceViewResolverDelegateConfiguration
|
||||
extends AbstractDelegateConfiguration {
|
||||
|
||||
@Autowired
|
||||
private InternalResourceViewResolver viewResolver;
|
||||
|
||||
@@ -48,7 +48,8 @@ public class DeviceResolverAutoConfiguration {
|
||||
|
||||
@Configuration
|
||||
@ConditionalOnWebApplication
|
||||
protected static class DeviceResolverMvcConfiguration extends WebMvcConfigurerAdapter {
|
||||
protected static class DeviceResolverMvcConfiguration
|
||||
extends WebMvcConfigurerAdapter {
|
||||
|
||||
@Autowired
|
||||
private DeviceResolverHandlerInterceptor deviceResolverHandlerInterceptor;
|
||||
|
||||
@@ -52,7 +52,8 @@ public class SitePreferenceAutoConfiguration {
|
||||
|
||||
@Configuration
|
||||
@ConditionalOnWebApplication
|
||||
protected static class SitePreferenceMvcConfiguration extends WebMvcConfigurerAdapter {
|
||||
protected static class SitePreferenceMvcConfiguration
|
||||
extends WebMvcConfigurerAdapter {
|
||||
|
||||
@Autowired
|
||||
private SitePreferenceHandlerInterceptor sitePreferenceHandlerInterceptor;
|
||||
|
||||
@@ -215,8 +215,8 @@ public class MongoProperties {
|
||||
}
|
||||
List<MongoCredential> credentials = null;
|
||||
if (hasCustomCredentials()) {
|
||||
String database = this.authenticationDatabase == null ? getMongoClientDatabase()
|
||||
: this.authenticationDatabase;
|
||||
String database = this.authenticationDatabase == null
|
||||
? getMongoClientDatabase() : this.authenticationDatabase;
|
||||
credentials = Arrays.asList(MongoCredential.createMongoCRCredential(
|
||||
this.username, database, this.password));
|
||||
}
|
||||
@@ -274,8 +274,8 @@ public class MongoProperties {
|
||||
builder.socketFactory(options.getSocketFactory());
|
||||
builder.socketKeepAlive(options.isSocketKeepAlive());
|
||||
builder.socketTimeout(options.getSocketTimeout());
|
||||
builder.threadsAllowedToBlockForConnectionMultiplier(options
|
||||
.getThreadsAllowedToBlockForConnectionMultiplier());
|
||||
builder.threadsAllowedToBlockForConnectionMultiplier(
|
||||
options.getThreadsAllowedToBlockForConnectionMultiplier());
|
||||
builder.writeConcern(options.getWriteConcern());
|
||||
}
|
||||
return builder;
|
||||
|
||||
@@ -36,8 +36,8 @@ import com.samskivert.mustache.Mustache.VariableFetcher;
|
||||
* @author Dave Syer
|
||||
* @since 1.2.2
|
||||
*/
|
||||
public class MustacheEnvironmentCollector extends DefaultCollector implements
|
||||
EnvironmentAware {
|
||||
public class MustacheEnvironmentCollector extends DefaultCollector
|
||||
implements EnvironmentAware {
|
||||
|
||||
private ConfigurableEnvironment environment;
|
||||
|
||||
@@ -51,8 +51,8 @@ public class MustacheEnvironmentCollector extends DefaultCollector implements
|
||||
public void setEnvironment(Environment environment) {
|
||||
this.environment = (ConfigurableEnvironment) environment;
|
||||
this.target = new HashMap<String, Object>();
|
||||
new RelaxedDataBinder(this.target).bind(new PropertySourcesPropertyValues(
|
||||
this.environment.getPropertySources()));
|
||||
new RelaxedDataBinder(this.target).bind(
|
||||
new PropertySourcesPropertyValues(this.environment.getPropertySources()));
|
||||
this.propertyResolver = new RelaxedPropertyResolver(environment);
|
||||
}
|
||||
|
||||
|
||||
@@ -38,8 +38,8 @@ import com.samskivert.mustache.Mustache.TemplateLoader;
|
||||
* @see Mustache
|
||||
* @see Resource
|
||||
*/
|
||||
public class MustacheResourceTemplateLoader implements TemplateLoader,
|
||||
ResourceLoaderAware {
|
||||
public class MustacheResourceTemplateLoader
|
||||
implements TemplateLoader, ResourceLoaderAware {
|
||||
|
||||
private String prefix = "";
|
||||
|
||||
@@ -77,8 +77,9 @@ public class MustacheResourceTemplateLoader implements TemplateLoader,
|
||||
|
||||
@Override
|
||||
public Reader getTemplate(String name) throws Exception {
|
||||
return new InputStreamReader(this.resourceLoader.getResource(
|
||||
this.prefix + name + this.suffix).getInputStream(), this.charSet);
|
||||
return new InputStreamReader(this.resourceLoader
|
||||
.getResource(this.prefix + name + this.suffix).getInputStream(),
|
||||
this.charSet);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -30,7 +30,8 @@ import org.springframework.util.ClassUtils;
|
||||
* @author Dave Syer
|
||||
* @since 1.2.2
|
||||
*/
|
||||
public class MustacheTemplateAvailabilityProvider implements TemplateAvailabilityProvider {
|
||||
public class MustacheTemplateAvailabilityProvider
|
||||
implements TemplateAvailabilityProvider {
|
||||
|
||||
@Override
|
||||
public boolean isTemplateAvailable(String view, Environment environment,
|
||||
|
||||
@@ -86,8 +86,8 @@ public class MustacheViewResolver extends UrlBasedViewResolver {
|
||||
}
|
||||
|
||||
private Resource resolveFromLocale(String viewName, String locale) {
|
||||
Resource resource = getApplicationContext().getResource(
|
||||
getPrefix() + viewName + locale + getSuffix());
|
||||
Resource resource = getApplicationContext()
|
||||
.getResource(getPrefix() + viewName + locale + getSuffix());
|
||||
if (resource == null || !resource.exists()) {
|
||||
if (locale.isEmpty()) {
|
||||
return null;
|
||||
|
||||
@@ -66,8 +66,8 @@ class DataSourceInitializedPublisher implements BeanPostProcessor {
|
||||
}
|
||||
if (bean instanceof EntityManagerFactory && this.dataSource != null
|
||||
&& isInitializingDatabase()) {
|
||||
this.applicationContext.publishEvent(new DataSourceInitializedEvent(
|
||||
this.dataSource));
|
||||
this.applicationContext
|
||||
.publishEvent(new DataSourceInitializedEvent(this.dataSource));
|
||||
}
|
||||
return bean;
|
||||
}
|
||||
|
||||
@@ -127,8 +127,9 @@ public class HibernateJpaAutoConfiguration extends JpaBaseConfiguration {
|
||||
}
|
||||
|
||||
private boolean runningOnWebSphere() {
|
||||
return ClassUtils.isPresent("com.ibm.websphere.jtaextensions."
|
||||
+ "ExtendedJTATransaction", getClass().getClassLoader());
|
||||
return ClassUtils.isPresent(
|
||||
"com.ibm.websphere.jtaextensions." + "ExtendedJTATransaction",
|
||||
getClass().getClassLoader());
|
||||
}
|
||||
|
||||
private void configureWebSphereTransactionPlatform(
|
||||
@@ -143,8 +144,8 @@ public class HibernateJpaAutoConfiguration extends JpaBaseConfiguration {
|
||||
private void configureSpringJtaPlatform(Map<String, Object> vendorProperties,
|
||||
JtaTransactionManager jtaTransactionManager) {
|
||||
try {
|
||||
vendorProperties.put(JTA_PLATFORM, new SpringJtaPlatform(
|
||||
jtaTransactionManager));
|
||||
vendorProperties.put(JTA_PLATFORM,
|
||||
new SpringJtaPlatform(jtaTransactionManager));
|
||||
}
|
||||
catch (LinkageError ex) {
|
||||
// NoClassDefFoundError can happen if Hibernate 4.2 is used and some
|
||||
|
||||
@@ -78,7 +78,8 @@ public class AuthenticationManagerConfiguration {
|
||||
|
||||
@Bean
|
||||
public static SpringBootAuthenticationConfigurerAdapter springBootAuthenticationConfigurerAdapter(
|
||||
SecurityProperties securityProperties, List<SecurityPrerequisite> dependencies) {
|
||||
SecurityProperties securityProperties,
|
||||
List<SecurityPrerequisite> dependencies) {
|
||||
return new SpringBootAuthenticationConfigurerAdapter(securityProperties);
|
||||
}
|
||||
|
||||
@@ -102,12 +103,13 @@ public class AuthenticationManagerConfiguration {
|
||||
* {@link AuthenticationManagerBuilder#authenticationProvider(AuthenticationProvider)}
|
||||
* method since all other methods add a {@link SecurityConfigurer} which is not
|
||||
* allowed in the configure stage. It is not allowed because we guarantee all init
|
||||
* methods are invoked before configure, which cannot be guaranteed at this point.</li>
|
||||
* methods are invoked before configure, which cannot be guaranteed at this point.
|
||||
* </li>
|
||||
* </ul>
|
||||
*/
|
||||
@Order(Ordered.LOWEST_PRECEDENCE - 100)
|
||||
private static class SpringBootAuthenticationConfigurerAdapter extends
|
||||
GlobalAuthenticationConfigurerAdapter {
|
||||
private static class SpringBootAuthenticationConfigurerAdapter
|
||||
extends GlobalAuthenticationConfigurerAdapter {
|
||||
|
||||
private final SecurityProperties securityProperties;
|
||||
|
||||
@@ -145,8 +147,8 @@ public class AuthenticationManagerConfiguration {
|
||||
* {@link DefaultInMemoryUserDetailsManagerConfigurer} will default the value.</li>
|
||||
* </ul>
|
||||
*/
|
||||
private static class DefaultInMemoryUserDetailsManagerConfigurer extends
|
||||
InMemoryUserDetailsManagerConfigurer<AuthenticationManagerBuilder> {
|
||||
private static class DefaultInMemoryUserDetailsManagerConfigurer
|
||||
extends InMemoryUserDetailsManagerConfigurer<AuthenticationManagerBuilder> {
|
||||
|
||||
private final SecurityProperties securityProperties;
|
||||
|
||||
@@ -165,8 +167,8 @@ public class AuthenticationManagerConfiguration {
|
||||
+ "\n");
|
||||
}
|
||||
Set<String> roles = new LinkedHashSet<String>(user.getRole());
|
||||
withUser(user.getName()).password(user.getPassword()).roles(
|
||||
roles.toArray(new String[roles.size()]));
|
||||
withUser(user.getName()).password(user.getPassword())
|
||||
.roles(roles.toArray(new String[roles.size()]));
|
||||
setField(auth, "defaultUserDetailsService", getUserDetailsService());
|
||||
super.configure(auth);
|
||||
}
|
||||
@@ -189,8 +191,8 @@ public class AuthenticationManagerConfiguration {
|
||||
* into the {@link AuthenticationManager}.
|
||||
*/
|
||||
@Component
|
||||
protected static class AuthenticationManagerConfigurationListener implements
|
||||
SmartInitializingSingleton {
|
||||
protected static class AuthenticationManagerConfigurationListener
|
||||
implements SmartInitializingSingleton {
|
||||
|
||||
@Autowired
|
||||
private AuthenticationEventPublisher eventPublisher;
|
||||
@@ -201,8 +203,8 @@ public class AuthenticationManagerConfiguration {
|
||||
@Override
|
||||
public void afterSingletonsInstantiated() {
|
||||
try {
|
||||
configureAuthenticationManager(this.context
|
||||
.getBean(AuthenticationManager.class));
|
||||
configureAuthenticationManager(
|
||||
this.context.getBean(AuthenticationManager.class));
|
||||
}
|
||||
catch (NoSuchBeanDefinitionException ex) {
|
||||
// Ignore
|
||||
|
||||
@@ -56,8 +56,8 @@ public class BootGlobalAuthenticationConfiguration {
|
||||
return new BootGlobalAuthenticationConfigurationAdapter(context);
|
||||
}
|
||||
|
||||
private static class BootGlobalAuthenticationConfigurationAdapter extends
|
||||
GlobalAuthenticationConfigurerAdapter {
|
||||
private static class BootGlobalAuthenticationConfigurationAdapter
|
||||
extends GlobalAuthenticationConfigurerAdapter {
|
||||
|
||||
private static Log logger = LogFactory
|
||||
.getLog(BootGlobalAuthenticationConfiguration.class);
|
||||
|
||||
@@ -40,7 +40,8 @@ public class SecurityProperties implements SecurityPrerequisite {
|
||||
* useful place to put user-defined access rules if you want to override the default
|
||||
* access rules.
|
||||
*/
|
||||
public static final int ACCESS_OVERRIDE_ORDER = SecurityProperties.BASIC_AUTH_ORDER - 2;
|
||||
public static final int ACCESS_OVERRIDE_ORDER = SecurityProperties.BASIC_AUTH_ORDER
|
||||
- 2;
|
||||
|
||||
/**
|
||||
* Order applied to the WebSecurityConfigurerAdapter that is used to configure basic
|
||||
|
||||
@@ -128,8 +128,8 @@ public class SpringBootWebSecurityConfiguration {
|
||||
|
||||
// Get the ignored paths in early
|
||||
@Order(SecurityProperties.IGNORED_ORDER)
|
||||
private static class IgnoredPathsWebSecurityConfigurerAdapter implements
|
||||
WebSecurityConfigurer<WebSecurity> {
|
||||
private static class IgnoredPathsWebSecurityConfigurerAdapter
|
||||
implements WebSecurityConfigurer<WebSecurity> {
|
||||
|
||||
@Autowired(required = false)
|
||||
private ErrorController errorController;
|
||||
@@ -168,8 +168,8 @@ public class SpringBootWebSecurityConfiguration {
|
||||
@Configuration
|
||||
@ConditionalOnProperty(prefix = "security.basic", name = "enabled", havingValue = "false")
|
||||
@Order(SecurityProperties.BASIC_AUTH_ORDER)
|
||||
protected static class ApplicationNoWebSecurityConfigurerAdapter extends
|
||||
WebSecurityConfigurerAdapter {
|
||||
protected static class ApplicationNoWebSecurityConfigurerAdapter
|
||||
extends WebSecurityConfigurerAdapter {
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
http.requestMatcher(new RequestMatcher() {
|
||||
@@ -184,8 +184,8 @@ public class SpringBootWebSecurityConfiguration {
|
||||
@Configuration
|
||||
@ConditionalOnProperty(prefix = "security.basic", name = "enabled", matchIfMissing = true)
|
||||
@Order(SecurityProperties.BASIC_AUTH_ORDER)
|
||||
protected static class ApplicationWebSecurityConfigurerAdapter extends
|
||||
WebSecurityConfigurerAdapter {
|
||||
protected static class ApplicationWebSecurityConfigurerAdapter
|
||||
extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Autowired
|
||||
private SecurityProperties security;
|
||||
|
||||
@@ -70,7 +70,8 @@ public class SocialWebAutoConfiguration {
|
||||
@Configuration
|
||||
@EnableSocial
|
||||
@ConditionalOnWebApplication
|
||||
protected static class SocialAutoConfigurationAdapter extends SocialConfigurerAdapter {
|
||||
protected static class SocialAutoConfigurationAdapter
|
||||
extends SocialConfigurerAdapter {
|
||||
|
||||
@Autowired(required = false)
|
||||
private List<ConnectInterceptor<?>> connectInterceptors;
|
||||
@@ -84,7 +85,8 @@ public class SocialWebAutoConfiguration {
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(ConnectController.class)
|
||||
public ConnectController connectController(
|
||||
ConnectionFactoryLocator factoryLocator, ConnectionRepository repository) {
|
||||
ConnectionFactoryLocator factoryLocator,
|
||||
ConnectionRepository repository) {
|
||||
ConnectController controller = new ConnectController(factoryLocator,
|
||||
repository);
|
||||
if (!CollectionUtils.isEmpty(this.connectInterceptors)) {
|
||||
@@ -142,8 +144,8 @@ public class SocialWebAutoConfiguration {
|
||||
@EnableSocial
|
||||
@ConditionalOnWebApplication
|
||||
@ConditionalOnClass(SecurityContextHolder.class)
|
||||
protected static class AuthenticationUserIdSourceConfig extends
|
||||
SocialConfigurerAdapter {
|
||||
protected static class AuthenticationUserIdSourceConfig
|
||||
extends SocialConfigurerAdapter {
|
||||
|
||||
@Override
|
||||
public UserIdSource getUserIdSource() {
|
||||
@@ -170,8 +172,8 @@ public class SocialWebAutoConfiguration {
|
||||
public String getUserId() {
|
||||
SecurityContext context = SecurityContextHolder.getContext();
|
||||
Authentication authentication = context.getAuthentication();
|
||||
Assert.state(authentication != null, "Unable to get a "
|
||||
+ "ConnectionRepository: no user signed in");
|
||||
Assert.state(authentication != null,
|
||||
"Unable to get a " + "ConnectionRepository: no user signed in");
|
||||
return authentication.getName();
|
||||
}
|
||||
|
||||
|
||||
@@ -28,8 +28,8 @@ import org.springframework.web.servlet.view.AbstractTemplateViewResolver;
|
||||
* @author Andy Wilkinson
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public abstract class AbstractTemplateViewResolverProperties extends
|
||||
AbstractViewResolverProperties {
|
||||
public abstract class AbstractTemplateViewResolverProperties
|
||||
extends AbstractViewResolverProperties {
|
||||
|
||||
/**
|
||||
* Prefix that gets prepended to view names when building a URL.
|
||||
|
||||
@@ -30,8 +30,8 @@ import org.springframework.util.ClassUtils;
|
||||
* @author Andy Wilkinson
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public class ThymeleafTemplateAvailabilityProvider implements
|
||||
TemplateAvailabilityProvider {
|
||||
public class ThymeleafTemplateAvailabilityProvider
|
||||
implements TemplateAvailabilityProvider {
|
||||
|
||||
@Override
|
||||
public boolean isTemplateAvailable(String view, Environment environment,
|
||||
|
||||
@@ -101,7 +101,8 @@ class BitronixJtaConfiguration {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public JtaTransactionManager transactionManager(TransactionManager transactionManager) {
|
||||
public JtaTransactionManager transactionManager(
|
||||
TransactionManager transactionManager) {
|
||||
return new JtaTransactionManager(transactionManager);
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,8 @@ import org.springframework.util.ClassUtils;
|
||||
* @author Andy Wilkinson
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public class VelocityTemplateAvailabilityProvider implements TemplateAvailabilityProvider {
|
||||
public class VelocityTemplateAvailabilityProvider
|
||||
implements TemplateAvailabilityProvider {
|
||||
|
||||
@Override
|
||||
public boolean isTemplateAvailable(String view, Environment environment,
|
||||
|
||||
@@ -56,8 +56,8 @@ import org.springframework.web.servlet.ModelAndView;
|
||||
* @see ErrorAttributes
|
||||
*/
|
||||
@Order(Ordered.HIGHEST_PRECEDENCE)
|
||||
public class DefaultErrorAttributes implements ErrorAttributes, HandlerExceptionResolver,
|
||||
Ordered {
|
||||
public class DefaultErrorAttributes
|
||||
implements ErrorAttributes, HandlerExceptionResolver, Ordered {
|
||||
|
||||
private static final String ERROR_ATTRIBUTE = DefaultErrorAttributes.class.getName()
|
||||
+ ".ERROR";
|
||||
|
||||
@@ -83,7 +83,8 @@ public class EmbeddedServletContainerAutoConfiguration {
|
||||
* Nested configuration if Jetty is being used.
|
||||
*/
|
||||
@Configuration
|
||||
@ConditionalOnClass({ Servlet.class, Server.class, Loader.class, WebAppContext.class })
|
||||
@ConditionalOnClass({ Servlet.class, Server.class, Loader.class,
|
||||
WebAppContext.class })
|
||||
@ConditionalOnMissingBean(value = EmbeddedServletContainerFactory.class, search = SearchStrategy.CURRENT)
|
||||
public static class EmbeddedJetty {
|
||||
|
||||
|
||||
@@ -52,6 +52,7 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupp
|
||||
public class HttpMessageConverters implements Iterable<HttpMessageConverter<?>> {
|
||||
|
||||
private static final List<Class<?>> NON_REPLACING_CONVERTERS;
|
||||
|
||||
static {
|
||||
List<Class<?>> nonReplacingConverters = new ArrayList<Class<?>>();
|
||||
addClassIfExists(nonReplacingConverters, "org.springframework.hateoas.mvc."
|
||||
@@ -81,7 +82,8 @@ public class HttpMessageConverters implements Iterable<HttpMessageConverter<?>>
|
||||
* default converter is found) The {@link #postProcessConverters(List)} method can be
|
||||
* used for further converter manipulation.
|
||||
*/
|
||||
public HttpMessageConverters(Collection<HttpMessageConverter<?>> additionalConverters) {
|
||||
public HttpMessageConverters(
|
||||
Collection<HttpMessageConverter<?>> additionalConverters) {
|
||||
this(true, additionalConverters);
|
||||
}
|
||||
|
||||
|
||||
@@ -30,13 +30,11 @@ import org.springframework.util.StringUtils;
|
||||
* be obtained.</li>
|
||||
* <li>{@literal multipart.maxFileSize} specifies the maximum size permitted for uploaded
|
||||
* files. The default is 1Mb.</li>
|
||||
* <li>
|
||||
* {@literal multipart.maxRequestSize} specifies the maximum size allowed for
|
||||
* <li>{@literal multipart.maxRequestSize} specifies the maximum size allowed for
|
||||
* {@literal multipart/form-data} requests. The default is 10Mb</li>
|
||||
* <li>
|
||||
* {@literal multipart.fileSizeThreshold} specifies the size threshold after which files
|
||||
* will be written to disk. Default is 0, which means that the file will be written to
|
||||
* disk immediately.</li>
|
||||
* <li>{@literal multipart.fileSizeThreshold} specifies the size threshold after which
|
||||
* files will be written to disk. Default is 0, which means that the file will be written
|
||||
* to disk immediately.</li>
|
||||
* </ul>
|
||||
* <p>
|
||||
* These properties are ultimately passed through
|
||||
|
||||
@@ -31,8 +31,8 @@ import org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletConta
|
||||
* @author Andy Wilkinson
|
||||
* @since 1.2.0
|
||||
*/
|
||||
public class JettyWebSocketContainerCustomizer extends
|
||||
WebSocketContainerCustomizer<JettyEmbeddedServletContainerFactory> {
|
||||
public class JettyWebSocketContainerCustomizer
|
||||
extends WebSocketContainerCustomizer<JettyEmbeddedServletContainerFactory> {
|
||||
|
||||
@Override
|
||||
protected void doCustomize(JettyEmbeddedServletContainerFactory container) {
|
||||
|
||||
@@ -33,8 +33,8 @@ import org.springframework.util.ReflectionUtils;
|
||||
* @author Andy Wilkinson
|
||||
* @since 1.2.0
|
||||
*/
|
||||
public class TomcatWebSocketContainerCustomizer extends
|
||||
WebSocketContainerCustomizer<TomcatEmbeddedServletContainerFactory> {
|
||||
public class TomcatWebSocketContainerCustomizer
|
||||
extends WebSocketContainerCustomizer<TomcatEmbeddedServletContainerFactory> {
|
||||
|
||||
private static final String TOMCAT_7_LISTENER_TYPE = "org.apache.catalina.deploy.ApplicationListener";
|
||||
|
||||
@@ -79,8 +79,8 @@ public class TomcatWebSocketContainerCustomizer extends
|
||||
|
||||
}
|
||||
else {
|
||||
Constructor<?> constructor = ClassUtils.getConstructorIfAvailable(
|
||||
listenerType, String.class, boolean.class);
|
||||
Constructor<?> constructor = ClassUtils
|
||||
.getConstructorIfAvailable(listenerType, String.class, boolean.class);
|
||||
Object instance = BeanUtils.instantiateClass(constructor, WS_LISTENER, false);
|
||||
ReflectionUtils.invokeMethod(ClassUtils.getMethod(contextClass,
|
||||
"addApplicationListener", listenerType), context, instance);
|
||||
|
||||
@@ -29,8 +29,8 @@ import io.undertow.websockets.jsr.WebSocketDeploymentInfo;
|
||||
* @author Phillip Webb
|
||||
* @since 1.2.0
|
||||
*/
|
||||
public class UndertowWebSocketContainerCustomizer extends
|
||||
WebSocketContainerCustomizer<UndertowEmbeddedServletContainerFactory> {
|
||||
public class UndertowWebSocketContainerCustomizer
|
||||
extends WebSocketContainerCustomizer<UndertowEmbeddedServletContainerFactory> {
|
||||
|
||||
@Override
|
||||
protected void doCustomize(UndertowEmbeddedServletContainerFactory container) {
|
||||
@@ -38,8 +38,8 @@ public class UndertowWebSocketContainerCustomizer extends
|
||||
container.addDeploymentInfoCustomizers(customizer);
|
||||
}
|
||||
|
||||
private static class WebsocketDeploymentInfoCustomizer implements
|
||||
UndertowDeploymentInfoCustomizer {
|
||||
private static class WebsocketDeploymentInfoCustomizer
|
||||
implements UndertowDeploymentInfoCustomizer {
|
||||
|
||||
@Override
|
||||
public void customize(DeploymentInfo deploymentInfo) {
|
||||
|
||||
@@ -59,8 +59,8 @@ public class AutoConfigurationPackagesTests {
|
||||
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(
|
||||
EmptyConfig.class);
|
||||
this.thrown.expect(IllegalStateException.class);
|
||||
this.thrown
|
||||
.expectMessage("Unable to retrieve @EnableAutoConfiguration base packages");
|
||||
this.thrown.expectMessage(
|
||||
"Unable to retrieve @EnableAutoConfiguration base packages");
|
||||
AutoConfigurationPackages.get(context.getBeanFactory());
|
||||
}
|
||||
|
||||
|
||||
@@ -65,8 +65,8 @@ public class AutoConfigurationSorterTests {
|
||||
|
||||
@Test
|
||||
public void byOrderAnnotation() throws Exception {
|
||||
List<String> actual = this.sorter.getInPriorityOrder(Arrays.asList(LOWEST,
|
||||
HIGHEST));
|
||||
List<String> actual = this.sorter
|
||||
.getInPriorityOrder(Arrays.asList(LOWEST, HIGHEST));
|
||||
assertThat(actual, nameMatcher(HIGHEST, LOWEST));
|
||||
}
|
||||
|
||||
@@ -97,8 +97,8 @@ public class AutoConfigurationSorterTests {
|
||||
|
||||
@Test
|
||||
public void byAutoConfigureMixedBeforeAndAfterWithClassNames() throws Exception {
|
||||
List<String> actual = this.sorter.getInPriorityOrder(Arrays.asList(A2, B, C, W2,
|
||||
X));
|
||||
List<String> actual = this.sorter
|
||||
.getInPriorityOrder(Arrays.asList(A2, B, C, W2, X));
|
||||
assertThat(actual, nameMatcher(C, W2, B, A2, X));
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ import org.springframework.boot.test.AbstractConfigurationClassTests;
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
public class AutoConfigureConfigurationClassTests extends AbstractConfigurationClassTests {
|
||||
public class AutoConfigureConfigurationClassTests
|
||||
extends AbstractConfigurationClassTests {
|
||||
|
||||
}
|
||||
|
||||
@@ -80,8 +80,8 @@ public class PropertyPlaceholderAutoConfigurationTests {
|
||||
@Bean
|
||||
public static PropertySourcesPlaceholderConfigurer morePlaceholders() {
|
||||
PropertySourcesPlaceholderConfigurer configurer = new PropertySourcesPlaceholderConfigurer();
|
||||
configurer.setProperties(StringUtils.splitArrayElementsIntoProperties(
|
||||
new String[] { "foo=spam" }, "="));
|
||||
configurer.setProperties(StringUtils
|
||||
.splitArrayElementsIntoProperties(new String[] { "foo=spam" }, "="));
|
||||
configurer.setLocalOverride(true);
|
||||
configurer.setOrder(0);
|
||||
return configurer;
|
||||
|
||||
@@ -30,15 +30,15 @@ import org.springframework.util.ClassUtils;
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
@Order(Ordered.HIGHEST_PRECEDENCE)
|
||||
public class TestAutoConfigurationPackageRegistrar implements
|
||||
ImportBeanDefinitionRegistrar {
|
||||
public class TestAutoConfigurationPackageRegistrar
|
||||
implements ImportBeanDefinitionRegistrar {
|
||||
|
||||
@Override
|
||||
public void registerBeanDefinitions(AnnotationMetadata metadata,
|
||||
BeanDefinitionRegistry registry) {
|
||||
AnnotationAttributes attributes = AnnotationAttributes.fromMap(metadata
|
||||
.getAnnotationAttributes(TestAutoConfigurationPackage.class.getName(),
|
||||
true));
|
||||
AnnotationAttributes attributes = AnnotationAttributes
|
||||
.fromMap(metadata.getAnnotationAttributes(
|
||||
TestAutoConfigurationPackage.class.getName(), true));
|
||||
AutoConfigurationPackages.register(registry,
|
||||
ClassUtils.getPackageName(attributes.getString("value")));
|
||||
}
|
||||
|
||||
@@ -210,8 +210,10 @@ public class RabbitAutoConfigurationTests {
|
||||
public void enableRabbitAutomatically() throws Exception {
|
||||
load(NoEnableRabbitConfiguration.class);
|
||||
AnnotationConfigApplicationContext ctx = this.context;
|
||||
ctx.getBean(RabbitListenerConfigUtils.RABBIT_LISTENER_ANNOTATION_PROCESSOR_BEAN_NAME);
|
||||
ctx.getBean(RabbitListenerConfigUtils.RABBIT_LISTENER_ENDPOINT_REGISTRY_BEAN_NAME);
|
||||
ctx.getBean(
|
||||
RabbitListenerConfigUtils.RABBIT_LISTENER_ANNOTATION_PROCESSOR_BEAN_NAME);
|
||||
ctx.getBean(
|
||||
RabbitListenerConfigUtils.RABBIT_LISTENER_ENDPOINT_REGISTRY_BEAN_NAME);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -100,8 +100,8 @@ public class BatchAutoConfigurationTests {
|
||||
@Test
|
||||
public void testNoDatabase() throws Exception {
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
this.context.register(TestCustomConfiguration.class,
|
||||
BatchAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class);
|
||||
this.context.register(TestCustomConfiguration.class, BatchAutoConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
assertNotNull(this.context.getBean(JobLauncher.class));
|
||||
JobExplorer explorer = this.context.getBean(JobExplorer.class);
|
||||
@@ -129,8 +129,8 @@ public class BatchAutoConfigurationTests {
|
||||
this.context.refresh();
|
||||
assertNotNull(this.context.getBean(JobLauncher.class));
|
||||
this.context.getBean(JobLauncherCommandLineRunner.class).run();
|
||||
assertNotNull(this.context.getBean(JobRepository.class).getLastJobExecution(
|
||||
"job", new JobParameters()));
|
||||
assertNotNull(this.context.getBean(JobRepository.class).getLastJobExecution("job",
|
||||
new JobParameters()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -160,8 +160,8 @@ public class BatchAutoConfigurationTests {
|
||||
this.context.refresh();
|
||||
assertNotNull(this.context.getBean(JobLauncher.class));
|
||||
this.context.getBean(JobLauncherCommandLineRunner.class).run();
|
||||
assertNotNull(this.context.getBean(JobRepository.class).getLastJobExecution(
|
||||
"discreteLocalJob", new JobParameters()));
|
||||
assertNotNull(this.context.getBean(JobRepository.class)
|
||||
.getLastJobExecution("discreteLocalJob", new JobParameters()));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -88,7 +88,8 @@ public class JobLauncherCommandLineRunnerTests {
|
||||
}).build();
|
||||
this.job = this.jobs.get("job").start(this.step).build();
|
||||
this.jobExplorer = this.context.getBean(JobExplorer.class);
|
||||
this.runner = new JobLauncherCommandLineRunner(this.jobLauncher, this.jobExplorer);
|
||||
this.runner = new JobLauncherCommandLineRunner(this.jobLauncher,
|
||||
this.jobExplorer);
|
||||
this.context.getBean(BatchConfiguration.class).clear();
|
||||
}
|
||||
|
||||
@@ -96,8 +97,8 @@ public class JobLauncherCommandLineRunnerTests {
|
||||
public void basicExecution() throws Exception {
|
||||
this.runner.execute(this.job, new JobParameters());
|
||||
assertEquals(1, this.jobExplorer.getJobInstances("job", 0, 100).size());
|
||||
this.runner.execute(this.job, new JobParametersBuilder().addLong("id", 1L)
|
||||
.toJobParameters());
|
||||
this.runner.execute(this.job,
|
||||
new JobParametersBuilder().addLong("id", 1L).toJobParameters());
|
||||
assertEquals(2, this.jobExplorer.getJobInstances("job", 0, 100).size());
|
||||
}
|
||||
|
||||
|
||||
@@ -180,9 +180,8 @@ public class ConditionEvaluationReportTests {
|
||||
@Test
|
||||
@SuppressWarnings("resource")
|
||||
public void springBootConditionPopulatesReport() throws Exception {
|
||||
ConditionEvaluationReport report = ConditionEvaluationReport
|
||||
.get(new AnnotationConfigApplicationContext(Config.class)
|
||||
.getBeanFactory());
|
||||
ConditionEvaluationReport report = ConditionEvaluationReport.get(
|
||||
new AnnotationConfigApplicationContext(Config.class).getBeanFactory());
|
||||
assertThat(report.getConditionAndOutcomesBySource().size(), not(equalTo(0)));
|
||||
}
|
||||
|
||||
@@ -211,12 +210,12 @@ public class ConditionEvaluationReportTests {
|
||||
public void duplicateOutcomes() {
|
||||
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(
|
||||
DuplicateConfig.class);
|
||||
ConditionEvaluationReport report = ConditionEvaluationReport.get(context
|
||||
.getBeanFactory());
|
||||
ConditionEvaluationReport report = ConditionEvaluationReport
|
||||
.get(context.getBeanFactory());
|
||||
String autoconfigKey = MultipartAutoConfiguration.class.getName();
|
||||
|
||||
ConditionAndOutcomes outcomes = report.getConditionAndOutcomesBySource().get(
|
||||
autoconfigKey);
|
||||
ConditionAndOutcomes outcomes = report.getConditionAndOutcomesBySource()
|
||||
.get(autoconfigKey);
|
||||
assertThat(outcomes, not(nullValue()));
|
||||
assertThat(getNumberOfOutcomes(outcomes), equalTo(2));
|
||||
|
||||
@@ -237,11 +236,12 @@ public class ConditionEvaluationReportTests {
|
||||
EnvironmentTestUtils.addEnvironment(context, "test.present=true");
|
||||
context.register(NegativeOuterConfig.class);
|
||||
context.refresh();
|
||||
ConditionEvaluationReport report = ConditionEvaluationReport.get(context
|
||||
.getBeanFactory());
|
||||
ConditionEvaluationReport report = ConditionEvaluationReport
|
||||
.get(context.getBeanFactory());
|
||||
Map<String, ConditionAndOutcomes> sourceOutcomes = report
|
||||
.getConditionAndOutcomesBySource();
|
||||
assertThat(context.containsBean("negativeOuterPositiveInnerBean"), equalTo(false));
|
||||
assertThat(context.containsBean("negativeOuterPositiveInnerBean"),
|
||||
equalTo(false));
|
||||
String negativeConfig = NegativeOuterConfig.class.getName();
|
||||
assertThat(sourceOutcomes.get(negativeConfig).isFullMatch(), equalTo(false));
|
||||
String positiveConfig = NegativeOuterConfig.PositiveInnerConfig.class.getName();
|
||||
@@ -287,8 +287,8 @@ public class ConditionEvaluationReportTests {
|
||||
}
|
||||
}
|
||||
|
||||
static class TestMatchCondition extends SpringBootCondition implements
|
||||
ConfigurationCondition {
|
||||
static class TestMatchCondition extends SpringBootCondition
|
||||
implements ConfigurationCondition {
|
||||
|
||||
private final ConfigurationPhase phase;
|
||||
|
||||
|
||||
@@ -210,8 +210,8 @@ public class ConditionalOnBeanTests {
|
||||
|
||||
}
|
||||
|
||||
protected static class WithPropertyPlaceholderClassNameRegistrar implements
|
||||
ImportBeanDefinitionRegistrar {
|
||||
protected static class WithPropertyPlaceholderClassNameRegistrar
|
||||
implements ImportBeanDefinitionRegistrar {
|
||||
|
||||
@Override
|
||||
public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata,
|
||||
|
||||
@@ -83,16 +83,16 @@ public class ConditionalOnJavaTests {
|
||||
public void equalOrNewerMessage() throws Exception {
|
||||
ConditionOutcome outcome = this.condition.getMatchOutcome(Range.EQUAL_OR_NEWER,
|
||||
JavaVersion.SEVEN, JavaVersion.SIX);
|
||||
assertThat(outcome.getMessage(), equalTo("Required JVM version "
|
||||
+ "1.6 or newer found 1.7"));
|
||||
assertThat(outcome.getMessage(),
|
||||
equalTo("Required JVM version " + "1.6 or newer found 1.7"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void olderThanMessage() throws Exception {
|
||||
ConditionOutcome outcome = this.condition.getMatchOutcome(Range.OLDER_THAN,
|
||||
JavaVersion.SEVEN, JavaVersion.SIX);
|
||||
assertThat(outcome.getMessage(), equalTo("Required JVM version "
|
||||
+ "older than 1.6 found 1.7"));
|
||||
assertThat(outcome.getMessage(),
|
||||
equalTo("Required JVM version " + "older than 1.6 found 1.7"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -271,8 +271,8 @@ public class ConditionalOnMissingBeanTests {
|
||||
protected static class NonspecificFactoryBeanClassAttributeConfiguration {
|
||||
}
|
||||
|
||||
protected static class NonspecificFactoryBeanClassAttributeRegistrar implements
|
||||
ImportBeanDefinitionRegistrar {
|
||||
protected static class NonspecificFactoryBeanClassAttributeRegistrar
|
||||
implements ImportBeanDefinitionRegistrar {
|
||||
|
||||
@Override
|
||||
public void registerBeanDefinitions(AnnotationMetadata meta,
|
||||
@@ -293,8 +293,8 @@ public class ConditionalOnMissingBeanTests {
|
||||
protected static class NonspecificFactoryBeanStringAttributeConfiguration {
|
||||
}
|
||||
|
||||
protected static class NonspecificFactoryBeanStringAttributeRegistrar implements
|
||||
ImportBeanDefinitionRegistrar {
|
||||
protected static class NonspecificFactoryBeanStringAttributeRegistrar
|
||||
implements ImportBeanDefinitionRegistrar {
|
||||
|
||||
@Override
|
||||
public void registerBeanDefinitions(AnnotationMetadata meta,
|
||||
@@ -302,9 +302,9 @@ public class ConditionalOnMissingBeanTests {
|
||||
BeanDefinitionBuilder builder = BeanDefinitionBuilder
|
||||
.genericBeanDefinition(NonspecificFactoryBean.class);
|
||||
builder.addConstructorArgValue("foo");
|
||||
builder.getBeanDefinition()
|
||||
.setAttribute(OnBeanCondition.FACTORY_BEAN_OBJECT_TYPE,
|
||||
ExampleBean.class.getName());
|
||||
builder.getBeanDefinition().setAttribute(
|
||||
OnBeanCondition.FACTORY_BEAN_OBJECT_TYPE,
|
||||
ExampleBean.class.getName());
|
||||
registry.registerBeanDefinition("exampleBeanFactoryBean",
|
||||
builder.getBeanDefinition());
|
||||
}
|
||||
|
||||
@@ -94,7 +94,8 @@ public class ConditionalOnPropertyTests {
|
||||
|
||||
@Test
|
||||
public void nonRelaxedName() throws Exception {
|
||||
load(NonRelaxedPropertiesRequiredConfiguration.class, "theRelaxedProperty=value1");
|
||||
load(NonRelaxedPropertiesRequiredConfiguration.class,
|
||||
"theRelaxedProperty=value1");
|
||||
assertFalse(this.context.containsBean("foo"));
|
||||
}
|
||||
|
||||
|
||||
@@ -40,8 +40,8 @@ public class SpringBootConditionTests {
|
||||
@Test
|
||||
public void sensibleClassException() {
|
||||
this.thrown.expect(IllegalStateException.class);
|
||||
this.thrown.expectMessage("Error processing condition on "
|
||||
+ ErrorOnClass.class.getName());
|
||||
this.thrown.expectMessage(
|
||||
"Error processing condition on " + ErrorOnClass.class.getName());
|
||||
new AnnotationConfigApplicationContext(ErrorOnClass.class);
|
||||
}
|
||||
|
||||
|
||||
@@ -66,8 +66,8 @@ public class JpaRepositoriesAutoConfigurationTests {
|
||||
public void testOverrideRepositoryConfiguration() throws Exception {
|
||||
prepareApplicationContext(CustomConfiguration.class);
|
||||
|
||||
assertNotNull(this.context
|
||||
.getBean(org.springframework.boot.autoconfigure.data.alt.jpa.CityJpaRepository.class));
|
||||
assertNotNull(this.context.getBean(
|
||||
org.springframework.boot.autoconfigure.data.alt.jpa.CityJpaRepository.class));
|
||||
assertNotNull(this.context.getBean(PlatformTransactionManager.class));
|
||||
assertNotNull(this.context.getBean(EntityManagerFactory.class));
|
||||
}
|
||||
|
||||
@@ -63,8 +63,8 @@ public class JpaWebAutoConfigurationTests {
|
||||
this.context.refresh();
|
||||
assertNotNull(this.context.getBean(CityRepository.class));
|
||||
assertNotNull(this.context.getBean(PageableHandlerMethodArgumentResolver.class));
|
||||
assertTrue(this.context.getBean(FormattingConversionService.class).canConvert(
|
||||
Long.class, City.class));
|
||||
assertTrue(this.context.getBean(FormattingConversionService.class)
|
||||
.canConvert(Long.class, City.class));
|
||||
}
|
||||
|
||||
@Configuration
|
||||
|
||||
@@ -100,7 +100,8 @@ public class MixedMongoRepositoriesAutoConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJpaRepositoryConfigurationWithMongoOverlapDisabled() throws Exception {
|
||||
public void testJpaRepositoryConfigurationWithMongoOverlapDisabled()
|
||||
throws Exception {
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
EnvironmentTestUtils.addEnvironment(this.context,
|
||||
"spring.datasource.initialize:false",
|
||||
|
||||
@@ -99,8 +99,8 @@ public class MongoDataAutoConfigurationTests {
|
||||
MongoAutoConfiguration.class, MongoDataAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
MongoTemplate template = this.context.getBean(MongoTemplate.class);
|
||||
assertTrue(template.getConverter().getConversionService()
|
||||
.canConvert(Mongo.class, Boolean.class));
|
||||
assertTrue(template.getConverter().getConversionService().canConvert(Mongo.class,
|
||||
Boolean.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -161,8 +161,8 @@ public class MongoDataAutoConfigurationTests {
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
private static void assertDomainTypesDiscovered(MongoMappingContext mappingContext,
|
||||
Class<?>... types) {
|
||||
Set<Class> initialEntitySet = (Set<Class>) ReflectionTestUtils.getField(
|
||||
mappingContext, "initialEntitySet");
|
||||
Set<Class> initialEntitySet = (Set<Class>) ReflectionTestUtils
|
||||
.getField(mappingContext, "initialEntitySet");
|
||||
assertThat(initialEntitySet, hasSize(types.length));
|
||||
assertThat(initialEntitySet, Matchers.<Class>hasItems(types));
|
||||
}
|
||||
|
||||
@@ -88,7 +88,8 @@ public class FlywayAutoConfigurationTests {
|
||||
EnvironmentTestUtils.addEnvironment(this.context,
|
||||
"flyway.url:jdbc:hsqldb:mem:flywaytest", "flyway.user:sa");
|
||||
registerAndRefresh(EmbeddedDataSourceConfiguration.class,
|
||||
FlywayAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class);
|
||||
FlywayAutoConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class);
|
||||
Flyway flyway = this.context.getBean(Flyway.class);
|
||||
assertNotNull(flyway.getDataSource());
|
||||
}
|
||||
@@ -105,10 +106,11 @@ public class FlywayAutoConfigurationTests {
|
||||
@Test
|
||||
public void defaultFlyway() throws Exception {
|
||||
registerAndRefresh(EmbeddedDataSourceConfiguration.class,
|
||||
FlywayAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class);
|
||||
FlywayAutoConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class);
|
||||
Flyway flyway = this.context.getBean(Flyway.class);
|
||||
assertEquals("[classpath:db/migration]", Arrays.asList(flyway.getLocations())
|
||||
.toString());
|
||||
assertEquals("[classpath:db/migration]",
|
||||
Arrays.asList(flyway.getLocations()).toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -116,7 +118,8 @@ public class FlywayAutoConfigurationTests {
|
||||
EnvironmentTestUtils.addEnvironment(this.context,
|
||||
"flyway.locations:classpath:db/changelog,classpath:db/migration");
|
||||
registerAndRefresh(EmbeddedDataSourceConfiguration.class,
|
||||
FlywayAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class);
|
||||
FlywayAutoConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class);
|
||||
Flyway flyway = this.context.getBean(Flyway.class);
|
||||
assertEquals("[classpath:db/changelog, classpath:db/migration]",
|
||||
Arrays.asList(flyway.getLocations()).toString());
|
||||
@@ -126,7 +129,8 @@ public class FlywayAutoConfigurationTests {
|
||||
public void overrideSchemas() throws Exception {
|
||||
EnvironmentTestUtils.addEnvironment(this.context, "flyway.schemas:public");
|
||||
registerAndRefresh(EmbeddedDataSourceConfiguration.class,
|
||||
FlywayAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class);
|
||||
FlywayAutoConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class);
|
||||
Flyway flyway = this.context.getBean(Flyway.class);
|
||||
assertEquals("[public]", Arrays.asList(flyway.getSchemas()).toString());
|
||||
}
|
||||
@@ -137,7 +141,8 @@ public class FlywayAutoConfigurationTests {
|
||||
"flyway.locations:file:no-such-dir");
|
||||
this.thrown.expect(BeanCreationException.class);
|
||||
registerAndRefresh(EmbeddedDataSourceConfiguration.class,
|
||||
FlywayAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class);
|
||||
FlywayAutoConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -148,7 +153,8 @@ public class FlywayAutoConfigurationTests {
|
||||
this.thrown.expect(BeanCreationException.class);
|
||||
this.thrown.expectMessage("Cannot find migrations location in");
|
||||
registerAndRefresh(EmbeddedDataSourceConfiguration.class,
|
||||
FlywayAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class);
|
||||
FlywayAutoConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -157,7 +163,8 @@ public class FlywayAutoConfigurationTests {
|
||||
"flyway.locations:classpath:db/changelog,classpath:db/migration",
|
||||
"flyway.check-location:true");
|
||||
registerAndRefresh(EmbeddedDataSourceConfiguration.class,
|
||||
FlywayAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class);
|
||||
FlywayAutoConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -134,7 +134,8 @@ public class FreeMarkerAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void customTemplateLoaderPath() throws Exception {
|
||||
registerAndRefreshContext("spring.freemarker.templateLoaderPath:classpath:/custom-templates/");
|
||||
registerAndRefreshContext(
|
||||
"spring.freemarker.templateLoaderPath:classpath:/custom-templates/");
|
||||
MockHttpServletResponse response = render("custom");
|
||||
String result = response.getContentAsString();
|
||||
assertThat(result, containsString("custom"));
|
||||
|
||||
@@ -40,8 +40,8 @@ public class FreeMarkerTemplateAvailabilityProviderTests {
|
||||
|
||||
@Test
|
||||
public void availabilityOfTemplateInDefaultLocation() {
|
||||
assertTrue(this.provider.isTemplateAvailable("home", this.environment, getClass()
|
||||
.getClassLoader(), this.resourceLoader));
|
||||
assertTrue(this.provider.isTemplateAvailable("home", this.environment,
|
||||
getClass().getClassLoader(), this.resourceLoader));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -113,8 +113,8 @@ public class HypermediaAutoConfigurationTests {
|
||||
this.context.refresh();
|
||||
ObjectMapper objectMapper = this.context.getBean("_halObjectMapper",
|
||||
ObjectMapper.class);
|
||||
assertTrue(objectMapper.getSerializationConfig().isEnabled(
|
||||
SerializationFeature.INDENT_OUTPUT));
|
||||
assertTrue(objectMapper.getSerializationConfig()
|
||||
.isEnabled(SerializationFeature.INDENT_OUTPUT));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -54,15 +54,15 @@ public class CommonsDataSourceConfigurationTests {
|
||||
@Test
|
||||
public void testDataSourcePropertiesOverridden() throws Exception {
|
||||
this.context.register(CommonsDataSourceConfiguration.class);
|
||||
EnvironmentTestUtils.addEnvironment(this.context, PREFIX
|
||||
+ "url:jdbc:foo//bar/spam");
|
||||
EnvironmentTestUtils.addEnvironment(this.context,
|
||||
PREFIX + "url:jdbc:foo//bar/spam");
|
||||
EnvironmentTestUtils.addEnvironment(this.context, PREFIX + "testWhileIdle:true");
|
||||
EnvironmentTestUtils.addEnvironment(this.context, PREFIX + "testOnBorrow:true");
|
||||
EnvironmentTestUtils.addEnvironment(this.context, PREFIX + "testOnReturn:true");
|
||||
EnvironmentTestUtils.addEnvironment(this.context, PREFIX
|
||||
+ "timeBetweenEvictionRunsMillis:10000");
|
||||
EnvironmentTestUtils.addEnvironment(this.context, PREFIX
|
||||
+ "minEvictableIdleTimeMillis:12345");
|
||||
EnvironmentTestUtils.addEnvironment(this.context,
|
||||
PREFIX + "timeBetweenEvictionRunsMillis:10000");
|
||||
EnvironmentTestUtils.addEnvironment(this.context,
|
||||
PREFIX + "minEvictableIdleTimeMillis:12345");
|
||||
EnvironmentTestUtils.addEnvironment(this.context, PREFIX + "maxWait:1234");
|
||||
this.context.refresh();
|
||||
BasicDataSource ds = this.context.getBean(BasicDataSource.class);
|
||||
|
||||
@@ -171,11 +171,9 @@ public class DataSourceAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void testExplicitDriverClassClearsUserName() throws Exception {
|
||||
EnvironmentTestUtils
|
||||
.addEnvironment(
|
||||
this.context,
|
||||
"spring.datasource.driverClassName:org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfigurationTests$DatabaseDriver",
|
||||
"spring.datasource.url:jdbc:foo://localhost");
|
||||
EnvironmentTestUtils.addEnvironment(this.context,
|
||||
"spring.datasource.driverClassName:org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfigurationTests$DatabaseDriver",
|
||||
"spring.datasource.url:jdbc:foo://localhost");
|
||||
this.context.register(DataSourceAutoConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
@@ -234,19 +232,19 @@ public class DataSourceAutoConfigurationTests {
|
||||
EnvironmentTestUtils.addEnvironment(this.context,
|
||||
"spring.datasource.driverClassName:org.hsqldb.jdbcDriver",
|
||||
"spring.datasource.url:jdbc:hsqldb:mem:testdb");
|
||||
this.context.setClassLoader(new URLClassLoader(new URL[0], getClass()
|
||||
.getClassLoader()) {
|
||||
@Override
|
||||
protected Class<?> loadClass(String name, boolean resolve)
|
||||
throws ClassNotFoundException {
|
||||
for (String hiddenPackage : hiddenPackages) {
|
||||
if (name.startsWith(hiddenPackage)) {
|
||||
throw new ClassNotFoundException();
|
||||
this.context.setClassLoader(
|
||||
new URLClassLoader(new URL[0], getClass().getClassLoader()) {
|
||||
@Override
|
||||
protected Class<?> loadClass(String name, boolean resolve)
|
||||
throws ClassNotFoundException {
|
||||
for (String hiddenPackage : hiddenPackages) {
|
||||
if (name.startsWith(hiddenPackage)) {
|
||||
throw new ClassNotFoundException();
|
||||
}
|
||||
}
|
||||
return super.loadClass(name, resolve);
|
||||
}
|
||||
}
|
||||
return super.loadClass(name, resolve);
|
||||
}
|
||||
});
|
||||
});
|
||||
this.context.register(DataSourceAutoConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
|
||||
@@ -107,16 +107,12 @@ public class DataSourceInitializerTests {
|
||||
public void testDataSourceInitializedWithExplicitScript() throws Exception {
|
||||
this.context.register(DataSourceAutoConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class);
|
||||
EnvironmentTestUtils
|
||||
.addEnvironment(
|
||||
this.context,
|
||||
"spring.datasource.initialize:true",
|
||||
"spring.datasource.schema:"
|
||||
+ ClassUtils.addResourcePathToPackagePath(getClass(),
|
||||
"schema.sql"),
|
||||
"spring.datasource.data:"
|
||||
+ ClassUtils.addResourcePathToPackagePath(getClass(),
|
||||
"data.sql"));
|
||||
EnvironmentTestUtils.addEnvironment(this.context,
|
||||
"spring.datasource.initialize:true",
|
||||
"spring.datasource.schema:" + ClassUtils
|
||||
.addResourcePathToPackagePath(getClass(), "schema.sql"),
|
||||
"spring.datasource.data:" + ClassUtils
|
||||
.addResourcePathToPackagePath(getClass(), "data.sql"));
|
||||
this.context.refresh();
|
||||
DataSource dataSource = this.context.getBean(DataSource.class);
|
||||
assertTrue(dataSource instanceof org.apache.tomcat.jdbc.pool.DataSource);
|
||||
@@ -128,19 +124,16 @@ public class DataSourceInitializerTests {
|
||||
|
||||
@Test
|
||||
public void testDataSourceInitializedWithMultipleScripts() throws Exception {
|
||||
EnvironmentTestUtils
|
||||
.addEnvironment(
|
||||
this.context,
|
||||
"spring.datasource.initialize:true",
|
||||
"spring.datasource.schema:"
|
||||
+ ClassUtils.addResourcePathToPackagePath(getClass(),
|
||||
"schema.sql")
|
||||
+ ","
|
||||
+ ClassUtils.addResourcePathToPackagePath(getClass(),
|
||||
"another.sql"),
|
||||
"spring.datasource.data:"
|
||||
+ ClassUtils.addResourcePathToPackagePath(getClass(),
|
||||
"data.sql"));
|
||||
EnvironmentTestUtils.addEnvironment(this.context,
|
||||
"spring.datasource.initialize:true",
|
||||
"spring.datasource.schema:"
|
||||
+ ClassUtils.addResourcePathToPackagePath(getClass(),
|
||||
"schema.sql")
|
||||
+ ","
|
||||
+ ClassUtils.addResourcePathToPackagePath(getClass(),
|
||||
"another.sql"),
|
||||
"spring.datasource.data:" + ClassUtils
|
||||
.addResourcePathToPackagePath(getClass(), "data.sql"));
|
||||
this.context.register(DataSourceAutoConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
@@ -155,19 +148,17 @@ public class DataSourceInitializerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDataSourceInitializedWithExplicitSqlScriptEncoding() throws Exception {
|
||||
public void testDataSourceInitializedWithExplicitSqlScriptEncoding()
|
||||
throws Exception {
|
||||
this.context.register(DataSourceAutoConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class);
|
||||
EnvironmentTestUtils.addEnvironment(
|
||||
this.context,
|
||||
EnvironmentTestUtils.addEnvironment(this.context,
|
||||
"spring.datasource.initialize:true",
|
||||
"spring.datasource.sqlScriptEncoding:UTF-8",
|
||||
"spring.datasource.schema:"
|
||||
+ ClassUtils.addResourcePathToPackagePath(getClass(),
|
||||
"encoding-schema.sql"),
|
||||
"spring.datasource.data:"
|
||||
+ ClassUtils.addResourcePathToPackagePath(getClass(),
|
||||
"encoding-data.sql"));
|
||||
"spring.datasource.schema:" + ClassUtils
|
||||
.addResourcePathToPackagePath(getClass(), "encoding-schema.sql"),
|
||||
"spring.datasource.data:" + ClassUtils
|
||||
.addResourcePathToPackagePath(getClass(), "encoding-data.sql"));
|
||||
this.context.refresh();
|
||||
DataSource dataSource = this.context.getBean(DataSource.class);
|
||||
assertTrue(dataSource instanceof org.apache.tomcat.jdbc.pool.DataSource);
|
||||
|
||||
@@ -90,8 +90,7 @@ public class DataSourceJsonSerializationTests {
|
||||
for (PropertyDescriptor property : BeanUtils
|
||||
.getPropertyDescriptors(DataSource.class)) {
|
||||
Method reader = property.getReadMethod();
|
||||
if (reader != null
|
||||
&& property.getWriteMethod() != null
|
||||
if (reader != null && property.getWriteMethod() != null
|
||||
&& this.conversionService.canConvert(String.class,
|
||||
property.getPropertyType())) {
|
||||
jgen.writeObjectField(property.getName(),
|
||||
@@ -115,9 +114,8 @@ public class DataSourceJsonSerializationTests {
|
||||
AnnotatedMethod setter = beanDesc.findMethod(
|
||||
"set" + StringUtils.capitalize(writer.getName()),
|
||||
new Class<?>[] { writer.getPropertyType() });
|
||||
if (setter != null
|
||||
&& this.conversionService.canConvert(String.class,
|
||||
writer.getPropertyType())) {
|
||||
if (setter != null && this.conversionService.canConvert(String.class,
|
||||
writer.getPropertyType())) {
|
||||
result.add(writer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,8 +48,8 @@ public class DataSourceTransactionManagerAutoConfigurationTests {
|
||||
this.context.refresh();
|
||||
assertNotNull(this.context.getBean(DataSource.class));
|
||||
assertNotNull(this.context.getBean(DataSourceTransactionManager.class));
|
||||
assertNotNull(this.context
|
||||
.getBean(AbstractTransactionManagementConfiguration.class));
|
||||
assertNotNull(
|
||||
this.context.getBean(AbstractTransactionManagementConfiguration.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -57,9 +57,8 @@ public class DataSourceTransactionManagerAutoConfigurationTests {
|
||||
this.context.register(DataSourceTransactionManagerAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
assertEquals(0, this.context.getBeanNamesForType(DataSource.class).length);
|
||||
assertEquals(
|
||||
0,
|
||||
this.context.getBeanNamesForType(DataSourceTransactionManager.class).length);
|
||||
assertEquals(0, this.context
|
||||
.getBeanNamesForType(DataSourceTransactionManager.class).length);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -38,15 +38,15 @@ public class DatabaseDriverTests {
|
||||
|
||||
@Test
|
||||
public void classNameForKnownDatabase() {
|
||||
String driverClassName = DatabaseDriver.fromJdbcUrl(
|
||||
"jdbc:postgresql://hostname/dbname").getDriverClassName();
|
||||
String driverClassName = DatabaseDriver
|
||||
.fromJdbcUrl("jdbc:postgresql://hostname/dbname").getDriverClassName();
|
||||
assertEquals("org.postgresql.Driver", driverClassName);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nullClassNameForUnknownDatabase() {
|
||||
String driverClassName = DatabaseDriver.fromJdbcUrl(
|
||||
"jdbc:unknowndb://hostname/dbname").getDriverClassName();
|
||||
String driverClassName = DatabaseDriver
|
||||
.fromJdbcUrl("jdbc:unknowndb://hostname/dbname").getDriverClassName();
|
||||
assertNull(driverClassName);
|
||||
}
|
||||
|
||||
|
||||
@@ -62,8 +62,8 @@ public class HikariDataSourceConfigurationTests {
|
||||
@Test
|
||||
public void testDataSourcePropertiesOverridden() throws Exception {
|
||||
this.context.register(HikariDataSourceConfiguration.class);
|
||||
EnvironmentTestUtils.addEnvironment(this.context, PREFIX
|
||||
+ "jdbcUrl:jdbc:foo//bar/spam");
|
||||
EnvironmentTestUtils.addEnvironment(this.context,
|
||||
PREFIX + "jdbcUrl:jdbc:foo//bar/spam");
|
||||
EnvironmentTestUtils.addEnvironment(this.context, PREFIX + "maxLifetime:1234");
|
||||
this.context.refresh();
|
||||
HikariDataSource ds = this.context.getBean(HikariDataSource.class);
|
||||
|
||||
@@ -83,8 +83,8 @@ public class JndiDataSourceAutoConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void dataSourceIsAvailableFromJndi() throws IllegalStateException,
|
||||
NamingException {
|
||||
public void dataSourceIsAvailableFromJndi()
|
||||
throws IllegalStateException, NamingException {
|
||||
DataSource dataSource = new BasicDataSource();
|
||||
configureJndi("foo", dataSource);
|
||||
|
||||
@@ -99,8 +99,8 @@ public class JndiDataSourceAutoConfigurationTests {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
public void mbeanDataSourceIsExcludedFromExport() throws IllegalStateException,
|
||||
NamingException {
|
||||
public void mbeanDataSourceIsExcludedFromExport()
|
||||
throws IllegalStateException, NamingException {
|
||||
DataSource dataSource = new BasicDataSource();
|
||||
configureJndi("foo", dataSource);
|
||||
|
||||
@@ -120,8 +120,8 @@ public class JndiDataSourceAutoConfigurationTests {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
public void standardDataSourceIsNotExcludedFromExport() throws IllegalStateException,
|
||||
NamingException {
|
||||
public void standardDataSourceIsNotExcludedFromExport()
|
||||
throws IllegalStateException, NamingException {
|
||||
DataSource dataSource = new org.apache.commons.dbcp.BasicDataSource();
|
||||
configureJndi("foo", dataSource);
|
||||
|
||||
|
||||
@@ -73,20 +73,20 @@ public class TomcatDataSourceConfigurationTests {
|
||||
@Test
|
||||
public void testDataSourcePropertiesOverridden() throws Exception {
|
||||
this.context.register(TomcatDataSourceConfiguration.class);
|
||||
EnvironmentTestUtils.addEnvironment(this.context, PREFIX
|
||||
+ "url:jdbc:foo//bar/spam");
|
||||
EnvironmentTestUtils.addEnvironment(this.context,
|
||||
PREFIX + "url:jdbc:foo//bar/spam");
|
||||
EnvironmentTestUtils.addEnvironment(this.context, PREFIX + "testWhileIdle:true");
|
||||
EnvironmentTestUtils.addEnvironment(this.context, PREFIX + "testOnBorrow:true");
|
||||
EnvironmentTestUtils.addEnvironment(this.context, PREFIX + "testOnReturn:true");
|
||||
EnvironmentTestUtils.addEnvironment(this.context, PREFIX
|
||||
+ "timeBetweenEvictionRunsMillis:10000");
|
||||
EnvironmentTestUtils.addEnvironment(this.context, PREFIX
|
||||
+ "minEvictableIdleTimeMillis:12345");
|
||||
EnvironmentTestUtils.addEnvironment(this.context,
|
||||
PREFIX + "timeBetweenEvictionRunsMillis:10000");
|
||||
EnvironmentTestUtils.addEnvironment(this.context,
|
||||
PREFIX + "minEvictableIdleTimeMillis:12345");
|
||||
EnvironmentTestUtils.addEnvironment(this.context, PREFIX + "maxWait:1234");
|
||||
EnvironmentTestUtils.addEnvironment(this.context, PREFIX
|
||||
+ "jdbcInterceptors:SlowQueryReport");
|
||||
EnvironmentTestUtils.addEnvironment(this.context, PREFIX
|
||||
+ "validationInterval:9999");
|
||||
EnvironmentTestUtils.addEnvironment(this.context,
|
||||
PREFIX + "jdbcInterceptors:SlowQueryReport");
|
||||
EnvironmentTestUtils.addEnvironment(this.context,
|
||||
PREFIX + "validationInterval:9999");
|
||||
this.context.refresh();
|
||||
org.apache.tomcat.jdbc.pool.DataSource ds = this.context
|
||||
.getBean(org.apache.tomcat.jdbc.pool.DataSource.class);
|
||||
@@ -146,8 +146,7 @@ public class TomcatDataSourceConfigurationTests {
|
||||
DataSourceBuilder factory = DataSourceBuilder
|
||||
.create(this.properties.getClassLoader())
|
||||
.driverClassName(this.properties.getDriverClassName())
|
||||
.url(this.properties.getUrl())
|
||||
.username(this.properties.getUsername())
|
||||
.url(this.properties.getUrl()).username(this.properties.getUsername())
|
||||
.password(this.properties.getPassword())
|
||||
.type(org.apache.tomcat.jdbc.pool.DataSource.class);
|
||||
return factory.build();
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user