Commit Graph

2299 Commits

Author SHA1 Message Date
Phillip Webb ca1540cefe Update header copyright for changed files 2017-02-27 20:41:18 -08:00
Phillip Webb 77f6ed8357 Further rework Spring MVC JSR-303 validation
Rework Spring MVC JSR-303 validation support a little more to move
most of the creation logic to the wrapper class. Also rename
`SpringValidatorAdapterWrapper` -> `WebMvcValidator`.

See gh-8223
2017-02-27 20:41:18 -08:00
Phillip Webb 7ed1a26c2d Fix test failures when running in Eclipse
Update MultipartAutoConfigurationTests to reset the Tomcat URL factory.
2017-02-27 20:41:18 -08:00
Phillip Webb 5867cd6175 Polish 2017-02-27 20:41:18 -08:00
Stephane Nicoll 0435f122d4 Rework JSR-303 validation exposure with Spring MVC
This commit improves the initial solution by actually overriding the
`mvcValidator` `@Bean`. This gives us more control as whether a custom
validator has been specified or not. We now wrap it regardless of it
being custom or provided by auto-configuration.

Closes gh-8223
2017-02-27 19:09:29 +01:00
Stephane Nicoll d8f62c46ad Prevent warning due to BPP dependency
`MethodValidationPostProcessor` requires a `Validator` so we need to flag
it as an infrastructure bean to prevent an additional log that indicates
it won't be post-processed.

We obviously don't want to post-process the `Validator` here so adding the
additional meta-data is a good idea anyway.

Closes gh-8422
2017-02-27 16:16:09 +01:00
Stephane Nicoll 4aa99b9531 Avoid exposing several javax.validaton.Validator beans
This commit makes sure that the Spring `Validator` used by the MVC
layer doesn't expose a JSR-303 contract, if any.

The default implementation of the `mvcValidator` is
`LocalValidatorFactoryBean`. While this object is exposed as a Spring
`Validator` only, its runtime capabilities expose that contract as well
as the standard `Validator` and `ValidatorFactory` ones.

Concretely, if an auto-configuration is checking if a
`javax.validation.Validator` bean is missing, the condition will match
since we only know about "advertized types": beans haven't been created
yet so we can't inspect their runtime capabilities. Since the condition
match, we will auto-configure a bean. At runtime though, we're no longer
ale to inject a `javax.validation.Validator` by type since two candidates
are available.

This commit introduces `SpringValidatorAdapterWrapper`, a wrapper class
on any `SpringValidatorAdapter` (`LocalValidatorFactoryBean` being one of
the available implementations) that only exposes the Spring contract.

Also, if a `javax.validation.Validator` bean is available, we will use it
for the MVC layer, rather than creating a new one.

Closes gh-8223
2017-02-24 11:01:42 +01:00
Andy Wilkinson b034a505a5 Polish 0f42c5dd
- Apply standard code formatting
- Add class javadoc to MultipleResourceServerConfigurationTests
- Add missing @Override annotations
- Remove unused ExpectedException field
- Remove use of SpringApplicationBuilder from the tests
- Use @ImportAutoConfiguration to import auto-configuration
- Add assertions to verify that the orders haven't been changed
- Remove unnecessary mocking of EmbeddedServletContainerFactory

See gh-8347
2017-02-22 12:16:05 +00:00
Dave Syer 0f42c5dd94 Check there is only one ResourceServerConfiguration before modifying
Fixes gh-8347
2017-02-22 11:30:17 +00:00
Madhura Bhave 67810abd9e Match ResourceServerCondition if JWK config present
Closes gh-8350
2017-02-21 12:02:49 -08:00
Stephane Nicoll 43a534f4ca Polish contribution
Closes gh-8195
2017-02-20 14:03:07 +01:00
Mathieu Ouellet fa8f0a6136 Add schema validation options for embedded LDAP
See gh-8195
2017-02-20 12:07:53 +01:00
Stephane Nicoll f57ddff478 Remove dead code
Closes gh-8305
2017-02-16 10:04:57 +01:00
Madhura Bhave b4134e239e Add autoconfiguration for JWKTokenStore
If `jwk.key-set-uri` is present.

Closes gh-4437
2017-02-15 12:05:29 -08:00
Andy Wilkinson 01729cc1d2 Merge branch '1.4.x' into 1.5.x 2017-02-15 17:25:07 +00:00
Andy Wilkinson 9e1238e286 Consider resource loader path when checking Groovy template availability
Closes gh-8304
2017-02-15 17:24:57 +00:00
Stephane Nicoll a0ef61a27d Enable proxy target class for `MethodValidationPostProcessor`
Closes gh-8277
2017-02-14 10:32:26 +01:00
Andy Wilkinson e0b355d313 Avoid ClassNotFoundException caused by areturn verification
The verifier's type checker is required to check that a type returned
from a method (an areturn instruction) is assignable to the method's
declared return type. When the return type is an interface, the JLS
states that it should be treated as java.lang.Object. This means that
no analysis of the type being returned is required and verification
passes. When the return type is a class, the type being returned must
be analyzed to ensure that it is compatible. This analysis causes the
return type to be loaded during verification.

