Commit Graph

5118 Commits

Author SHA1 Message Date
Rossen Stoyanchev
1af7575bde Merge rather than add URI vars to data binding values
As of Spring 3.1 URI variables can be used for data binding purposes in
addition to request parameters (including query string and form params)

In some cases URI variables and request params can overlap (e.g. form
contains a child entity with an entityId as hidden form input while the
URI contains the entityId of the parent entity) and that can lead to
surprises if the application already exists.

This change ensures that request parameters are used first and URI
vars are added only if they don't overlap. Ideally however an
application should not use the same uri variable name as the name of
a request parameter where they don't refer to the same value.

Issue: SPR-9349
Backport-Issue: SPR-9432
Backport-Commit: 4027b38903
2012-06-26 17:40:45 -04:00
Rossen Stoyanchev
8143d66e4c Pattern suffix issue in AnnotationMethodHandlerAdapter
Issue: SPR-9333
Backport-Issue: SPR-9419
Backport-Commit: cf5d55173b
2012-06-26 17:38:29 -04:00
Rossen Stoyanchev
9e370208d0 Fix content negotiation issue with sort by q-value
Before this fix the q-value of media types in the Accept header were
ignored when using the new RequestMappingHandlerAdapter in combination
with @ResponseBody and HttpMessageConverters.

Issue: SPR-9160
Backport-Issue: SPR-9168
Backport-Commit: 982cb2f258
2012-06-26 17:28:52 -04:00
Rossen Stoyanchev
e66bc07c37 Translate EOF to HttpMessageNotReadableException
The MappingJacksonHttpMessageConverter now catches all IOException
types raised while reading JSON and translates them into
HttpMessageNotReadableException.

Issue: SPR-9238
Backport-Issue: SPR-9397
Backport-Commit: 816c1f47a4
2012-06-26 17:04:44 -04:00
Rossen Stoyanchev
c9a2dbdbfd Add Jackson 2 HttpMessageConverter and View
Jackson 2 uses completely new package names and new maven artifact ids.
This change adds Jackson 2 as an optional dependency and also provides
MappingJackson2HttpMessageConverter and MappingJackson2JsonView for use
with the new version.

The MVC namespace and the MVC Java config detect and use
MappingJackson2HttpMessageConverter if Jackson 2 is present.
Otherwise if Jackson 1.x is present,
then MappingJacksonHttpMessageConverter is used.

Issue: SPR-9302
Backport-Issue: SPR-9507
Backport-Commit: e63ca04fdb
2012-06-26 16:52:51 -04:00
Rossen Stoyanchev
2fa0e63e5a Discover controllers based on type @RequestMapping
This was supported in DefaultAnnotationHandlerMapping but not in the
RequestMappingHandlerMapping. The specific scenario where this matters
is a controller decorated with a JDK proxy. In this scenario the
HandlerMapping looks at interfaces only to decide if the bean is a
controller. The @Controller annotation is better left (and required)
on the class.

Issue: SPR-9374
Backport-Issue: SPR-9384
Backport-Commit: f61f4a960e
2012-06-26 15:51:08 -04:00
Rossen Stoyanchev
83ac44d1e4 Fix issue with parsing media types
Invalid Content-Type or Accept header values previously resulted in the
IllegalArgumentException getting propagated. After this change such
errors are detected and generally treated as a "no match", which
may for example result in a 406 in the case of the Accept header.

Issue: SPR-9142
Backport-Issue: SPR-9148
Backport-Commit: ca8b98e947
2012-06-26 13:55:05 -04:00
Rossen Stoyanchev
0cf93711b9 Fix race condition in AnntationMethodHER
Issue: SPR-9138
Backport-Issue: SPR-9147
Backport-Commit: 0b02933938
2012-06-26 13:46:25 -04:00
Rossen Stoyanchev
8faa2e61ec Fix bug with custom RequestCondition
A custom RequestCondition which can be provided by overriding methods
in RequestMappingHandlerMapping worked only for conditions that match
and did not return null (as it should have) for conditions that don't
match.

