Commit Graph

5185 Commits

Author SHA1 Message Date
Rossen Stoyanchev ca8b98e947 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-9148
2012-04-02 17:36:23 -04:00
Rossen Stoyanchev 0b02933938 Fix race condition in AnntationMethodHER
Issues: SPR-9138
2012-04-02 15:46:31 -04:00
Rossen Stoyanchev 64ee5e579a 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.

Issues: SPR-9134
2012-04-02 15:19:38 -04:00
Rossen Stoyanchev 9833a4c385 Improvement in AntPathMatcher.combine method
Issues: SPR-7970
2012-04-02 15:06:20 -04:00
Chris Beams 4653dbe73f Fix typo in util:constant error reporting
Issue: SPR-9260
2012-03-26 20:08:54 +03:00
Chris Beams 180c5b2ef6 Introduce 3.2 versions of Spring XML namespaces
Copy spring-*-3.1.xsd => spring-*-3.2.xsd; this commit introduces no
substantive changes, but rather prepares for them by creating a clean
baseline. All internal references to 3.1 schemas (e.g. spring-tool) have
also been updated.
2012-03-26 20:06:06 +03:00
Arjen Poutsma d2251a12c3 Fixed illegal characters in JibxUnmarshallerTests
JibxUnmarshallerTests contained UTF-8 characters; this commit changes
those to the \uXXX notation, as all Java source files should be in
Latin-1.
2012-03-20 09:22:49 +01:00
Chris Beams bb5c81e0c5 Merge pull request #58 from sslavic/SPR-7865
* SPR-7865:
  Use configured encoding during JiBX unmarshalling
2012-03-15 15:14:52 +02:00
Stevo Slavic e25183eab1 Use configured encoding during JiBX unmarshalling
Before this change JibxMarshaller did not use the configured encoding
when unmarshalling XML. This caused issues when content being
unmarshalled was not encoded using the default encoding.

This commit fixes the issue by passing configured encoding to JiBX so
it gets used when unmarshalling instead of the default encoding.

Issue: SPR-7865
2012-03-15 15:10:47 +02:00
Chris Beams e3f544904c Fix warnings in LocalSessionFactoryBean 2012-03-09 11:36:56 +02:00
Chris Beams 045c97f75e Support automatic Hibernate dialect detection
Use the preferred SessionFactoryImplementor#getDialect call as
opposed to the previous Dialect#getDialect approach which required
explicitly setting the 'hibernate.dialect' property.

Issue: SPR-7396
2012-03-09 11:36:49 +02:00
Chris Beams 352ed517c5 Fix typo in @ComponentScan Javadoc
With thanks to @abdull for pull request #55
2012-03-09 10:50:44 +02:00
Chris Beams 6d94b74ab1 Move QueryTimeoutException to spring-tx
This change fixes a mistake made during an earlier sync with the 3.1.x
branch in which the new QueryTimeoutException class was accidentally
placed in spring-transaction instead of spring-tx.

Issue: SPR-7680
2012-03-08 12:11:01 +02:00
Rossen Stoyanchev e7e74c83d8 Merge pull request #50 from sslavic/SPR-8732 2012-03-05 06:59:43 -08:00
Stevo Slavic a9f4206151 Generate bracketless tag id in FreeMarker forms
Before this change if FreeMarker Spring form macro was bound to a path
which contains square brackets, those brackets would also appear in id
of generated tag, making the id invalid.

As of this fix all FreeMarker Spring form macros generate tag with id
that does not contain square brackets.

Issue: SPR-8732
2012-03-04 22:02:38 +01:00
Rossen Stoyanchev 9c8332a6c4 Merge pull request #48 from sslavic/SPR-5984 2012-03-02 10:55:03 -08:00
Stevo Slavic 104f13e43f Fix MultipartResolver javadoc implementation refs
Before this fix MultipartResolver javadoc mentioned that there is only
one concrete implementation included in Spring. This was true as of
Spring 2.5 but Spring 3.1 added another one, Servlet 3.0 Part API based
implementation.

This fix changes MultipartResolver javadoc so that the other one,
StandardServletMultipartResolver implementation, gets also listed.
Changed javadoc mentions also as of which version does Spring bundle
two MultipartResolver implementations.

Issue: SPR-5984
2012-03-02 19:00:03 +01:00
Chris Beams 6295f2b591 Merge pull request #44 from mjkrumlauf/patch-1
* patch-1:
  Fix typo in Eclipse import instructions
2012-03-01 20:26:10 +01:00
Mike Krumlauf 35bf5dc592 Fix typo in Eclipse import instructions 2012-03-01 12:46:52 +01:00
Chris Beams 7b703b7e9b Merge pull request #45 from sslavic/SPR-7940
* SPR-7940:
  Remove note on singleton-scoped proxy raising BCE
2012-03-01 12:30:15 +01:00
Stevo Slavic 924c869b8a Remove note on singleton-scoped proxy raising BCE
Before this change bean scopes chapter in Spring reference documentation
had a note which mentioned that creating a scoped proxy for singleton-
or prototype-scoped beans will throw BeanCreationException.

This is no longer the case and this change removes the mentioned note.