Prior to this commit, BasicBatchConfigurer's
createAppropriateTransactionManager method had a return type of
AbstractPlatformTransactionManager and a branch that could return
a JpaTransactionManager. This caused the verifier to attempt to load
JpaTransactionManager so that it could check that it was assignable
to AbstractPlatformTransactionManager. This would fail when
spring-orm is not on the classpath as JpaTransactionManager could not
be loaded.

This commit updates BasicBatchConfigurer to change the return type
of createAppropriateTransactionManager so that it returns a
PlatformTransactionManager which is an interface. As described above,
this relaxes the verification of any areturn instructions in the
method and, in this particular case stops the verifier from trying to
load JpaTransactionManager.

Closes gh-8181
2017-02-13 12:36:17 +00:00
Andy Wilkinson 601c6aa305 Tidy up code formatting and address some compiler warnings 2017-02-09 13:48:55 +00:00
Stephane Nicoll aa49468171 Allow to define a custom MessageRecoverer
This commit improves `SimpleRabbitListenerContainerFactoryConfigurer` to
use a custom `MessageConverter`. If such a bean is present, it is used
for the default factory that is auto-configured.

Closes gh-8194
2017-02-09 10:43:03 +01:00
Stephane Nicoll 8a59e88a9d Fix MongoDB CustomConversions bean name
This commit qualifies the `CustomConversions` bean name that the Mongo
auto-configuration might create. `CustomConversions` is a common pattern
in Spring Data and other stores are using the same name.

See https://jira.spring.io/browse/DATASOLR-362

Closes gh-8225
2017-02-08 14:29:33 +01:00
Stephane Nicoll 45a91fca31 Fix parsing of spring.autoconfigure.exclude property
This commits makes sure that `AutoConfigureImportSelector` properly
parses comma separated lists that contain additional spaces.

Closes gh-8220
2017-02-07 18:26:57 +01:00
Andy Wilkinson e891fe0584 Merge branch '1.4.x' into 1.5.x 2017-02-07 17:06:33 +00:00
Andy Wilkinson 06017f688a Only auto-configure SpringSocialDialect for Thymeleaf 2
Previously, SocialWebAutoConfiguration would create a
SpringSocialDialect bean when SpringTemplateEngine was on the
classpath. This class exists in both Thymeleaf 2 and Thymeleaf 3 but
SpringSocialDialect is only compatible with Thymeleaf 2.

This commit updates the auto-configuration to require
SpringResourceResourceResolver to be on the classpath. This class
exists in Thymeleaf 2 but does not exist in Thymeleaf 3.

Closes gh-4858
2017-02-07 16:20:33 +00:00
Stephane Nicoll 130e0808d0 Merge branch '1.4.x' into 1.5.x 2017-02-07 16:31:02 +01:00
Stephane Nicoll 008aef6142 Document @LiquibaseDataSource feature
Closes gh-8214
2017-02-07 16:16:19 +01:00
Stephane Nicoll e88bda4682 Avoid extra space if condition is empty
Previously, if a builder was created with an empty condition, an extra
space was added before the message. This commit checks for this
particular case and adds a space only when necessary.

Closes gh-8218
2017-02-07 11:59:49 +01:00
Stephane Nicoll 519a03ccda Polish 2017-02-06 14:08:10 +01:00
Johnny Lim 09998d1155 Fix ImportAutoConfigurationImportSelectorTests.determineImportsWhenUsingNonMetaWithClassesShouldBeSame()
Closes gh-8204
2017-02-06 14:05:26 +01:00
Johnny Lim 0adab8a2be Use logical 'and' instead of bitwise 'and'
Closes gh-8198
2017-02-06 10:35:13 +01:00
Johnny Lim 846994e498 Polish
Closes gh-8148
2017-02-01 09:07:47 +01:00
Spring Buildmaster 5c12500366 Next Development Version 2017-01-30 20:10:13 +00:00
Spring Buildmaster a2696bf873 Next Development Version 2017-01-30 11:40:24 +00:00
Phillip Webb fa6a138598 Refine ImportsContextCustomizer cache logic
Update `ImportsContextCustomizer` so that whenever possible a more
specific cache key is used.

