Commit Graph

5369 Commits

Author SHA1 Message Date
Rossen Stoyanchev f05e2bc56f Add abstractions for content negotiation
Introduced ContentNeogtiationStrategy for resolving the requested
media types from an incoming request. The available implementations
are based on path extension, request parameter, 'Accept' header,
and a fixed default content type. The logic for these implementations
is based on equivalent options, previously available only in the
ContentNegotiatingViewResolver.

Also in this commit is ContentNegotiationManager, the central class to
use when configuring content negotiation options. It accepts one or
more ContentNeogtiationStrategy instances and delegates to them.

The ContentNeogiationManager can now be used to configure the
following classes:

- RequestMappingHandlerMappingm
- RequestMappingHandlerAdapter
- ExceptionHandlerExceptionResolver
- ContentNegotiatingViewResolver

Issue: SPR-8410, SPR-8417, SPR-8418,SPR-8416, SPR-8419,SPR-7722
2012-06-22 11:55:46 -04:00
Chris Beams 35055fd866 Refactor PropertyResolver impl for consistency
PropertySourcesPropertyResolver#containsProperty now
calls #containsProperty on each underlying PropertySource instead of
calling #getProperty and checking for null.

Issue: SPR-9529
2012-06-21 12:53:51 +02:00
Sam Brannen 027e49c58a Document default scripts for embedded databases
The reference manual currently documents the wrong file name for the
default data SQL script used by EmbeddedDatabaseBuilder. In addition,
the testing chapter of the reference manual does not link to the testing
section of the JDBC chapter.

 - Updated the "Testing data access logic with an embedded database"
   section of the reference manual appropriately.
 - Added a new paragraph to the "JDBC Testing Support" section of the
   testing chapter which cross references the "Testing data access logic
   with an embedded database" section.

Issue: SPR-9467
2012-06-19 20:48:07 +02:00
Sam Brannen 5eae22abb8 Document SPR-9493 in the changelog
Issue: SPR-9493
2012-06-19 20:13:46 +02:00
Sam Brannen e3d8ab2088 Fix Javadoc typo in ConfigurableWebEnvironment 2012-06-19 19:34:38 +02:00
Chris Beams 08498d57dd Fix line endings in new JacksonObjectMapper classes
Commit aa415d7c0c introduced
JacksonObjectMapperFactoryBean and associated tests, but with Windows
(CRLF) line endings instead of the conventional Unix (LF) line endings.

This commit converts these files to LF endings using the handy
`dos2unix` utility.

Issue: SPR-9125
2012-06-19 18:14:56 +02:00
Sam Brannen 64d6605974 Merge pull request #97 from sbrannen/SPR-9493
* SPR-9493:
  Infer return type of parametrized factory methods
2012-06-19 18:07:28 +02:00
Sam Brannen c461455c7c Infer return type of parametrized factory methods
Currently, if a factory method is parameterized and the corresponding
variable types are declared on the method itself instead of on the
enclosing class or interface, Spring always predicts the return type to
be Object, even if the return type can be explicitly inferred from the
method signature and supplied arguments (which are available in the bean
definition).

This commit introduces a new resolveParameterizedReturnType() method in
GenericTypeResolver that attempts to infer the concrete type for the
generic return type of a given parameterized method, falling back to the
standard return type if necessary. Furthermore,
AbstractAutowireCapableBeanFactory now delegates to
resolveParameterizedReturnType() when predicting the return type for
factory methods.

resolveParameterizedReturnType() is capable of inferring the concrete
type for return type T for method signatures similar to the following.
Such methods may potentially be static. Also, the formal argument list
for such methods is not limited to a single argument.

 - public <T> T foo(Class<T> clazz)
 - public <T> T foo(Object obj, Class<T> clazz)
 - public <V, T> T foo(V obj, Class<T> clazz)
 - public <T> T foo(T obj)