Issue: SPR-7940
2012-03-01 12:29:40 +01:00
Chris Beams 833e74168a Merge pull request #46 from pkan/master
* pkan/master:
  Fix typo in spring:eval taglib reference doc
  Fix typo in ApplicationContext reference doc
2012-03-01 12:13:07 +01:00
Phani Kandula 00d9c3f5e8 Fix typo in spring:eval taglib reference doc
- Replace 'javascriptEncoding' with 'javaScriptEscape'

Issue: SPR-9188
2012-03-01 12:12:52 +01:00
Phani Kandula 6c602d7bbc Fix typo in ApplicationContext reference doc
- Add missing '=' sign in sample code for section 4.2.3

Issue: SPR-8856
2012-03-01 12:12:45 +01:00
Chris Beams 15d1d824b5 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-9179
2012-02-29 14:33:29 +01:00
Arjen Poutsma 43b4997e3f Support scanned classes in Jaxb2Marshaller
Jaxb2Marshaller#supports now supports classes found via package
scanning.

Issue: SPR-9152
2012-02-28 09:49:54 +01:00
Arjen Poutsma 83f3750fb3 Support byte[] in JaxbMarshaller under JDK 7
JDK7 changed its reflections API in order to resolve
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5041784

In short, JDK 5 and 6 (wrongly) return GenericArrayTypes in certain
reflection scenarios, whereas JDK 7 changed this to return a normal
array type. For Jaxb2Marshaller, this meant that marshaling byte arrays
was not supported under JDK 7.

This change fixes that, so that Jaxb2Marhsaller supports marshalling
byte arrays again (under JDK 5, 6 or 7).
2012-02-27 11:35:26 +01:00
Chris Beams 7ca5fba05f 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-9161
2012-02-24 14:29:28 +01:00
Chris Beams f4010f14d1 Upgrade to Gradle 1.0-milestone-8a
- Rename customized .wrapper to default gradle/wrapper directory for
   out of the box compatibility with STS Gradle tooling

 - Add .settings/gradle directory to capture defaults when using STS
   Gradle tooling to import projects
2012-02-23 14:17:09 +01:00
Chris Beams 0ff28a6b22 Upgrade to docbook-reference-plugin 0.1.3 2012-02-23 13:34:47 +01:00
Chris Beams f5042d1928 Merge pull request #41 from sslavic/SPR-7843
* SPR-7843:
  Predict specific object type in EhCacheFactoryBean
2012-02-21 19:20:29 +01:00
Stevo Slavic 0690b58878 Predict specific object type in EhCacheFactoryBean
Prior to this change, before a bean is created by EhCacheFactoryBean,
its #getObjectType would return only an Ehcache interface. This caused
unwanted wiring issues as described in the related JIRA issue.

This fix makes use of EhCacheFactoryBean's configuration to determine
the specific Ehcache object type even before it's created, such that
the container is provided with as much information as possible when
resolving dependencies. Nevertheless, users are advised to code to
the Ehcache interface.

Issue: SPR-7843
2012-02-21 19:17:19 +01:00
Chris Beams b2291ff814 Map ORA-30006 to CannotAcquireLockException as well
ORA-00054 is already mapped to CannotAcquireLockException and is
described as

  "resource busy and acquire with NOWAIT specified"

As pointed out in the associated JIRA issue, ORA-30006 is quite similar
being described as

  "resource busy; acquire with WAIT timeout expired"

This commit maps ORA-30006 to CannotAcquireLockException as well.

Issue: SPR-9141
2012-02-21 11:46:42 +01:00
Chris Beams 4df2a14b13 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, SPR-9127
2012-02-20 14:21:51 +01:00
Chris Beams 37d547c506 Sync with 3.1.x
* 3.1.x:
  Warn re Environment construction and instance vars
  Disallow empty @PropertySource(value = {})
  Fix @PropertySource bug with multiple values
  final preparations for 3.1.1 release
  added "receive-timeout" attribute to "jms:listener-container" element
2012-02-20 14:19:04 +01: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
Chris Beams 624ba720d5 Add link to contributor guidelines in readme 2012-02-16 13:13:44 +01:00
Chris Beams 3e81482760 Sync with 3.1.x
* 3.1.x:
  Demonstrate use of @Configuration as meta-annotation
  Prune dead code from JmsTransactionManager#doBegin
  Apply @Configuration BeanNameGenerator consistently
  Improve @Configuration bean name discovery
  Fix infinite recursion bug in nested @Configuration
  Polish static imports
  Minor fix in ServletResponseMethodArgumentResolver
  extracted ResourceUtils.useCachesIfNecessary(URLConnection) method (SP
  prepared for 3.1.1 release
  CustomSQLExceptionTranslatorRegistry/Registrar etc
  revised CustomSQLExceptionTranslatorRegistry/Registrar method naming
  use custom InputStream traversal instead of a full byte array (SPR-911
  PathMatchingResourcePatternResolver preserves caching for JNLP jar con
  Resource "contentLength()" implementations work with OSGi bundle resou
  fixed MethodInvokingJobDetailFactoryBean for compatibility with Quartz
  fixed MethodInvokingJobDetailFactoryBean for compatibility with Quartz
2012-02-16 13:00:28 +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