Prior to this commit the customizer would generate a key based on *all*
annotations on the test class. This has repeatedly caused issues where
test classes that should have the same cache key did not due to
unrelated annotations.

A new `DeterminableImports` interface has been added that can be
implemented by `ImportSelector` and `ImportBeanDefinitionRegistrar`
implementations that are able to determine their imports early. The
existing `ImportAutoConfigurationImportSelector` and
`AutoConfigurationPackages` classes have been retrofitted with
this interface.

Fixes gh-7953
2017-01-27 17:19:52 -08:00
Andy Wilkinson f34d309548 Formatting 2017-01-26 15:03:02 +00:00
Spring Buildmaster ed1ce140c0 Next Development Version 2017-01-26 14:20:39 +00:00
Andy Wilkinson f5445ba5ff Remove OnValidatorAvailableCondition as it is now redundant
Previously, Hibernate Validator would fail to initialize if it was
on the classpath but an EL implementation was not.
OnValidatorAvailableCondition protected against this scenario by
initializing the validator.

The Hibernate Validator shortcoming was addressed in eb222209
(gh-7598). As a result, checking for the precences of the
ValidationProvider META-INF/services resource is now sufficient to
auto-configure validation. This commit removes
OnValidatorAvailableCondition as it is no longer necessary.

Closes gh-8110
2017-01-26 10:42:46 +00:00
Andy Wilkinson f823599d1f Replace @PostConstruct validation with setter validation
Closes gh-7579
2017-01-26 09:32:07 +00:00
Andy Wilkinson 37cf31f450 Upgrade to Couchbase Java Client 2.3.7
In version 2.3.6 and earlier, an attempt to create a Bucket or a
ClusterInfo would fail fast with a ConnectException in the cause of
the Couchbase server was done. In 2.3.7 this remains true for a
Bucket but is no longer the case for ClusterInfo. The latter now
retries for 75 seconds by default and when it eventually fails a
ConnectException is no longer part of the cause chain.

This commit makes the auto-configured ClusterInfo depend on the
auto-configured Bucket. This means that the Bucket is always created
before the ClusterInfo, thereby ensuring that things fail gracefully
with useful diagnostics when the server is unavailable.

Closes gh-8092
2017-01-25 14:55:28 +00:00
Stephane Nicoll 505e7f75ea Polish contribution
Closes gh-8089
2017-01-25 11:01:53 +01:00
dreis d58f38f6f6 Use String.replace() with single char if possible
See gh-8089
2017-01-25 11:01:52 +01:00
Stephane Nicoll 551bfb2c60 Polish contribution
Closes gh-8103
2017-01-25 11:01:52 +01:00
Johnny Lim 32f9e90de5 Replace 'String.length() == 0' with 'String.isEmpty()'
See gh-8103
2017-01-25 11:01:52 +01:00
Johnny Lim e0de28a1f7 Polish
Closes gh-8076
2017-01-24 13:22:22 +01:00
Phillip Webb b0e06c30a0 Polish 2017-01-23 22:14:58 -08:00
Phillip Webb de50cfa21e Make OnClassCondition an AutoConfigurationImportFilter
Update OnClassCondition to implement AutoConfigurationImportFilter so
that auto-configuration candidates can be filtered early. The
optimization helps to improve application startup time by reducing
the number of classes that are loaded.

See gh-7573
2017-01-23 22:14:58 -08:00
Phillip Webb 20a20b7711 Add AutoConfigurationImportFilter support
Add `AutoConfigurationImportFilter` strategy interface which can be used
to filter auto-configuration candidates before they are loaded.

See gh-7573
2017-01-23 22:14:57 -08:00
Phillip Webb 02641a8207 Optimize AutoConfigurationSorter
Optimize `AutoConfigurationSorter` by used properties generated by the
annotation processor whenever possible. The removes the need for each
candidate class to be ASM parsed just to access the order annotations.

See gh-7573
2017-01-23 22:14:57 -08:00
Phillip Webb 1cbda9bd60 Add AutoConfigurationMetadata abstraction
Add AutoConfigurationMetadata interface and a an internal loader that
allows easy access to data written by `spring-boot-configure-processor`.

See gh-7573
2017-01-23 22:14:57 -08:00
Madhura Bhave ca435512c0 Introduce spring-boot-autoconfigure-processor
Add an annotation processor that generates properties files for certain
auto-configuration class annotations. Currently attribute values from
@AutoConfigureOrder, @AutoConfigureBefore, @AutoConfigureAfter and
@ConditionalOnClass annotations are stored.

The properties file will allow optimizations to be added in the
`spring-boot-autoconfigure` project. Primarily by removing the need
to ASM parse as many `.class` files.

See gh-7573
2017-01-23 22:14:56 -08:00