Issue: SPR-9134
Backport-Issue: SPR-9146
Backport-Commit: 64ee5e579a
2012-06-26 13:40:00 -04:00
Chris Beams
71443efd90 Fix typo in MessageSource reference docs
Issue: SPR-5022
2012-06-19 11:58:41 +02:00
Juergen Hoeller
bc243b5aa7 preparations for 3.1.2 release 2012-05-28 00:23:01 +02:00
Juergen Hoeller
d36979bc80 fixed WindowState comparison 2012-05-28 00:12:55 +02:00
Juergen Hoeller
5875695d99 polishing 2012-05-28 00:11:55 +02:00
Juergen Hoeller
dcb44264ad EhCacheFactoryBean applies listeners and enabled/disabled flags to existing cache regions as well (SPR-9392) 2012-05-28 00:11:19 +02:00
Juergen Hoeller
9fcb578187 fixed StandardServletMultipartResolver compatibility with Resin (SPR-9299) 2012-05-28 00:10:47 +02:00
Juergen Hoeller
8cdfbfe864 ServletContextResource's getFile implementation falls back to getRealPath for non-existent files (SPR-8461) 2012-05-28 00:10:23 +02:00
Oliver Gierke
9ca407d55e Add missing section ids in reference documentation
Add missing id attributes to <section> elements in the reference
documentation to ensure stable anchor links in HTML output.

Issue: SPR-9410
Backport-Issue: SPR-9346
Backport-Commit: 2a75c57d3c
2012-05-15 22:11:23 +03:00
Chris Beams
1380d053c4 Clarify @EnableScheduling javadoc
It is now advised that destroyMethod="shutdown" should be used
on @Bean methods returning an ExecutorService.

Backport-Issue: SPR-9280
Backport-Commit: 6da03a61b22696283c2c5c79f8f88b5c36480560
2012-05-15 22:10:54 +03:00
Chris Beams
6b76afd1ce Fix typo in reference documentation
Issue: SPR-9321
2012-04-13 20:40:21 +03:00
Chris Beams
2fe74a4ef0 Eliminate INDEX.LIST from Spring jar META-INF dirs
The contents of this file could be problematic as they were generated
by spring-build with "org.springframework.core.jar" EBR-style naming,
but this naming is incorrect when dealing with Maven-central style
artifacts, e.g. spring-core.jar.

While a well-formed INDEX.LIST may speed up classloading, the simplest
solution to the issues listed below is simply to eliminate the file.
This also means consistent treatment across 3.1.x and 3.2.x artifacts,
as the new Gradle build in 3.2.x does not create these index files.

Issue: SPR-6383, SPR-9208
2012-04-13 16:58:26 +03:00
Juergen Hoeller
ee9b9d6a57 JDBC parameter binding uses JDBC 3.0 ParameterMetaData (if available) for type determination 2012-03-14 16:54:22 +01:00
Juergen Hoeller
bf8fa6e268 moved getInputStream() not-null requirement to InputStreamSource itself 2012-03-14 16:40:47 +01:00
Juergen Hoeller
c976fa329f initial fixes for 3.1.2 2012-03-14 16:18:06 +01:00
Juergen Hoeller
d22c8aca49 moved getInputStream() not-null requirement to InputStreamSource itself 2012-03-14 16:12:57 +01:00
Juergen Hoeller
79d9f7a5f7 JDBC parameter binding uses JDBC 3.0 ParameterMetaData (if available) for type determination 2012-03-14 16:07:39 +01:00
Juergen Hoeller
9d3cfcd8e6 fixed OSGi metadata for optional "javax.inject" package import (SPR-9173) 2012-03-14 16:03:49 +01:00
Chris Beams
7d72ab59ae Return null correctly from MutablePropertySources#get
Prior to this commit, MutablePropertySources#get(String) would throw
IndexArrayOutOfBoundsException if the named property source does not
actually exist. This is a violation of the PropertySource#get contract
as described in its Javadoc.

The implementation now correctly checks for the existence of the named
property source, returning null if non-existent and otherwise returning
the associated PropertySource.

Other changes

 - Rename PropertySourcesTests => MutablePropertySourcesTests
 - Polish MutablePropertySourcesTests for style, formatting
 - Refactor MutablePropertySources for consistency

Issue: SPR-9185
Backport-Issue: SPR-9179
Backport-Commit: 15d1d824b5
2012-02-29 14:47:47 +01:00
Chris Beams
40a6769309 Avoid infinite loop in AbstractResource#contentLength
Due to changes made in commit 2fa87a71 for SPR-9118,
AbstractResource#contentLength would fall into an infinite loop unless
the method were overridden by a subclass (which it is in the majority of
use cases).

This commit:

 - fixes the infinite recursion by refactoring to a while loop

 - asserts that the value returned from #getInputStream is not null in
   order to avoid NullPointerException

 - tests both of the above

 - adds Javadoc to the Resource interface to clearly document that the
   contract for any implementation is that #getInputStream must not
   return null

Issue: SPR-9163
Backport-Issue: SPR-9161
Backport-Commit: 7ca5fba05f
2012-02-24 14:47:02 +01:00
Chris Beams
e30d6104f3 Fix regression in @PropertySource placeholder resolution
Changes in commit 41ade68b50 introduced
a regression causing all but the first location in the
@PropertySource#value array to be ignored during ${...} placeholder
resolution. This change ensures that all locations are processed and
replaced as expected.