Issue: SPR-9493
2012-06-19 18:05:41 +02:00
Chris Beams 9fc05a80d0 Reformat and add links to README
The readme is heavy on links and hard to read in source form when using
typical inline Markdown links. The following changes have been made to
increase readability.

 - Wrap lines at 80 characters
 - Use 'implicit link name' shortcut syntax as described at [1]
 - Add link to 'spring-mvc' Stack Overflow tag as well
 - Add link to new 'lifecycle of an issue' wiki doc

[1]: http://daringfireball.net/projects/markdown/syntax
2012-06-19 17:56:18 +02:00
Chris Beams e5bbec7e2b Add Gradle task for building zip with dependencies
Some Spring Framework users and teams cannot use transitive dependency
management tools like Maven, Gradle and Ivy. For them, a `distZip` task
has been added to allow for creating a Spring Framework distribution
from source that includes all optional and required runtime
dependencies for all modules of the framework.

This 'dist-with-deps' zip is not published to the SpringSource
repository nor to the SpringSource community download page. It is
strictly an optional task introduced as a convenience to the users
mentioned above.

Detailed instructions for building this zip locally have been added to
the wiki and the README has been updated with a link to that new doc.

Issue: SPR-6575
2012-06-19 16:49:31 +02:00
Sam Brannen 726655af50 Fix outdated Javadoc in the TestContext framework
Fixed outdated Javadoc regarding support for 'annotated classes' in
the TestContext Framework.
2012-06-19 12:52:24 +02:00
Chris Beams de04d9c654 Fix typo in MessageSource reference docs
Issue: SPR-5022
2012-06-19 11:56:05 +02:00
Rossen Stoyanchev 7dcca4bcfb Merge pull reqest #88 from dmak/SPR-9125
* SPR-9125:
  BeanFactory for configuring a Jackson ObjectMapper
2012-06-18 17:13:35 -04:00
Dmitry Katsubo aa415d7c0c BeanFactory for configuring a Jackson ObjectMapper
The BeanFactory makes it easier to configure a customized Jackson
ObjectMapper (for example enable/disable certain features).
This bean factory is usually used with
MappingJacksonHttpMessageConverter or MappingJacksonJsonView.
See JavaDoc for examples.

Issue: SPR-9125
2012-06-18 17:12:09 -04:00
Rossen Stoyanchev 5959de5d9e Merge pull reqest #92 from DavidBiesack/master
* DavidBiesack-master:
  Minor fix in Javadoc for RequestMapping
2012-06-18 07:22:45 -04:00
David J. Biesack 7cd0b16403 Minor fix in Javadoc for RequestMapping
Issue: SPR-9483
2012-06-18 07:20:03 -04:00
Rossen Stoyanchev 277a115f8b Minor Javadoc fix
Issue: SPR-9513
2012-06-18 06:30:34 -04:00
Chris Beams e8bf25ba9d Merge pull request #95 from rstoyanchev/SPR-4984
* rstoyanchev/SPR-4984:
  Add splitIndex Javadoc option to the root project
2012-06-15 11:01:18 +02:00
Rossen Stoyanchev b0f80d6358 Add splitIndex Javadoc option to the root project
Splits the very large index page with all classes into individual pages
organized by first letter.

Issue: SPR-4984
2012-06-14 12:17:54 -04:00
Rossen Stoyanchev 2abcdaab1e Merge pull request #93 from maxcom/SPR-8917
* SPR-8917:
  Allow parsing of media types with single-quotes
2012-06-14 08:55:18 -04:00
Maxim Valyanskiy 7cdc53487d Allow parsing of media types with single-quotes
Previously MediaType could only parse double-quoted parameters without
raising an IllegalArgumentException. Now parameters can also be
single-quoted.

Issue: SPR-8917
2012-06-14 08:51:52 -04:00
Rossen Stoyanchev ab4952a959 Raise RestClientException for unknown status codes
HttpStatus cannot be created with an unknown status code. If a server
returns a status code that's not in the HttpStatus enum values, an
IllegalArgumentException is raised. Rather than allowing it to
propagate as such, this change ensures the actual exception raised is
a RestClientException.

Issue: SPR-9406
2012-06-13 08:27:16 -04:00
Chris Beams 0e3a1d8176 Require aopalliance dependency for spring-aop
A recent commit made aopalliance optional for spring-aop, while
continuing to require it for spring-tx. On review, this is probably
overly aggressive, and for convenience aopalliance should remain
required for spring-aop. There are use cases for which aopalliance is
indeed optional, but core functionality such as <aop:scoped-proxy>
should never result in a ClassNotFoundException.

This commit returns the aopalliance dependency for spring-aop to
required status, and also explicitly notes the same dependency in other
modules that compile directly against aopalliance types.

Issue: SPR-9501
2012-06-13 13:47:47 +02:00
Chris Beams 49fd20319d Upgrade to Gradle 1.0 GA
Issue: SPR-9494
2012-06-12 11:16:08 +02:00
Sam Brannen 369d77bdf0 spring-test module now depends on junit:junit-dep
The junit:junit Maven artifact includes a bundled version of hamcrest
core. For projects that depend on later versions of hamcrest this causes
significant issues in terms of dependency management.

The spring-test module now depends on junit:junit-dep, thus allowing
developers to better manage their test dependencies on a more fine
grained level.

Also tidied up dependency issues regarding hamcrest-core and
hamcrest-all across the build.

Issue: SPR-6966
2012-06-10 02:39:27 +02:00
Sam Brannen 04a6827290 Reproduce claims raised in SPR-8849
This commit introduces a test suite (Spr8849Tests) that demonstrates
the claims made in SPR-8849.

Specifically, if <jdbc:embedded-database id="xyz" /> is used to create
an embedded HSQL database in an XML configuration file and that
configuration file is imported in different sets of configuration files
that are used to load ApplicationContexts for different integration
tests, the embedded database will be initialized multiple times using
any nested <jdbc:script /> elements. If such a script is used to create
a table, for example, subsequent attempts to initialize the database
named "xyz" will fail since an embedded database named "xyz" already
exists in the JVM.

As a work-around, this test suite uses a SpEL expression to generate a
random string for each embedded database instance:

  id="#{T(java.util.UUID).randomUUID().toString()}"

See the Javadoc in Spr8849Tests for further information.

Issue: SPR-8849
2012-06-10 00:31:05 +02:00
Chris Beams 67d5a1238f Merge pull request #87 from olivergierke/SPR-9457
* SPR-9457:
  Use transactional connection during db population
2012-06-04 16:37:44 +02:00
Oliver Gierke 49c9a2a915 Use transactional connection during db population
Previously, DatabasePopulatorUtils#execute looked up a Connection from
the given DataSource directly which resulted in the executed statements
not being executed against a transactional connection (if any) which in
turn resulted in the statements executed by the populator potentially
not being rolled back.

Now DataSourceUtils#getConnection is used to transparently take part in
any active transaction and #releaseConnection is used to ensure the
connection is closed if appropriate.

Issue: SPR-9457
2012-06-04 16:36:45 +02:00
Chris Beams c471bdde85 Merge pull request #86 from scothis/SPR-7938
* SPR-7938:
  Include response headers in RestTemplate exceptions
  Polish web.client exceptions and related classes
2012-06-01 16:40:06 +02:00
Scott Andrews b992c3d3f2 Include response headers in RestTemplate exceptions
Default HTTP error exceptions thrown from RestTemplate now include
response headers in addition to the response body. In particular, this
enables inspection of the Content-Type header allowing manual
deserialization of the response body without guessing as to the content
type.

 - introduce HttpStatusCodeException#getResponseHeaders
 - add constructor with headers param for HttpStatusCodeException,
   HttpClientErrorException and HttpServerErrorException
 - preserve exsisting constructor signatures
 - mark HttpHeaders as Serializable
 - generate new serialVersionUID where needed