Issue: SPR-9133
Backport-Issue: SPR-9127
Backport-Commit: 4df2a14b13
2012-02-20 15:27:09 +01:00
Chris Beams
129b4b3136 Update reference doc copyright year to 2012 2012-02-17 01:24:14 +01:00
Spring Buildmaster
b32a365f14 Increment version to 3.1.2.BUILD-SNAPSHOT 2012-02-16 15:38:16 -08:00
Spring Buildmaster
79c9ca1a26 Release version 3.1.1.RELEASE 2012-02-16 15:33:27 -08:00
Chris Beams
7535e24deb Warn re Environment construction and instance vars
- Add warning regarding access to default instance variable values
   during AbstractEnvironment#customizePropertySources callback

 - Polish AbstractEnvironment Javadoc and formatting

Issue: SPR-9013
2012-02-16 21:31:10 +01:00
Chris Beams
80dd32e95c Disallow empty @PropertySource(value = {})
Previously, a user could specify an empty array of resource locations
to the @PropertySource annotation, which amounts to a meaningless no-op.

ConfigurationClassParser now throws IllegalArgumentException upon
encountering any such misconfiguration.
2012-02-16 18:25:53 +01:00
Chris Beams
41ade68b50 Fix @PropertySource bug with multiple values
Prior to this commit, specifying a named @PropertySource with multiple
values would not work as expected. e.g.:

  @PropertySource(
      name = "ps",
      value = { "classpath:a.properties", "classpath:b.properties" })

In this scenario, the implementation would register a.properties with
the name "ps", and subsequently register b.properties with the name
"ps", overwriting the entry for a.properties.

To fix this behavior, a CompositePropertySource type has been introduced
which accepts a single name and a set of PropertySource objects to
iterate over. ConfigurationClassParser's @PropertySource parsing routine
has been updated to use this composite approach when necessary, i.e.
when both an explicit name and more than one location have been
specified.

Note that if no explicit name is specified, the generated property
source names are enough to distinguish the instances and avoid
overwriting each other; this is why the composite wrapper is not used
in these cases.

Issue: SPR-9127
2012-02-16 18:25:03 +01:00
Juergen Hoeller
ff862addbe final preparations for 3.1.1 release 2012-02-16 17:34:53 +01:00
Juergen Hoeller
94e3f08a44 added "receive-timeout" attribute to "jms:listener-container" element in JMS namespace (SPR-9114) 2012-02-16 12:03:09 +01:00
Chris Beams
1c2b1d2c85 Demonstrate use of @Configuration as meta-annotation
Issue: SPR-9090
2012-02-15 22:01:35 +01:00
Chris Beams
58e270f7da Prune dead code from JmsTransactionManager#doBegin 2012-02-15 21:11:29 +01:00
Chris Beams
fc416bcb0b Apply @Configuration BeanNameGenerator consistently
Since the introduction of the AnnotationConfig(Web)ApplicationContext
types in Spring 3.0, it has been possible to specify a custom
bean name generation strategy via the #setBeanNameGenerator methods
available on each of these classes.

If specified, that BeanNameGenerator was delegated to the underlying
AnnotatedBeanDefinitionReader and ClassPathBeanDefinitionScanner. This
meant that any @Configuration classes registered or scanned directly
from the application context, e.g. via #register or #scan methods would
respect the custom name generation strategy as intended.

However, for @Configuration classes picked up via @Import or implicitly
registered due to being nested classes would not be aware of this
strategy, and would rather fall back to a hard-coded default
AnnotationBeanNameGenerator.