Issue: SPR-7938
2012-06-01 16:38:50 +02:00
Chris Beams bca2357be7 Polish web.client exceptions and related classes
The following style updates have been made in anticipation of
substantive changes in subsequent commits:

 - organize imports
 - correct whitespace errors (leading spaces in code, tabs in Javadoc)
 - wrap Javadoc at 90 chars; make imperative ("Return" vs. "Returns")
 - use conventional constructor argument wrapping

A serialVersionUID has also been added to RestClientException and its
ResourceAccessException subclass for consistency with the rest of that
same exception hierarchy.

Issue: SPR-7938
2012-06-01 16:38:38 +02:00
Chris Beams b8ff6c1f86 Update dependencies for spring-aspects
- Explicitly specify compile-time dependencies on other spring-*
   modules, primarily for accuracy in pom generation and ensuring
   minimal dependencies for users of spring-aspects.

 - Remove use of p: namespace from annotation-cache-aspectj.xml to
   avoid parser-related test failures under Eclipse (likely due to
   classpath differences between Gradle and Eclipse).
2012-06-01 15:35:29 +02:00
Chris Beams 706da4f7c2 Fix missing spring-instrument jar manifest entry
The spring-intstrument jar should have a 'Premain-Class:' manifest
entry in order to enable use as a Java agent. This entry was present in
versions 3.1.1 and earlier, but due to build infrastructure changes
starting in 3.2.x this entry was missed. It is now back in place as
expected.

Issue: SPR-9458
2012-06-01 09:58:02 +02:00
Chris Beams 94f839329e Increment version to 3.2.0.BUILD-SNAPSHOT 2012-05-28 23:52:17 +03:00
Spring Buildmaster eec2be05af Release version 3.2.0.M1 2012-05-28 13:22:36 -07:00
Chris Beams da2aa3d35c Test pom generation and update optional deps
Gradle-generated poms thoroughly tested against 3.1.1 versions, with an
eye toward making as many spring-* dependencies optional as possible.

All spring-* modules now declare a Gradle dependency on any other
spring-* module where there is a direct compile-time usage of the
sources in that module. Previously, dependency declarations were
minimal, letting transitive resolution do most of the work. However,
this creates less than ideal poms and is generally not very
informative.

So for example, spring-jdbc uses spring-core, spring-beans and
spring-tx classes directly. Therefore it has the following declarations:

  compile project(":spring-core")
  compile project(":spring-beans")
  compile project(":spring-tx")

spring-core depends on spring-asm, but spring-jdbc does not use
spring-asm classes directly. Therefore spring-jdbc does not declare a
dependency on spring-asm. Transitive resolution is fine in such a case.

As for optional dependencies, it is a matter of degrees what
constitutes optional. A rule of thumb is whether there are legitimate
and likely use cases in which the module can be used without needing
the dependency. spring-jdbc has only one compile-time dependency on
spring-context classes, and that's in JndiDataSourceLookup. It is
certainly reasonable to imagine using spring-jdbc without JNDI,
therefore the spring-context dependency is declared optional as
follows:

  compile(project(":spring-context"), optional) // for JndiDataSourceLookup
2012-05-28 18:16:27 +03:00
Chris Beams b5b46156b1 Rename test versions of @Qualified and @Autowired
Avoid Eclipse classpath conflicts between test versions of @Qualified
and @Autowired living in spring-core and actual versions living in
spring-beans.
2012-05-28 15:04:47 +03:00
Chris Beams f582974b0c Update 3.2 M1 changelog 2012-05-28 11:08:41 +03:00
Sam Brannen 155b88ffce Improve dependency management for spring-test
In Spring 3.1 the spring-test Maven artifact did not have a required
dependency on spring-core, but there is practically no part of
spring-test that can be used without spring-core. Most test utilities
that are intended to be stand-alone utilities in fact use utility
classes from spring-core (e.g., ReflectionTestUtils). Even some of the
web mocks/stubs use spring-core (e.g., DelegatingServletInputStream).

In addition, the current Gradle build configuration for the spring-test
module is very simplistic -- in that it does not explicitly list any
optional dependencies such as the Servlet and Portlet APIs -- and it
defines a 'compile' dependency on spring-webmvc-portlet.

The resulting Maven dependencies in the generated POM are therefore not
what a typical consumer of the spring-test artifact would reasonably
expect.

To address these issues, the Gradle build configuration for the
spring-test module now explicitly defines the following 'compile'
dependencies:

 - spring-core
 - spring-webmvc, optional
 - spring-webmvc-portlet, optional
 - junit, optional
 - testng, optional
 - servlet-api, optional
 - jsp-api, optional
 - portlet-api, optional
 - activation, provided

The only required dependency is now spring-core; all other dependencies
are 'optional'.

Issue: SPR-8861
2012-05-28 11:08:41 +03:00
Juergen Hoeller 9b10d38e41 Fix window state comparison in DAHandlerMapping 2012-05-28 11:08:41 +03:00
Juergen Hoeller 08784f3ba9 Apply cache settings consistently in EhCacheFactoryBean
EhCacheFactoryBean now applies listeners and enabled/disabled flags to
existing cache regions as well.

Issue: SPR-9392
2012-05-28 11:08:41 +03:00
Juergen Hoeller 83fa8e12f0 Add initial support for JCache-compliant providers
Issue: SPR-8774
2012-05-28 11:08:40 +03:00
Sam Brannen 86fabb266a Polish CacheOperationSource 2012-05-28 11:08:40 +03:00
Juergen Hoeller 54f82cd540 Polish caching components 2012-05-28 11:08:40 +03:00
Juergen Hoeller 7ea85a959c Fix MultipartResolver Resin compatibility
StandardServletMultipartResolver#cleanupMultipart now takes care to
delete only actual file parts for Resin compatibility.

Issue: SPR-9299
2012-05-28 11:08:40 +03:00
Juergen Hoeller 2c7d2f7063 Handle non-existent files in ServletContextResource
ServletContextResource#getFile now falls back to #getRealPath for
non-existent files

Issue: SPR-8461
2012-05-28 11:08:40 +03:00
Sam Brannen c8e693b878 Polish SmartValidator and SpringValidatorAdapter
- Improve wording & grammar in SmartValidator Javadoc
 - Suppress 'rawtypes' warnings in SpringValidatorAdapter
2012-05-28 11:08:25 +03:00
Chris Beams f75c01d191 Merge branch cbeams/SPR-6870
* SPR-6870:
  Cache by-type lookups in DefaultListableBeanFactory
  Polish
2012-05-27 18:34:27 +03:00
Chris Beams 4c7a1c0a54 Cache by-type lookups in DefaultListableBeanFactory
Prior to this change, by-type lookups using DLBF#getBeanNamesForType
required traversal of all bean definitions within the bean factory
in order to inspect their bean class for assignability to the target
type. These operations are comparatively expensive and when there are a
large number of beans registered within the container coupled with a
large number of by-type lookups at runtime, the performance impact can
be severe. The test introduced here demonstrates such a scenario clearly.

This performance problem is likely to manifest in large Spring-based
applications using non-singleton beans, particularly request-scoped
beans that may be created and wired many thousands of times per second.

This commit introduces a simple ConcurrentHashMap-based caching strategy
for by-type lookups; container-wide assignability checks happen only
once on the first by-type lookup and are afterwards cached by type
with the values in the map being an array of all bean names assignable
to that type. This means that at runtime when creating and autowiring
non-singleton beans, the cost of by-type lookups is reduced to that of
ConcurrentHashMap#get.

Issue: SPR-6870
2012-05-27 18:09:38 +03:00
Chris Beams db1cb13448 Polish
Issue: SPR-6870
2012-05-27 18:08:14 +03:00