This change ensures consistent application of custom BeanNameGenerator
strategies in the following ways:

 - Introduction of AnnotationConfigUtils#CONFIGURATION_BEAN_NAME_GENERATOR
   singleton

   If a custom BeanNameGenerator is specified via #setBeanNameGenerator
   the AnnotationConfig* application contexts will, in addition to
   delegating this object to the underlying reader and scanner, register
   it as a singleton bean within the enclosing bean factory having the
   constant name mentioned above.

   ConfigurationClassPostProcessor now checks for the presence of this
   singleton, falling back to a default AnnotationBeanNameGenerator if
   not present. This singleton-based approach is necessary because it is
   otherwise impossible to parameterize CCPP, given that it is
   registered as a BeanDefinitionRegistryPostProcessor bean definition
   in AnnotationConfigUtils#registerAnnotationConfigProcessors

 - Introduction of ConfigurationClassPostProcessor#setBeanNameGenerator

   As detailed in the Javadoc for this new method, this allows for
   customizing the BeanNameGenerator via XML by dropping down to direct
   registration of CCPP as a <bean> instead of using
   <context:annotation-config> to enable  @Configuration class
   processing.

 - Smarter defaulting for @ComponentScan#beanNameGenerator

   Previously, @ComponentScan's #beanNameGenerator attribute had a
   default value of AnnotationBeanNameGenerator. The value is now the
   BeanNameGenerator interface itself, indicating that the scanner
   dedicated to processing each @ComponentScan should fall back to an
   inherited generator, i.e. the one originally specified against the
   application context, or the original default provided by
   ConfigurationClassPostProcessor. This means that name generation
   strategies will be consistent with a single point of configuration,
   but that individual @ComponentScan declarations may still customize
   the strategy for the beans that are picked up by that particular
   scanning.

Issue: SPR-9124
2012-02-15 15:33:35 +01:00
Chris Beams
e81df2ef3e Improve @Configuration bean name discovery
Prior to this commit, and based on earlier changes supporting SPR-9023,
ConfigurationClassBeanDefinitionReader employed a simplistic strategy
for extracting the 'value' attribute (if any) from @Configuration in
order to determine the bean name for imported and nested configuration
classes. An example case follows:

  @Configuration("myConfig")
  public class AppConfig { ... }

This approach is too simplistic however, given that it is possible in
'configuration lite' mode to specify a @Component-annotated class with
@Bean methods, e.g.

  @Component("myConfig")
  public class AppConfig {
      @Bean
      public Foo foo() { ... }
  }

In this case, it's the 'value' attribute of @Component, not
@Configuration, that should be consulted for the bean name. Or indeed if
it were any other stereotype annotation meta-annotated with @Component,
the value attribute should respected.

This kind of sophisticated discovery is exactly what
AnnotationBeanNameGenerator was designed to do, and
ConfigurationClassBeanDefinitionReader now uses it in favor of the
custom approach described above.

To enable this refactoring, nested and imported configuration classes
are no longer registered as GenericBeanDefinition, but rather as
AnnotatedGenericBeanDefinition given that AnnotationBeanNameGenerator
falls back to a generic strategy unless the bean definition in question
is assignable to AnnotatedBeanDefinition.

A new constructor accepting AnnotationMetadata
has been added to AnnotatedGenericBeanDefinition in order to support
the ASM-based approach in use by configuration class processing. Javadoc
has been updated for both AnnotatedGenericBeanDefinition and its now
very similar cousin ScannedGenericBeanDefinition to make clear the
semantics and intention of these two variants.

Issue: SPR-9023
2012-02-15 15:33:35 +01:00
Chris Beams
08e2669b84 Fix infinite recursion bug in nested @Configuration
Prior to this commit, an infinite recursion would occur if a
@Configuration class were nested within its superclass, e.g.

  abstract class Parent {
      @Configuration
      static class Child extends Parent { ... }
  }

This is because the processing of the nested class automatically
checks the superclass hierarchy for certain reasons, and each
superclass is in turn checked for nested @Configuration classes.

The ConfigurationClassParser implementation now prevents this by
keeping track of known superclasses, i.e. once a superclass has been
processed, it is never again checked for nested classes, etc.

Issue: SPR-8955
2012-02-15 15:33:35 +01:00
Chris Beams
f3651c9998 Polish static imports 2012-02-15 15:33:35 +01:00
Rossen Stoyanchev
a3484aebb3 Minor fix in ServletResponseMethodArgumentResolver
Issues: SPR-8983
2012-02-15 09:20:02 -05:00
Juergen Hoeller
6fd476e2c5 extracted ResourceUtils.useCachesIfNecessary(URLConnection) method (SPR-9117) 2012-02-14 21:55:29 +01:00
Juergen Hoeller
ab98f288e9 prepared for 3.1.1 release 2012-02-14 21:30:12 +01:00
Juergen Hoeller
acaf820941 CustomSQLExceptionTranslatorRegistry/Registrar etc 2012-02-14 21:29:52 +01:00
Juergen Hoeller
ddf0d071ad revised CustomSQLExceptionTranslatorRegistry/Registrar method naming 2012-02-14 21:29:22 +01:00
Juergen Hoeller
2fa87a71fa use custom InputStream traversal instead of a full byte array (SPR-9118) 2012-02-14 21:16:10 +01:00
Juergen Hoeller
fe57f74c1a PathMatchingResourcePatternResolver preserves caching for JNLP jar connections (SPR-9117) 2012-02-14 18:26:56 +01:00