Commit Graph

3242 Commits

Author SHA1 Message Date
Sam Brannen 8fdc7d4e8f Polish type prediction for generic factory methods
- Now avoiding NullPointerExceptions in GenericTypeResolver's
   resolveReturnTypeForGenericMethod() in case the supplied ClassLoader
   is null.
 - AutowireUtils.resolveReturnTypeForFactoryMethod() now properly
   asserts that the supplied ClassLoader is not null.
 - Fixed copy-n-paste errors in Javadoc for
   AutowireUtils.resolveReturnTypeForFactoryMethod().

Issue: SPR-10411
2013-10-15 15:21:47 +02:00
Sam Brannen e86e182d5d Reinstate deleted @author tag
SPR-10411
2013-10-15 15:09:05 +02:00
Juergen Hoeller 3bd6dfe047 Autowiring of generic types
Includes revisions of MethodParameter and DependencyDescriptor (in particular towards a reference to the containing class). Also refines several ResolvableType method signatures.

Issue: SPR-9965
2013-10-15 00:11:23 +02:00
Juergen Hoeller 8b1927f3ec Fixed type prediction for generic factory methods
We're consistently resolving class names now, and the entire algorithm moved from GenericTypeResolver to the internal AutowireUtils helper in the bean factory package.

Issue: SPR-10411
2013-10-14 23:50:04 +02:00
Sam Brannen 977c8c7137 Polish Javadoc for ResolvableType 2013-10-14 17:57:16 +02:00
Phillip Webb ee8f1aa61a Clarify ResolvableType.resolve() Java Doc
Issue: SPR-10973
2013-10-10 11:58:21 -07:00
Phillip Webb 5358cc0f5f Fix ResolvableType isAssignableFrom for <?>
Fix ResolvableType.isAssignableFrom to correctly deal with <?> style
generics.

Issue: SPR-10973
2013-10-10 09:22:22 -07:00
Phillip Webb 501a1cbb5d Refactor from deprecated GenericTypeResolver calls
Refactor AbstractMessageConverterMethodArgumentResolver and
BridgeMethodResolver to use ResolvableType in preference to deprecated
GenericTypeResolver calls.

Issue: SPR-10980
2013-10-10 00:19:51 -07:00
Phillip Webb fdf0ef40c0 Use ResolvableType in GenericCollectnTypeResolver
Refactor GenericCollectionTypeResolver to make use of ResolvableType
for generic resolution.

Issue: SPR-10977
2013-10-10 00:19:51 -07:00
Phillip Webb 595efe9aab Use ResolvableType in GenericTypeResolver
Refactor GenericTypeResolver to make use of ResolvableType
for generic resolution.

Issue: SPR-10978
2013-10-10 00:19:51 -07:00
Phillip Webb 6a18b0048d Introduce ResolvableType Class
Add a new ResolvableType Class which encapsulates java.lang.reflect.Type,
providing access to supertypes, interfaces and generic parameters along
with the ability to ultimately resolve to a java.lang.Class.

ResolvableTypes may be obtained from fields, method parameters, method
returns, classes or directly from a java.lang.reflect.Type. Most methods
will themselves return ResolvableTypes, allowing easy navigation.

For example:

	private HashMap<Integer, List<String>> myMap;

	public void example() {
 		ResolvableType t = ResolvableType.forField(
 					getClass().getDeclaredField("myMap"));
 		t.getSuperType(); // AbstractMap<Integer, List<String>>;
 		t.asMap(); // Map<Integer, List<String>>
 		t.getGeneric(0).resolve(); // Integer
 		t.getGeneric(1).resolve(); // List
 		t.getGeneric(1); // List<String>
 		t.resolveGeneric(1, 0); // String
 	}

Issue: SPR-10973
2013-10-10 00:19:50 -07:00
Juergen Hoeller 4574528a27 Comprehensive update to the framework's TimeZone handling, including a new TimeZoneAwareLocaleContext and a LocaleContextResolver for Spring MVC
A few noteworthy minor changes: LocaleContext.getLocale() may return null in special cases (not by default), which our own accessing classes are able to handle now. If there is a non-null TimeZone user setting, we're exposing it to all collaborating libraries, in particular to JSTL, Velocity and JasperReports. Our JSR-310 and Joda-Time support falls back to checking the general LocaleContext TimeZone now, adapting it to their time zone types, if no more specific setting has been provided. Our DefaultConversionService has TimeZone<->ZoneId converters registered. And finally, we're using a custom parseTimeZoneString method now that doesn't accept the TimeZone.getTimeZone(String) GMT fallback for an invalid time zone id anymore.

Issue: SPR-1528
2013-10-04 23:14:08 +02:00
Juergen Hoeller bd4c64af04 Turned ByteBufferConverter's visibility to package level 2013-10-04 22:52:14 +02:00
Phillip Webb 8abe949734 Fix ArrayStoreException reading subclassed enums
Fix ASM AnnotationAttributesReadingVisitor to correctly deal with
subclasses enums.

Issue: SPR-10914
2013-09-27 11:25:57 -07:00
Rob Winch 0ee910c61a Add test for StandardReflectionParameterNameDiscoverer
Added test to StandardReflectionParameterNameDiscoverer that
demonstrates discovering of parameter names on an interface.

Issue: SPR-9643
2013-09-13 21:23:44 -07:00
Sam Brannen 41fffdcf7b Polish Javadoc in ResourceUtils 2013-09-12 16:28:14 +02:00
Arjen Poutsma d0aa158aef Added ListenableFuture interface
Added extension to Future with capabilities for registering callbacks
when the future is complete.

- Added ListenableFuture, ListenableFutureCallback,
  ListenableFutureCallbackRegistry, and ListenableFutureTask.
- Using ListenableFuture in AsyncRestOperations/AsyncRestTemplate.
- Added AsyncListenableTaskExecutor, implemented in
  SimpleAsyncTaskExecutor.
- Added FutureAdapter and ListenableFutureAdapter.
2013-09-04 14:32:47 +02:00
Juergen Hoeller caa1218d36 Polishing 2013-08-29 19:17:59 +02:00
Juergen Hoeller c664010001 Added conversion support for Java 8's ZoneId class and the 'of' method convention
Issue: SPR-1528
2013-08-29 19:15:22 +02:00
Antonio Marrero 57f7b14b49 Assign lowest priority to `/**` pattern
Update AntPathMatcher Comparator to treat `/**` in the same way as
`null` paths.

Prior to this commit the pattern `/**` would be picked in preference
to patterns with 3 or more PathVariable (e.g. `/matches/{matchId}/
periods/{periodId}/teams/{teamId}/results`).

Issue: SPR-10550
2013-08-28 17:14:37 -07:00
Phillip Webb c1dafed886 Refine AntPathMatcher.combine when p1 contains '.'
Refine AntPathMatcher.combine rules to allow direct concatenation of
patterns when pattern1 does not contain '*.'. Prior to this commit
direct concatenation was allowed when pattern1 did not contain '.',
this prevented calls of the form:

	pathMatcher.combine("/1.0", "/foo/test")

from working as expected.

This commit also applies some general cleanup to the `combine` method.

Issue: SPR-10554
2013-08-28 14:30:08 -07:00
Juergen Hoeller 465e6292eb Javadoc fixes 2013-08-28 22:16:08 +02:00
Juergen Hoeller 4447248a83 Introduced support for @Lazy on injection points
This turned into a rather huge affair since it led to the introduction of a new AutowireCandidateResolver implementation in the spring-context module. That ACR impl is now being set through AnnotationConfigUtils; GenericApplicationContext and co do not set a default QualifierAnnotationAutowireCandidateResolver anymore (which has always been a smell anyway).  At the same time, dependency ordering has moved from AutowiredAnnotationBeanPostProcessor to DefaultListableBeanFactory itself through a "dependencyComparator" strategy, applying to constructor dependencies and lazy resolution proxies as well.

Issue: SPR-10353
2013-08-28 00:14:39 +02:00
Juergen Hoeller 8f90eacd92 Polishing 2013-08-26 20:04:40 +02:00
Rossen Stoyanchev 1fd7bc3ee5 Make MediaType serializable
Issue: SPR-8738
2013-08-22 16:05:44 -04:00
Juergen Hoeller 4a9af233ae @Autowired/@Inject with array/List value gets sorted against Ordered/@Order
Issue: SPR-5574
2013-08-22 16:43:10 +02:00
Juergen Hoeller f2fb0ec9e7 Minor polishing of related files
Issue: SPR-10181
2013-08-21 17:37:06 +02:00
Juergen Hoeller 6d3649858e Allow meta-annotations to override attributes from their parent
Issue: SPR-10181
2013-08-21 17:35:56 +02:00
Juergen Hoeller ea6525f15f GenericTypeResolver properly handles bound parameterized type
Issue: SPR-10819
2013-08-20 19:36:57 +02:00
Juergen Hoeller 1420b970a7 Introduced DefaultParameterNameDiscoverer which checks JDK 8's standard reflection first and then falls back to ASM-based debug symbol analysis
Also, StandardReflectionParameterNameDiscoverer calls "Parameter.isNamePresent()" now to return null (and pass on to the next discoverer) if no JDK 8 parameters are available. Note that this requires OpenJDK 8 b100 or higher to compile now.

Issue: SPR-10532
2013-08-08 15:52:43 +02:00
Rossen Stoyanchev eb4579b4d4 Extract MimeType as a base class of MediaType
MimeType is available in core-spring and does not include support
for quality parameters and media used in HTTP content negotiation.
The MediaType sub-class in org.springframework.http adds q-parameters.
2013-08-07 13:21:37 -04:00
Rossen Stoyanchev 15a2f03459 Polish SockJS exception handling and javadoc
See javadoc in SockJsService for details.

Also remove ReadOnlyMultiValueMap, CollectionUtils has a method for
that already.
2013-08-03 11:03:27 -04:00
Rossen Stoyanchev a03517fa35 Polish ServletServerHttpRequest query param handling
The method returning query parameters now returns only query string
parameters as opposed to any Servlet request parameter.

This commit also adds a ReadOnlyMultiValueMap.
2013-08-02 17:40:08 -04:00
Juergen Hoeller 85c9ed005d Fixed misunderstanding with respect to excludeUnlistedClasses default in JPA 2.0
Issue: SPR-10767
(cherry picked from commit d0948f1)
2013-08-01 00:20:21 +02:00
Juergen Hoeller 127b91fd4f PropertySourcesPlaceholderConfigurer's "ignoreUnresolvablePlaceholders" setting reliably applies to nested placeholders as well
Issue: SPR-10549
2013-07-31 17:50:44 +02:00
Rob Winch f7c0795c1a Add TestGroup.CUSTOM_COMPILATION
Previously building with JDK > 1.8 b88 caused test failures due to errors
with custom compilers like Jibx and Jasper reports.

This commit adds a new TestGroup named CUSTOM_COMPILATION that allows the
CI server to continue to run these tests but allow committers to ignore
these tests.
2013-07-24 09:29:17 -05:00
Juergen Hoeller 2d1b44202b OpenJDK 8 build 99: annotation discovery on bridge methods 2013-07-24 13:36:59 +02:00
Nick Williams e59c821603 Fix PathResourceTests on Windows
Fix PathResourceTests so that paths are accessed in a platform
independent manor.

Issue: SPR-10770
2013-07-23 14:48:25 -07:00
Phillip Webb 9eb596a7e5 Make TypeDescriptor serializable
Issue: SPR-10631
2013-07-23 14:17:19 -07:00
Phillip Webb 587877c6da Add MemorySafeUndeclaredThrowableStrategy
Port the latest unreleased UndeclaredThrowableStrategy implementation
from cglib to fix a memory-leak present in v3.

Issue: SPR-10709
2013-07-19 14:36:19 -07:00
Phillip Webb 9dba73dfc9 Add ConversionService support for ByteBuffers
Add ByteBufferConverter that is registered by default with the
DefaultConversionService. Allows conversion from/to a ByteBuffer and
byte[] or to any type that can be converted via a byte[].

Issue: SPR-10712
2013-07-01 13:12:52 -07:00
Sam Brannen f311bf3daf Introduce TCP & UDP server port scanning utility
Prior to this commit the Spring Framework did not provide a public means
for scanning for available server ports. However, the Spring Framework
internally used a FreePortScanner in integration tests within its own
test suite. Furthermore, Spring Integration 2.2 provides similar support
in a SocketUtils class in the spring-integration-test module.

This commit introduces SocketUtils in spring-core to replace the
FreePortScanner which was previously only used internally within
Spring's test suite. This new implementation is inspired by both Spring
Framework's FreePortScanner and Spring Integration's SocketUtils and
consequently attempts to merge the best of both previous
implementations.

Issue: SPR-8032
2013-06-15 13:46:32 +02:00
Sam Brannen 97d152547d Reformatted GenericTypeResolverTests 2013-06-09 00:24:37 +02:00
Phillip Webb 5377fae7f5 Remove duplicate Javadoc line from PathResource
Remove duplicate Javadoc comment from PathResource that was
accidentally introduced during the merge.

Issue: SPR-10608
2013-06-03 22:10:57 -07:00
Philippe Marschall 2313c9a007 Introduce java.nio.file.Path based Resource
Develop new org.springframework.core.io.Resource implementation
backed by java.nio.file.Path. Primarily developed to allow custom
file system implementations to be used with Spring.

Since the minimum requirement for Spring is still Java 6 the
existing FileSystemResource can't be retrofitted (and no #getPath
method can be added to the Resource interface).

Unlike FileSystemResource, PathResource delegates to the underlying
file system instead of StringUtils. It has therefore slightly
different semantics. First, when building relative resources via
createRelative the relative path will apply to this path (like URL or
Unix). Second, equality is delegated to the underlying file system
provider so it's case-insensitive on Windows.

Issue: SPR-10608
2013-06-03 16:25:45 -07:00
Chris Beams 46d47fef9a Polish pull request #291 per committer guidelines
- Update Apache license headers
 - Remove trailing whitespace
 - Edit original commit comment to use 'Issue:' syntax
 - Revert use of diamond operator (<>) in main sources

See committer guidelines at
https://github.com/SpringSource/spring-framework/blob/master/CONTRIBUTING.md

Issue: SPR-10579
2013-05-28 13:51:35 +02:00
Dave Syer 7860af8624 Make CommandLinePropertySource enumerable
JOpt 4.4 has enumerable options, so this change can be made
if we upgrade. The only awkward thing is that JOpt allows
aliases for options, so we have to pick one to avoid double
counting. This implementation picks the last one in the list
which is the alphebtically last of the long options, if there
are any (e.g. "o1", "option1" returns "option1"). Most of the
time there will only be one or two aliases for each option so
it won't matter.

Issue: SPR-10579
2013-05-28 12:57:01 +02:00
Phillip Webb 6fe50b502f Enforce JDK version on CI server
Add a test to ensure that the CI server does not accidentally build
with the wrong JDK version.

Issue: SPR-10569
2013-05-16 17:06:30 -07:00
Juergen Hoeller 814d24e64f Consistent detection of Order annotation in superclasses and interfaces
Issue: SPR-10514
2013-05-16 18:05:56 +02:00
Juergen Hoeller 16548d23e9 Consistent use of Class<?> in Assert 2013-05-16 16:10:36 +02:00
Juergen Hoeller 7e01578515 Avoid unnecessary creation of default StandardEnvironment instances
Issue: SPR-10568
2013-05-15 23:41:32 +02:00
Juergen Hoeller 25e29b851d GenericTypeResolver defensively calls Class.getGenericSuperclass() and consistently uses Class<?>
Issue: SPR-10559
2013-05-14 16:02:52 +02:00
Rob Winch 9468548116 Add @Override to remaining source files
Issue: SPR-10130
2013-05-13 17:04:56 -05:00
Juergen Hoeller 1f0f46fb06 ServletContextResourcePatternResolver uses encoded jar file location for UrlResource
Adding overloaded constructors for URI specification to UrlResource, as a convenience.

Issue: SPR-10471
2013-05-10 22:11:40 +02:00
Phillip Webb 8e445f3a21 Extend AnnotationMetadata and MethodMetadata
Update AnnotationMetadata and MethodMetadata to extend from a new
AnnotatedTypeMetadata base interface containing the methods that are
common to both. Also introduce new getAllAnnotationAttributes methods
providing MultiValueMap access to both annotation and meta-annotation
attributes.

Existing classreading and standard implementations have been
refactored to support the new interface.
2013-05-08 19:41:20 -07:00
Phillip Webb 0652febe34 Make Make ClassPathContextResource protected
Allow ClassPathContextResource to be accessed by subclasses of
DefaultResourceLoader.

Issue: SPR-10544
2013-05-08 15:16:43 -07:00
Juergen Hoeller 2a44228b98 Consistent use of <pre class="code">
Issue: SPR-8108
2013-05-07 21:31:26 +02:00
Phillip Webb e1c25ff1a3 Workaround jasper report test fail on OSX
Add temporary Assume.canLoadNativeDirFonts() method allowing failing
jasper report tests to be bypassed on OSX.

This should be revisited when JDK 8 is released.

Issue: SPR-10537
2013-05-07 08:23:46 -07:00
Phillip Webb 2c887248f0 Make SpringFactoriesLoader.loadFactoryNames public
Update the SpringFactoriesLoader static loadFactoryNames method from
private to public.

Issue: SPR-10528
2013-05-06 15:32:52 -07:00
Sam Brannen 95c1255452 Updated JdkVersion regarding Java 9 support
- JdkVersion#JAVA_19 is now properly set to 6 instead of 5.
 - Javadoc for getMajorJavaVersion() now references currently supported
   Java versions.
2013-05-05 16:19:11 +02:00
Juergen Hoeller b9ca0fb947 Compatibility of JDK 8 compiled reflection API usage with JDK <8 runtimes
Specifically, we need to avoid "... ? this.method : this.constructor" expressions since those potentially select java.lang.reflect.Executable (which is only available on JDK 8) as common type and hardcode this into the generated bytecode (which therefore becomes JDK 8 dependent).
2013-05-03 17:28:58 +02:00
Juergen Hoeller 0a8f5b2919 Removed deprecated helper classes and methods (that have been deprecated since 3.0 or before) 2013-05-02 17:25:10 +02:00
Juergen Hoeller 9f9b972f00 Prepared for JDK 1.9
Aiming for the JdkVersion class to support one generation ahead now, in order for the test suite to properly detect 1.7/1.8+ JVMs even when running against a JDK 1.9 preview at some point.
2013-05-02 11:40:16 +02:00
Juergen Hoeller 0ea17c8382 Allow for reuse of key visitor classes in tooling
Based on https://github.com/SpringSource/spring-framework/pull/263
2013-04-30 21:31:22 +02:00
Juergen Hoeller 06fdfb0b0d Fixed annotation attribute processing for enum arrays
Based on https://github.com/SpringSource/spring-framework/pull/263
2013-04-30 21:30:27 +02:00
Juergen Hoeller 506f6a7c57 Adapter for JDK 8's standard parameter name reflection facilities
Issue: SPR-9643
2013-04-23 14:00:24 +02:00
Juergen Hoeller cd996ba18f Upgrading to JDK 1.8 bytecode along with ASM 4.1 patch
ASM has been patched to accept 1.8 bytecode simply through removing an assertion. As a consequence, we have an embedded copy of the ASM sources now instead of jarjar'ing the original ASM jar. The sources originate from ASM 4.1; for CGLIB 3.0 compatibility, a further assertion has been removed.

Issue: SPR-9639
2013-04-23 13:57:26 +02:00
Juergen Hoeller d3a4068768 Minimized ASM usage
In particular, avoid accidental usage of ASM for core JDK types - which will fail in case of a new bytecode version in the JDK, even if the application itself has been compiled with an earlier bytecode target.

Issue: SPR-10292
2013-04-23 13:49:25 +02:00
Juergen Hoeller e11cf5f061 Upgraded JdkVersion and CollectionFactory to JDK 1.6+, also removing deprecated methods from CollectionFactory 2013-03-28 23:27:17 +01:00
Juergen Hoeller 5472e975f6 Removed deprecated core.enums package 2013-03-19 23:31:50 +01:00
Juergen Hoeller ebb3d32ea8 Removed deprecated core.enums package 2013-03-19 23:14:55 +01:00
Juergen Hoeller 9c52ae9558 Removed OC4J support (including documentation references) 2013-03-19 14:53:26 +01:00
Juergen Hoeller 7f0a780925 StaxUtils relies on JAXP 1.4 (as included in JDK 1.6+) 2013-03-19 13:15:05 +01:00
Juergen Hoeller 87e5f19c3f JDK 1.6+ API baseline across the codebase 2013-03-19 13:10:25 +01:00
Phillip Webb 4e1cab28df Merge branch '3.2.x'
* 3.2.x: (28 commits)
  Hide 'doc' changes from jdiff reports
  Document @Bean 'lite' mode vs @Configuration
  Final preparations for 3.2.2
  Remove Tiles 3 configuration method
  Polishing
  Extracted buildRequestAttributes template method from FrameworkServlet
  Added "beforeExistingAdvisors" flag to AbstractAdvisingBeanPostProcessor
  Minor refinements along the way of researching static CGLIB callbacks
  Compare Kind references before checking log levels
  Polish Javadoc in RequestAttributes
  Fix copy-n-paste errors in NativeWebRequest
  Fix issue with restoring included attributes
  Add additional test for daylight savings glitch
  Document context hierarchy support in the TCF
  Fix test for daylight savings glitch
  Make the methodParameter field of HandlerMethod final
  Disable AsyncTests in spring-test-mvc
  Reformat the testing chapter
  Document context hierarchy support in the TCF
  Document context hierarchy support in the TCF
  ...
2013-03-13 14:01:46 -07:00
Sam Brannen 98074e7762 Provide support for context hierarchies in the TCF
Prior to this commit the Spring TestContext Framework supported creating
only flat, non-hierarchical contexts. There was no easy way to create
contexts with parent-child relationships.

This commit addresses this issue by introducing a new @ContextHierarchy
annotation that can be used in conjunction with @ContextConfiguration
for declaring hierarchies of application contexts, either within a
single test class or within a test class hierarchy. In addition,
@DirtiesContext now supports a new 'hierarchyMode' attribute for
controlling context cache clearing for context hierarchies.

- Introduced a new @ContextHierarchy annotation.
- Introduced 'name' attribute in @ContextConfiguration.
- Introduced 'name' property in ContextConfigurationAttributes.
- TestContext is now aware of @ContextHierarchy in addition to
  @ContextConfiguration.
- Introduced findAnnotationDeclaringClassForTypes() in AnnotationUtils.
- Introduced resolveContextHierarchyAttributes() in ContextLoaderUtils.
- Introduced buildContextHierarchyMap() in ContextLoaderUtils.
- @ContextConfiguration and @ContextHierarchy may not be used as
  top-level, class-level annotations simultaneously.
- Introduced reference to the parent configuration in
  MergedContextConfiguration and WebMergedContextConfiguration.
- Introduced overloaded buildMergedContextConfiguration() methods in
  ContextLoaderUtils in order to handle context hierarchies separately
  from conventional, non-hierarchical contexts.
- Introduced hashCode() and equals() in ContextConfigurationAttributes.
- ContextLoaderUtils ensures uniqueness of @ContextConfiguration
  elements within a single @ContextHierarchy declaration.
- Introduced CacheAwareContextLoaderDelegate that can be used for
  loading contexts with transparent support for interacting with the
  context cache -- for example, for retrieving the parent application
  context in a context hierarchy.
- TestContext now delegates to CacheAwareContextLoaderDelegate for
  loading contexts.
- Introduced getParentApplicationContext() in MergedContextConfiguration
- The loadContext(MergedContextConfiguration) methods in
  AbstractGenericContextLoader and AbstractGenericWebContextLoader now
  set the parent context as appropriate.
- Introduced 'hierarchyMode' attribute in @DirtiesContext with a
  corresponding HierarchyMode enum that defines EXHAUSTIVE and
  CURRENT_LEVEL cache removal modes.
- ContextCache now internally tracks the relationships between contexts
  that make up a context hierarchy. Furthermore, when a context is
  removed, if it is part of a context hierarchy all corresponding
  contexts will be removed from the cache according to the supplied
  HierarchyMode.
- AbstractGenericWebContextLoader will set a loaded context as the
  ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE in the MockServletContext when
  context hierarchies are used if the context has no parent or if the
  context has a parent that is not a WAC.
- Where appropriate, updated Javadoc to refer to the
  ServletTestExecutionListener, which was introduced in 3.2.0.
- Updated Javadoc to avoid and/or suppress warnings in spring-test.
- Suppressed remaining warnings in code in spring-test.

Issue: SPR-5613, SPR-9863
2013-03-07 02:11:11 +01:00
Phillip Webb 05765d7520 Replace EasyMock with Mockito
Issue: SPR-10126
2013-03-06 11:06:15 -08:00
Chris Beams ce4be3b46b Merge branch '3.2.x' into master
Conflicts:
	gradle.properties
	spring-beans/src/main/java/org/springframework/beans/factory/support/StaticListableBeanFactory.java
	spring-context-support/src/main/java/org/springframework/cache/ehcache/EhCacheManagerFactoryBean.java
	spring-core/src/main/java/org/springframework/core/convert/support/StringToEnumConverterFactory.java
	spring-core/src/main/java/org/springframework/core/env/ReadOnlySystemAttributesMap.java
	spring-jdbc/src/main/java/org/springframework/jdbc/datasource/LazyConnectionDataSourceProxy.java
	spring-jdbc/src/main/java/org/springframework/jdbc/support/lob/AbstractLobHandler.java
	spring-web/src/main/java/org/springframework/http/client/BufferingClientHttpRequestWrapper.java
	spring-web/src/main/java/org/springframework/http/client/SimpleBufferingClientHttpRequest.java
	spring-web/src/main/java/org/springframework/http/converter/BufferedImageHttpMessageConverter.java
	spring-web/src/main/java/org/springframework/http/converter/FormHttpMessageConverter.java
2013-03-04 15:41:15 +01:00
Rossen Stoyanchev 33e723b4a8 Fix AntPathMatcher rule for combining with extensions
Before this fix AntPathMatcher had a special rule for combining
patterns with wildcards and extensions as follows:

"/*.*"  + "/*.html" => "/*.html"

This change ensures this rule never applies if the first pattern
contains URI variables.

Issue: SPR-10062
2013-03-01 16:30:02 -05:00
Sam Brannen 9b72bf4691 Update @since tag for StreamUtils 2013-02-28 01:39:15 +01:00
Chris Beams 9a48c10dcb Segregate tests that depend on the jmxmp: protocol
This commit introduces TestGroup#JMXMP and adds assumptions to related
tests accordingly. These tests require the jmxoptional_remote jar on the
classpath, and are run nightly in the SPR-PERF build.

Issue: SPR-8089
2013-02-26 16:52:29 +01:00
Chris Beams 55caf7bdb0 Improve diagnostics for invalid testGroup values 2013-02-26 16:46:13 +01:00
Phillip Webb 009d2a5efd Remove unnecessary null check in SysEnvPropSource
Remove unnecessary null check and dead code from
SystemEnvironmentPropertySource.

Issue: SPR-10318
2013-02-25 15:35:13 -08:00
Phillip Webb 9a6c6b9ee6 StringToEnumConverterFactory class from enum value
Update StringToEnumConverterFactory to search superclasses until
Class.isEnum() returns true. This allows conversion when the
enum class is obtained from the enum value:

    public static enum SubFoo {
        BAR { String s() { return "x"; } };
        abstract String s();
    }

    conversionService.convert("BAR", SubFoo.BAR.getClass())

This fix is particularly important when converting collections of
enums.

Issue: SPR-10329
2013-02-25 13:25:44 -08:00
Juergen Hoeller 5e64723e02 Catch ASM ClassReader's IllegalArgumentException and turn it into a more expressive exception, hinting at the class file version
Issue: SPR-10292
2013-02-15 18:31:22 +01:00
Phillip Webb 953b2b60ad Javadoc polish 2013-02-13 11:58:21 -08:00
Phillip Webb 6661788748 Ensure HTTP classes don't close streams
Prior to this commit several HTTP classes made use of FileCopyUtils
when reading from or writing to streams. This has the unfortunate
side effect of closing streams that should really be left open.

The problem is particularly noticeable when dealing with a
FormHttpMessageConverter that is writing a multi-part response.

Relevant HTTP classes have now been refactored to make use of a new
StreamUtils class that works in a similar way FileCopyUtils but does
not close streams.

The NonClosingOutputStream class from SimpleStreamingClientHttpRequest
has also been refactored to a StreamUtils method.

Issue: SPR-10095
2013-02-11 19:04:53 -08:00
Juergen Hoeller 93e6238f92 Polishing 2013-02-11 21:52:04 +01:00
Juergen Hoeller e9db785799 Polishing 2013-02-10 21:10:58 +01:00
Phillip Webb 7bbb4ec7af Fix Assert.instanceOf exception message
Update the exception message used when Assert.instanceOf fails such
that it expects the provided message to end with '.'. This reverts
commit 5874383ef0 which caused the
implementation to be at odds with the JavaDoc and the previous
release.

The updated code also has the benefit of protecting against a null
message.

Issue: SPR-10269
2013-02-07 13:35:31 -08:00
Phillip Webb f464a45ba4 Polish formatting
Minor formatting polish across that codebase. Primarily fixing
whitespace issues.
2013-02-04 10:35:25 -08:00
Phillip Webb aac6b913d6 Merge branch 'cleanup-3.2.x' into 3.2.x
* cleanup-3.2.x:
  Fix unnecessary @SupressWarnings annotations
  Fix Javadoc warnings
  Fix unused local variable warnings
  Fix unused type compiler warnings
  Fix 'is already an instance of type' warnings
2013-01-31 12:52:51 -08:00
Juergen Hoeller a694db2933 Removed logging from GenericTypeResolver's resolveReturnTypeForGenericMethod
GenericTypeResolver is very low-level and quite a hotspot, so let's not do any logging there and rather use the debugger instead.
2013-01-31 18:01:01 +01:00
Phillip Webb d89e30b864 Fix unnecessary @SupressWarnings annotations 2013-01-29 15:37:25 -08:00
Phillip Webb 2b0d860923 Fix Javadoc warnings 2013-01-25 17:31:33 -08:00
Phillip Webb 065b1c0e46 Fix unused local variable warnings 2013-01-25 14:35:19 -08:00
Phillip Webb 6a1e841952 Fix unused type compiler warnings 2013-01-25 14:35:07 -08:00
Chris Beams 39c00c489e Avoid UnsupportedOperationEx. with active SecurityManager
Issue: SPR-9970
2013-01-24 15:08:07 +01:00
Juergen Hoeller 078a1c5db8 Made EncodedResource based variant public; consistently detect XML properties across all variants
Issue: SPR-9078
2013-01-24 14:56:45 +01:00
Juergen Hoeller 575926932d Polishing 2013-01-23 22:17:48 +01:00
Juergen Hoeller e5d9378482 Removed pre-JDK-1.5 checks 2013-01-23 22:17:38 +01:00
Juergen Hoeller 049169d19f ResourcePropertyResource accepts EncodedResource for properties files with a specific encoding
Also added constructor with Charset argument to EncodedResource.

Issue: SPR-10096
2013-01-23 22:16:35 +01:00
Sam Brannen a1aba23aa9 Polish Javadoc in TypeDescriptor
- fix @since version in array()
- format method-level Javadoc
- unescape HTML-escaped angle brackets with {@code} blocks
2013-01-23 16:47:23 +01:00
Phillip Webb 9c032d52d4 Allow TypeDescriptor array construction
Add a static factory method that can be used to create an array
TypeDescriptor with a specific element type. Allows array types
with generic elements to be constructed.

Issue: SPR-9792
2013-01-22 15:35:43 -08:00
Phillip Webb 4d01d43c19 Test String to char[] conversion
Issue: SPR-9793
2013-01-22 14:36:38 -08:00
Chris Beams 3a626f9319 Support XML properties in ResourcePropertySource
JDK 5 introduced an XML-based properties file syntax. This commit
ensures that when such files are supplied as the underlying resource
for a ResourcePropertySource instance, they are routed appropriately
to Properties#loadFromXML as opposed to Properties#load.

Issue: SPR-9896
2013-01-22 14:14:15 +01:00
Chris Beams d9a4fb410d Introduce "dummy" Environment implementation
For testing purposes in which an Environment implementation is required
but a ConfigurableEnvironment is not desirable.

All methods are no-ops and return null, therefore NPEs are likely.
2013-01-22 11:33:37 +01:00
Chris Beams cb8dc73fbb Attempt to repro ReflectionUtils performance issue
Issue: SPR-10197
2013-01-21 14:03:36 +01:00
Juergen Hoeller 8c9383da7c BridgeMethodResolver properly handles bridge methods in interfaces
Issue: SPR-9330
2013-01-18 15:00:00 +01:00
Juergen Hoeller ed952ccba1 LocalVariableTableParameterNameDiscoverer works for bridge methods as well
Issue: SPR-9429
2013-01-18 14:52:24 +01:00
Juergen Hoeller 2cd23a79a3 Polishing 2013-01-15 22:09:16 +01:00
Sam Brannen 8694a0aac0 Minor changes to AnnotationUtils
- Polished Javadoc for isAnnotationDeclaredLocally() and
  isAnnotationInherited().
- Removed unnecessary call to Arrays.asList() in
  isAnnotationDeclaredLocally().
2013-01-14 12:24:12 +01:00
Juergen Hoeller e806c4eb3d AnnotationAwareOrderComparator is able to sort Class objects as well
Issue: SPR-10152
2013-01-10 17:00:46 +01:00
Juergen Hoeller dae4485155 Added dedicated sort method to AnnotationAwareOrderComparator
Issue: SPR-9625
2013-01-10 17:00:45 +01:00
Rossen Stoyanchev f185c3a3c1 Add option to not trim path segments in AntPathMatch
Issue: SPR-8687
2013-01-08 12:03:51 -05:00
Chris Beams 662a02b952 Fix several miscellaneous compiler/Eclipse warnings
- Suppress an (intentional) AspectJ warning
 - Remove unused imports
 - Suppress a [hiding] warning
 - Fix a generics warning related to extension of final types

Issue: SPR-9431
2013-01-04 11:41:49 +01:00
Chris Beams b836e14b5f Merge branch 'cleanup-test-duplicates' into cleanup-3.2.x
* cleanup-test-duplicates:
  Update Apache license headers for affected sources
  Remove duplicate test classes
  Replace test beans with test objects

Conflicts:
	spring-beans/src/test/java/org/springframework/beans/factory/ConcurrentBeanFactoryTests.java
	spring-beans/src/test/java/org/springframework/beans/support/PagedListHolderTests.java
2013-01-04 10:31:31 +01:00
Chris Beams d1e6dbe74a Update Apache license headers for affected sources 2013-01-04 10:29:11 +01:00
Phillip Webb 42b5d6dd7e Remove duplicate test classes
Prior to this commit many test utility classes and sample beans were
duplicated across projects. This was previously necessary due to the
fact that dependent test sources were not shared during a gradle
build. Since the introduction of the 'test-source-set-dependencies'
gradle plugin this is no longer the case.

This commit attempts to remove as much duplicate code as possible,
co-locating test utilities and beans in the most suitable project.
For example, test beans are now located in the 'spring-beans'
project.

Some of the duplicated code had started to drift apart when
modifications made in one project where not ported to others. All
changes have now been consolidated and when necessary existing tests
have been refactored to account for the differences.

Conflicts:
	spring-beans/src/test/java/org/springframework/beans/factory/ConcurrentBeanFactoryTests.java
	spring-beans/src/test/java/org/springframework/beans/factory/support/BeanFactoryGenericsTests.java
	spring-beans/src/test/java/org/springframework/beans/support/PagedListHolderTests.java
2013-01-04 10:02:29 +01:00
Phillip Webb 2a30fa07ea Replace test beans with test objects
Refactor spring-core tests to replace test beans from
'org.springframework.beans' with lighter test objects in
'org.springframework.tests.sample.objects'.
2013-01-04 10:02:29 +01:00
Chris Beams 7a737bebdd Merge branch '3.2.x' into master
* 3.2.x:
  Fix ClassCastException when setting media types
  Enable execution of TestNG tests in spring-test
  Polish support for topic branch-specific versions
  Segregate add'l long-running and performance tests
  Eliminate EBR dependencies and repository config
  Skip creation of IDEA metadata for spring-aspects
  Fix Eclipse compilation error in Gradle plugin
  Polish build.gradle
  Fix null parameterName issue in content negotiation
  Recursively add test dependencies
2013-01-03 22:31:52 +01:00
Chris Beams 68e3b7773c Segregate add'l long-running and performance tests
- Add TestGroup#LONG_RUNNING to distinguish from #PERFORMANCE, the
   former being tests that simply take a long time vs the latter being
   tests that are actually dependent on certain actions happening within
   a given time window and are thefore CPU-dependent.

Issue: SPR-9984
2013-01-03 19:28:05 +01:00
Chris Beams 961dbdb68a Merge branch '3.2.x' into master
* 3.2.x:
  Exclude spring-build-src from maven publish
  Move spring-build-junit into spring-core
  Relocate MergePlugin package
  Develop a gradle plugin to add test dependencies
  Expose Gradle buildSrc for IDE support
  Fix [deprecation] compiler warnings
  Upgrade to xmlunit version 1.3
  Improve 'build' folder ignores
  Fix regression in static setter method support
  Fix SpEL JavaBean compliance for setters

Conflicts:
	spring-beans/src/test/java/org/springframework/beans/ExtendedBeanInfoTests.java
2013-01-02 10:36:57 +01:00
Chris Beams 70eaf02b7f Revert "Merge branch 'SPR-10130' into cleanup-master"
This reverts commit 45fa50821a, reversing
changes made to a312d900f8.
2013-01-02 10:33:59 +01:00
Phillip Webb 65fb26f847 Move spring-build-junit into spring-core
Move code from spring-build-junit into spring-core/src/test along with
several other test utility classes. This commit removes the temporary
spring-build-junit project introduced in commit
b083bbdec7.
2013-01-01 19:49:45 -08:00
Phillip Webb 6626a38730 Fix [deprecation] compiler warnings
Fix deprecation compiler warnings by refactoring code or applying
@SuppressWarnings("deprecation") annotations. JUnit tests of
internally deprecated classes are now themselves marked as
@Deprecated.

Numerous EasyMock deprecation warnings will remain until the
migration to mockito can be completed.
2013-01-01 13:42:15 -08:00
Chris Beams b2a048b6f3 Update Apache license headers for affected sources 2012-12-28 23:57:33 +01:00
Chris Beams 3b40ce76bf Add @Override annotations to main sources
Issue: SPR-10130
2012-12-28 23:53:24 +01:00
Chris Beams 8472a2b2ab Update Apache license headers for affected sources 2012-12-28 23:09:31 +01:00
Phillip Webb 60032e0012 Ignore performance-sensitive tests by default
Make use of the new JUnit functionality introduced in the previous
commit to 'Assume' that perfomance- and timing-sensitive tests should
run only when TestGroup.PERFORMANCE is selected, i.e. when
-PtestGroups="performance" has been provided at the Gradle command line.

The net effect is that these tests are now ignored by default, which
will result in far fewer false-negative CI build failures due to
resource contention and other external factors that cause slowdowns.

We will set up a dedicated performance CI build to run these tests on
an isolated machine, etc.

Issue: SPR-9984
2012-12-28 23:08:37 +01:00
Phillip Webb d66c733ef4 Replace EasyMock with Mockito in test sources
Issue: SPR-10126
2012-12-28 23:07:04 +01:00
Chris Beams 4c8cd7b0bd Add @Override annotations to test sources
Issue: SPR-10129
2012-12-28 23:05:44 +01:00
Chris Beams 4c7cafbde6 Fix "unnecessary @SuppressWarnings" warnings 2012-12-28 22:50:46 +01:00
Chris Beams 8d2e125e7b Fix [rawtypes] compiler warnings
- Suppress rawtypes warnings for src/main
 - Enable rawtypes warnings for src/test

This commit attempts to to resolve all rawtypes problems across tests as
aggressively as possible, i.e. without regard for binary compatibility,
whereas main sources must be treated much more cautiously with an eye
toward compatibility.
2012-12-28 22:50:46 +01:00
Chris Beams 4d97ff2479 Fix [dep-ann] warnings with @Deprecated 2012-12-28 22:50:45 +01:00
Phillip Webb 6c14eaad61 Fix [cast] compiler warnings 2012-12-28 22:41:06 +01:00
Phillip Webb b0986049a3 Fix [serial] compiler warnings
Fix serialization warnings by applying @SuppressWarnings("serial")
when appropriate.

In certain cases and for unknown reasons, a correctly-placed
@SuppressWarnings("serial") annotation will fix the warning at the
javac level (i.e. the Gradle command-line), but will produce an
"unnecessary @SuppressWarnings" warning within Eclipse. In these
cases, a private static final serialVersionUID field has been added
with the default value of 1L.
2012-12-28 22:41:06 +01:00
Phillip Webb 7f0aa5cfb2 Fix [varargs] compiler warnings
Remove unnecessary 'null' argument from calls to vararg supported
methods and fix cast in ValidationUtils.invokeValidator().
2012-12-28 22:40:49 +01:00
Phillip Webb 731d5be644 Fix warnings due to unused import statements 2012-12-28 22:40:49 +01:00
Chris Beams 9540d2c81b Replace <code> with {@code} throughout Javadoc
Issue: SPR-10128
2012-12-28 22:36:02 +01:00
Chris Beams 8597ec25ec Fix various Javadoc warnings
Issue: SPR-10128
2012-12-28 22:36:02 +01:00
Phillip Webb 2cf45bad86 Replace space indentation with tabs
Issue: SPR-10127
2012-12-28 20:49:56 +01:00
Phillip Webb 1762157ad1 Remove trailing whitespace in source files
find . -type f -name "*.java" -or -name "*.aj" | \
    xargs perl -p -i -e "s/[ \t]*$//g" {} \;

Issue: SPR-10127
2012-12-28 20:49:45 +01:00
Phillip Webb 1abb7f66a7 Fix GenericConversionService search algorithm
Previously the algorithm used by GenericConversionService to find
converters incorrectly searched for interfaces working up from the
base class. This caused particular problems with custom List
converters as as the Collection interface would be considered before
the List interface giving CollectionToObjectConverter precedence
over the custom converter.

The updated algorithm restores the class search order to behave in the
same way as Spring 3.1.

Issue: SPR-10116
Backport-Issue: SPR-10117
Backport-Commit: aa914497dc
2012-12-22 11:53:00 -08:00
Juergen Hoeller c242abada1 Fixed QualifierAnnotationAutowireCandidateResolver's detection of custom qualifier annotations
Issue: SPR-10107
2012-12-20 17:35:02 +01:00
Juergen Hoeller 531318a4b2 Polishing 2012-12-13 00:03:26 +01:00
Juergen Hoeller a35b9c9431 Revert "Cache MethodParameter annotation lookup results"
This reverts commit c10d63dc01.
2012-12-12 23:57:50 +01:00
Juergen Hoeller b9df7d68d9 Consistent fine-tuning of synchronized and concurrent data structures
In particular, avoiding synchronized Sets and Maps wherever possible (preferring a ConcurrentHashMap even instead of a synchronized Set) and specifying appropriate ConcurrentHashMap initial capacities (even if we end up choosing 16).
2012-12-12 23:46:26 +01:00
Juergen Hoeller a2f8902b3a Inlined AntPathStringMatcher into AntPathMatcher
Also initializing the capacity of the AntPathStringMatcher cache to 256 now.
2012-12-12 23:39:25 +01:00
Juergen Hoeller 710fe9349a Deprecated CachingMapDecorator (following the deprecation of LabeledEnum support) 2012-12-12 23:39:24 +01:00
Chris Beams f26534700a Eliminate all Javadoc warnings
- Support external Javadoc links using Gradle's javadoc.options.links

 - Fix all other Javadoc warnings, such as typos, references to
   non-existent (or no longer existent) types and members, etc,
   including changes related to the Quartz 2.0 upgrade (SPR-8275) and
   adding the HTTP PATCH method (SPR-7985).

 - Suppress all output for project-level `javadoc` tasks in order to
   hide false-negative warnings about cross-module @see and @link
   references (e.g. spring-core having a @see reference to spring-web).
   Use the `--info` (-i) flag to gradle at any time to see project-level
   javadoc warnings without running the entire `api` task. e.g.
   `gradle :spring-core:javadoc -i`

 - Favor root project level `api` task for detection of legitimate
   Javadoc warnings. There are now zero Javadoc warnings across the
   entirety of spring-framework. Goal: keep it that way.

 - Remove all @link and @see references to types and members that exist
   only in Servlet <= 2.5 and Hibernate <= 4.0, favoring 3.0+ and 4.0+
   respectively. This is necessary because only one version of each of
   these dependencies can be present on the global `api` javadoc task's
   classpath. To that end, the `api` task classpath has now been
   customized to ensure that the Servlet 3 API and Hibernate Core 4 jars
   have precedence.

 - SPR-8896 replaced our dependency on aspectjrt with a dependency on
   aspectjweaver, which is fine from a POM point of view, but causes
   a spurious warning to be emitted from the ant iajc task that it
   "cannot find aspectjrt on the classpath" - even though aspectjweaver
   is perfectly sufficient. In the name of keeping the console quiet, a
   new `rt` configuration has been added, and aspectjrt added as a
   dependency to it. In turn, configurations.rt.asPath is appended to
   the iajc classpath during both compileJava and compileTestJava for
   spring-aspects.

Issue: SPR-10078, SPR-8275, SPR-7985, SPR-8896
2012-12-12 12:55:10 +01:00
Juergen Hoeller 1cb6e3dbb6 Several enhancements with respect to CachingMetadataReaderFactory handling.
Added "clearCache()" method to CachingMetadataReaderFactory, for clearing the metadata cache once not needed anymore - in particular when the MetadataReaderFactory instance is long-lived. Also added "setMetadataReaderFactory" method to ClassPathScanningCandidateComponentProvider, analogous to ConfigurationClassPostProcessor.
2012-12-12 03:29:44 +01:00
Phillip Webb 6e3c3c58b5 Polish whitespace and formatting 2012-11-26 09:34:22 -08:00
Oliver Gierke e40e2b7cae Introduce AnnotationAwareOrderComparator#INSTANCE
Prior to this change, the INSTANCE constant one could refer to on
AnnotationAwareOrderComparator actually referred to the constant
declared in the OrderAwareComparator superclass. Thus
AnnotationAwareOrderComparator#INSTANCE did not actually return an
AnnotationAwareOrderComparator but an OrderAwareComparator instead. This
commit introduces a dedicated constant on AnnotationAwareOrderComparator
to avoid this glitch.

Issue: SPR-10038
2012-11-26 18:14:29 +01:00
Juergen Hoeller 7d7758bfc9 Polishing 2012-11-25 21:15:48 +01:00
Rossen Stoyanchev b36ab83ab3 Support GenericArrayType in GenericTypeResolver method
Before this change GenericTypeResolver.resolveType supported
TypeVariable's and ParameterizedType's only. Now it also supports
GenericArrayType.
2012-11-21 13:26:56 -05:00
Sam Brannen dc0a0df8d6 Polish Javadoc for ConcurrentReferenceHashMap
Issue: SPR-9796
2012-11-04 15:37:26 +01:00
Phillip Webb 3aa9ac15a1 Update cache to support concurrent reads
Change the cache implementation from a synchronized weak hash map to
a concurrent implementation.

Issue: SPR-8701
2012-11-03 15:34:12 -07:00
Phillip Webb 02ce826ce4 Cache and late resolve annotations for performance
Annotations are no longer resolved in the constructor and are cached
for improved performance.

Issue: SPR-9166
2012-11-03 15:34:11 -07:00
Phillip Webb 6e0400db32 Polish Property class 2012-11-03 15:34:09 -07:00
Phillip Webb fac060f0af Develop ConcurrentReferenceHashMap
Develop a new ConcurrentMap implementation that support both weak and
soft entry references. Intended primarily to be used internally to
support fast concurrent caching.

Issue: SPR-9796
2012-11-03 15:33:59 -07:00
Chris Beams c94bc2e709 Respect spring.profiles.active in #addActiveProfile
Prior to this commit, calls to ConfigurableEnvironment#addActiveProfile
would cause any active profile values provided via the
"spring.profiles.active" property to be ignored.

Now these two mechanisms can be used in conjunction and work as
expected.

Issue: SPR-9944
2012-11-02 15:02:13 +01:00
Phillip Webb 468f9c7814 Polish 2012-11-01 11:10:25 -07:00
Phillip Webb 4036ffc4d4 Improve #toString for AnnotationAttributes
Improve the #toString method for AnnotationAttributes to print array
values as a comma-separated list. This change is primarily to provide
better variable inspection when debugging code within an IDE.
2012-10-31 09:42:27 +01:00
Juergen Hoeller 3a09644843 Adapted PropertySourcesPropertyResolverTests for different error message format 2012-10-31 02:53:24 +01:00
Juergen Hoeller 5b93b14392 DateTimeFormat annotation supports use as a meta-annotation as well 2012-10-31 02:53:23 +01:00
Juergen Hoeller ee50d849a1 Polished "Could not resolve placeholder" error message 2012-10-31 02:53:22 +01:00
Phillip Webb 22dfe93f2f Revert ConversionService SPI interface
Remove canBypassConvert() methods from the ConversionService SPI
interface, restoring it to the previous Spring 3.1 incarnation.

Bypassing conversion is now only supported when using a
GenericConversionService.

Issue: SPR-9566
2012-10-30 14:00:12 -07:00
Phillip Webb 31331e6ad3 Avoid NPE in ObjectToObjectConverter
Bypass ObjectToObject conversion when source and object types are
identical and protect against a null source object.

Prior to this commit the TypeDescriptor was used to determine if
conversion was necessary.  This caused issues when comparing a
descriptor with annotations to one without.  The updated code
now compares using TypeDescriptor.getType().

The ObjectToObject converter will now no longer attempt to convert
null source objects.

Issue: SPR-9933
2012-10-30 11:25:10 -07:00
Phillip Webb 5a1f924ac3 Resolve Collection element types during conversion
TypeDescriptor.valueOf now uses GenericCollectionTypeResolver to resolve
Collection and Map element types whereas previously this information was
simply not supported, i.e. null.

Issue: SPR-9257
2012-10-30 14:00:50 +01:00
Chris Beams 222eec58cd Review and polish pull request #132
Content:

 - Rename Conditional{Conversion=>Converter}
 - Add @since tags where appropriate
 - Update Apache date headers to read 2002-2012 (not just 2012)
 - Correct minor Javadoc typo

Style:

 - Polish line breaks / whitespace
 - Use wildcard static imports where appropriate

Issue: SPR-9566, SPR-9692, SPR-9928, SPR-9927
2012-10-30 09:14:28 +01:00
Phillip Webb f82c6ed7cc Support conversion from Enum Interface
EnumToStringConverter in now conditional and only matches Enums that
do not implement interfaces that can be converted.

Issue: SPR-9692
2012-10-30 09:14:24 +01:00
Phillip Webb a27d1a28ff Bypass conversion when possible
Prior to this commit conversion between like types would often result in
a copy of the object. This can be problematic in the case of large byte
arrays and objects that do not have a default constructor.

The ConversionService SPI now includes canBypassConvert methods that can
be used to deduce when conversion is not needed. Several existing
converters have been updated to ensure they only apply when source and
target types differ.

This change introduces new methods to the ConversionService that will
break existing implementations. However, it anticipated that most users
are consuming the ConversionService interface rather then extending it.

Issue: SPR-9566
2012-10-30 09:13:39 +01:00
Phillip Webb f13e3ad72b Extend conditional conversion support
Introduce new ConditionalConversion interface that can be applied to
Converter, ConverterFactory or GenericConverter interfaces to make
them conditional. Prior to this commit the only
ConditionalGenericConverter could be conditional.

Issue: SPR-9928
2012-10-30 09:13:36 +01:00
Phillip Webb 4dc289592d Refactor GenericConversionService
Refactor internal workings of GenericConversionService in order to
better support future enhancements. This commit should not affect
existing behavior.

Issue: SPR-9927
2012-10-30 09:13:22 +01:00
Phillip Webb 9bfe675761 Additional GenericConversionService Tests 2012-10-30 09:13:18 +01:00
Chris Beams 06e34f05a6 Allow PropertyResolvers to ignore unresolvable ${placeholders}
Prior to this commit, the PropertyResolver API (and therefore the
Environment API) allowed callers a choice between
 #resolvePlaceholders and #resolveRequiredPlaceholders for low-level
${placeholder} resolution. However, when calling the higher level
 #getProperty variants, users had no control over whether property
values returned with unresolvable ${placeholders} would result in an
exception or simply be passed through.

This commit introduces a #setIgnoreUnresolvableNestedPlaceholders
property via ConfigurablePropertyResolver, defaulting to false, the
value of which is respected by AbstractPropertyResolver#getProperty
method implementations. See the new test in
PropertySourcesPropertyResolverTests for usage examples.

Issue: SPR-9569, SPR-9473
2012-10-26 23:47:00 +02:00
Phillip Webb 01272fb0e6 Polish whitespace for conversion service packages 2012-10-26 14:09:26 -07:00
Phillip Webb 6adb49b7a9 Add StringToUUIDConverter
Conversion to and from UUID objects is now supported by the
DefaultConversionService.

Issue: SPR-9765
2012-10-12 14:47:19 -07:00
Phillip Webb c8c0e827b4 Polish trailing whitespace 2012-10-12 14:47:19 -07:00
Phillip Webb 38c4393592 Allow MapToMap conversion to work when the target map does not have a
default constructor (as long as a new map copy is not required).

Issue: SPR-9284
2012-10-12 13:10:07 -07:00
Phillip Webb 60afa5ead4 Polish trailing whitespace 2012-10-12 13:09:53 -07:00
Juergen Hoeller 84b3f7106d Polishing along with 3.1.3 backport
Issue: SPR-9761
Issue: SPR-9762
2012-10-11 00:35:02 +02:00
Phillip Webb e543ffdfd7 Improve annotation methods in TypeDescriptor
- Use generic typing for getAnnotation()
- Add hasAnnoation() method
- Update existing code and tests to make use of changes

Issue: SPR-9744
2012-10-10 15:16:46 -07:00
Phillip Webb 23f089ff1e Polish code and JavaDoc formatting
- Remove trailing whitespace
- Apply consistent JavaDoc formatting
2012-10-10 15:16:46 -07:00
Phillip Webb 2e48656906 Chain exception cause on create failure
Propogate root cause of exceptions thrown from createCollection
and createMap.

Issue: SPR-9285
2012-10-10 14:03:02 -07:00
Juergen Hoeller 49294c9d00 ClassUtils.getMostSpecificMethod uses Class.getMethod code path in case of a public method
This should be significantly faster than our standard algorithm, for a very common case. Motivated by SPR-9802, even if the fix there uses a different approach, with transaction name determination not calling getMostSpecificMethod at all anymore.

Issue: SPR-9802
2012-09-26 20:03:30 +02:00
Arjen Poutsma f191a55b8f Preserve comments when using JibxMarshaller
Prior to this commit, JibxMarshaller used a SAX ContentHandler to
marshal to StAX XMLEventWriters, which inadvertently resulted in the
deletion of XML comments.

After this commit, JibxMarshaller adapts the XMLEventWriter into an
XMLStreamWriter and comments are preserved.

Issue: SPR-9768
2012-09-17 14:07:02 +01:00
Phillip Webb 73832f8c6e Support inferred base package for @ComponentScan
Prior to this change, @ComponentScan required the declaration of
exactly one of the #value, #basePackage or #basePackageClasses
attributes in order to determine which package(s) to scan.

This commit introduces support for base package inference, relaxing the
above requirement and falling back to scanning the package in which the
@ComponentScan-annotated class is declared.

Issue: SPR-9586
2012-09-11 16:50:01 +02:00
Chris Beams dfe05305e2 Upgrade to JUnit 4.11 snapshot in support of JDK7
Class#getDeclaredMembers returns arbitrary results under JDK7. This
results in non-deterministic execution of JUnit test methods, often
revealing unintended dependencies between methods that rely on a
specific order to succeed.

JUnit 4.11 contains support for predictable test ordering [1], but at
the time of this commit, JUnit 4.11 has not yet been released.
Therefore we are testing against a snapshot version [2], which has been
uploaded to repo.springsource.org [3] for easy access. Note that this
artifact may be removed when JUnit 4.11 goes GA.

 - Care has been taken to ensure that spring-test's compile-time
   dependency on JUnit remains at 4.10. This means that the spring-test
   pom.xml will continue to have an optional <dependency> on JUnit
   4.10, instead of the 4.11 snapshot.

 - For reasons not fully understood, the upgrade to the 4.11 snapshot
   of junit-dep caused NoSuchMethodErrors around certain Hamcrest
   types, particularly CoreMatchers and Matchers. import statements
   have been updated accordingly throughout affected test cases.

 - Runtime errors also occurred around uses of JUnit @Rule and
   ExpectedException. These have been reverted to use simpler
   mechanisms like @Test(expected) in the meantime.

 - Some test methods with order-based dependencies on one another have
   been renamed in order to fall in line with JUnit 4.11's new method
   ordering (as opposed to actually fixing the inter-test
   dependencies). In other areas, the fix was as simple as adding a
   tearDown method and cleaning up state.

 - For no apparent reason, the timeout in AspectJAutoProxyCreatorTests'
   testAspectsAndAdvisorNotAppliedToPrototypeIsFastEnough method begins
   to be exceeded. Prior to this commit the timeout value was 3000 ms;
   on the CI server under Linux/JDK6 and JDK7, the test begins taking
   anywhere from 3500-5500 ms with this commit. It is presumed that
   this is an incidental artifact of the upgrade to JUnit 4.11. In any
   case, there are no changes to src/main in this commit, so this
   should not actually represent a performance risk for Spring
   Framework users. The timeout has been increased to 6000 ms to
   accommodate this situation.

[1]: https://github.com/KentBeck/junit/pull/293
[2]: https://github.com/downloads/KentBeck/junit/junit-dep-4.11-SNAPSHOT-20120805-1225.jar
[3]: https://repo.springsource.org/simple/ext-release-local/junit/junit-dep/4.11.20120805.1225

Issue: SPR-9783
2012-09-11 15:04:56 +02:00
Juergen Hoeller 787d8f5916 SpringFactoriesLoader as the simplest possible mechanism for BeanInfoFactory loading 2012-09-10 23:16:21 +02:00
Rossen Stoyanchev 34c3e821dd Cache AntPathStringMatcher instances
AntPathMatcher now caches AntPathStringMatcher instances by pattern
thus avoiding java.util.regex.Pattern recompilation.

Issue: SPR-9749
2012-09-10 16:57:10 -04:00
Juergen Hoeller f29b791c85 MutablePropertySources log statements guarded by isDebugEnabled
Issue: SPR-9670
2012-09-10 15:14:13 +02:00
Juergen Hoeller 8f12d98a99 LinkedCaseInsensitiveMap checks for uniqueness of case-insensitive keys now
Issue: SPR-9754
2012-09-10 15:14:09 +02:00
Arjen Poutsma aeff91c1da Moved SpringFactoriesLoader to io.support in order to resolve tangle. 2012-09-10 11:28:45 +02:00
Sam Brannen c795c1b362 Polishing 2012-09-08 18:16:33 +02:00
Arjen Poutsma 988f376752 Added SpringFactoriesLoader 2012-09-07 17:00:22 +02:00
Phillip Webb 77c9321967 Sort candidate @AspectJ methods deterministically
Update the ReflectiveAspectJAdvisorFactory class to sort candidate
AOP methods based on their annotation first and method name second.

Prior to this the order of aspects created from annotated methods
could differ depending on the underling JVM, as first noticed under
JDK7 in SPR-9729.

 - ConvertingComparator and InstanceComparator have been introduced in
   support of this change, per SPR-9730.

 - A shared static INSTANCE field has been added to ComparableComparator
   to avoid unnecessary instantiation costs within ConvertingComparator
   as well as to prevent generics warnings during certain caller
   scenarios.

Issue: SPR-9729, SPR-9730
2012-09-06 16:06:16 +02:00
Phillip Webb 719a9e120d Refactor ComparatorTests into separate classes 2012-09-06 16:06:16 +02:00
Phillip Webb 9821868707 Refactor and polish various Comparator impls
- Refactor CompoundComparator constructor to use varargs
 - Refactor MediaType to consume new varargs constructor
 - Add notNull assertions where appropriate
 - Add generic typing where appropriate
 - Suppress generics warnings elsewhere
 - Fix whitespace errors
2012-09-06 16:06:16 +02:00
Chris Beams 9f8d219146 Remove default profile during environment merge
This change fixes a minor bug with the implementation of
ConfigurableEnvironment#merge, introduced in SPR-9444. During a merge
of two environments A and B, where A has default profiles [prod] and B
has default profiles [default] (the so-called 'reserved default
profile'), B would complete the merge process having a collection of
profiles reading [default, prod], which is incorrect.

This commit explicitly ensure's that B's reserved default profile is
removed if A has a set of default profiles greater than zero. If A
consists only of [default], B will inherit it during the merge
correctly; if A consists of [p1, p2], B will result in [p1, p2] as
well; if B consists of [p1] and A of [p2, p3], B will result in
[p1, p2, p3] post-merge.

Issue: SPR-9761, SPR-9444
2012-09-05 22:33:14 +02:00
Juergen Hoeller 931ea5cdf4 polishing 2012-09-04 18:05:11 +02:00
jhoeller db4cc9562f Merge pull request #94 from dsyer/SPR-9498
SPR-9498: relax logic detecting successful property editor after conversion exception
2012-09-04 08:54:01 -07:00
Juergen Hoeller 30de87a51e StaxEventContentHandler uses static inner class for Location adapter, in order to avoid leaks when caching events
Issue: SPR-9305
2012-08-29 22:00:26 +02:00
Juergen Hoeller 769753dac4 ResourceUtils.useCachesIfNecessary() not correct handle JNLP connections
Issue: SPR-9547
2012-08-29 22:00:25 +02:00
Arjen Poutsma d37e7878e6 Improved Javadoc 2012-08-27 12:40:08 +02:00
Arjen Poutsma ca017a4880 Introduce strategy for BeanInfo creation
Before this commit, the CachedIntrospectionResults was hard-coded to
create ExtendedBeanInfos for bean classes. The ExtendedBeanInfo support
the JavaBeans property contract only.

This commit introduces the BeanInfoFactory, a strategy for creating
BeanInfos. Through this strategy, it is possible to support
beans that do not necessarily implement the JavaBeans contract (i.e.
have a different getter or setter style).

BeanInfoFactories are are instantiated by the
CachedIntrospectionResults, which looks for
'META-INF/spring.beanInfoFactories' files on the class path. These files
contain one or more BeanInfoFactory class names. When a BeanInfo is to
be created, the CachedIntrospectionResults will iterate through the
factories, asking it to create a BeanInfo for the given bean class. If
none of the factories support it, an ExtendedBeanInfo is created as a
default.

This commit also contains a change to Property, allowing BeanWrapperImpl
to specify the property name at construction time (as opposed to using
Property#resolveName(), which supports the JavaBeans contract only).

Issue: SPR-9677
2012-08-24 10:23:16 +02:00
Arjen Poutsma ed3823b045 Support generic target types in the RestTemplate
This change makes it possible to use the RestTemplate to read an HTTP
response into a target generic type object. The RestTemplate has three
new exchange(...) methods that accept ParameterizedTypeReference -- a
new class that enables capturing and passing generic type info.
See the Javadoc of the three new methods in RestOperations for a
short example.

To support this feature, the HttpMessageConverter is now extended by
GenericHttpMessageConverter, which adds a method for reading an
HttpInputMessage to a specific generic type. The new interface
is implemented by the MappingJacksonHttpMessageConverter and also by a
new Jaxb2CollectionHttpMessageConverter that can read read a generic
Collection where the generic type is a JAXB type annotated with
@XmlRootElement or @XmlType.

Issue: SPR-7023
2012-08-22 16:20:36 -04:00
Chris Beams 92500ab902 Upgrade to CGLIB 3 and inline into spring-core
CGLIB 3 has been released in order to depend on ASM 4, which Spring now
depends on internally (see previous commit).

This commit eliminates spring-beans' optional dependency on cglib-nodep
v2.2 and instead repackages net.sf.cglib => org.springframework.cglib
much in the same way we have historically done with ASM.

This change is beneficial to users in several ways:

 - Eliminates the need to manually add CGLIB to the application
   classpath; especially important for the growing number of
   @Configuration class users. Java-based configuration functionality,
   along with proxy-target-class and method injection features now
   work 'out of the box' in Spring 3.2.

 - Eliminates the possibility of conflicts with other libraries that
   may dependend on differing versions of CGLIB, e.g. Hibernate
   3.3.1.ga and its dependency on CGLIB 2.1.3 would easily cause a
   conflict if the application were depending on CGLIB 3 for
   Spring-related purposes.

 - Picks up CGLIB 3's changes to support ASM 4, meaning that CGLIB is
   that much less likely to work well in a Java 7 environment due to
   ASM 4's support for transforming classes with invokedynamic
   bytecode instructions.

On CGLIB and ASM:

  CGLIB's own dependency on ASM is also transformed along the way to
  depend on Spring's repackaged org.springframework.asm, primarily to
  eliminate unnecessary duplication of ASM classfiles in spring-core and
  in the process save around 100K in the final spring-core JAR file size.

  It is coincidental that spring-core and CGLIB currently depend on the
  exact same version of ASM (4.0), but it is also unlikely to change any
  time soon. If this change does occur and versions of ASM drift, then
  the size optimization mentioned above will have to be abandoned. This
  would have no compatibility impact, however, so this is a reasonable
  solution now and for the forseeable future.

On a mysterious NoClassDefFoundError:

  During the upgrade to CGLIB 3.0, Spring test cases began failing due to
  NoClassDefFoundErrors being thrown from CGLIB's DebuggingClassWriter
  regarding its use of asm-util's TraceClassVisitor type. previous
  versions of cglib-nodep, particularly 2.2, did not cause this behavior,
  even though cglib-nodep has never actually repackaged and bundled
  asm-util classes. The reason for these NoClassDefFoundErrors occurring
  now is still not fully understood, but appears to be due to subtle JVM
  bytecode preverification rules. The hypothesis is that due to minor
  changes in DebuggingClassWriter such as additional casts, access to
  instance variables declared in the superclass, and indeed a change in
  the superclass hierarchy, preverification may be kicking in on the
  toByteArray method body, at which point the reference to the missing
  TraceClassVisitor type is noticed and the NCDFE is thrown. For this
  reason, a dummy implementation of TraceClassVisitor has been added to
  spring-core in the org.springframework.asm.util package. This class
  simply ensures that Spring's own tests never result in the NCDFE
  described above, and more importantly that Spring's users never
  encounter the same.

Other changes include:

 - rename package-private Cglib2AopProxy => CglibAopProxy
 - eliminate all 'cglibAvailable' checks, warnings and errors
 - eliminate all 'CGLIB2' language in favor of 'CGLIB'
 - eliminate all mention in reference and java docs of needing to add
   cglib(-nodep) to one's application classpath

Issue: SPR-9669
2012-08-10 00:38:49 +02:00
Chris Beams c16f18a5fd Remove spring-asm and inline ASM 4 into spring-core
ASM 4.0 is generally compatibile with Java 7 classfiles, particularly
including 'invokedynamic' instructions. This is important when
considering that Spring's component-scanning support is internally
ASM-based and it is increasingly likely that component classes having
invokedynamic instructions may be encountered and read by ASM.
This upgrade, then, is primarily preventive in nature.

Changes include:

 - upgrade from ASM 2.2.3 to ASM 4.0

 - adapt to ASM API changes as necessary throughout spring-core,
   resulting in no impact to the public Spring API.

 - remove dedicated spring-asm module

 - use new :spring-core:asmRepackJar task to repackage
   org.objectweb.asm => org.springframework.asm as per usual and write
   repackaged classes directly into spring-core jar

The choice to eliminate the spring-asm module altogether and instead
inline the repackaged classes directly into spring-core is first to
eliminate an otherwise unnecessary second jar. spring-core has a
non-optional dependency on spring-asm meaning it is always on the
application classpath. This change simplifies that situation by
consoliding two jars into one. The second reason for this choice is in
anticipation of upgrading CGLIB to version 3 and inlining it into
spring-core as well. See subsequent commit for details.

Issue: SPR-9669
2012-08-10 00:36:49 +02:00
Sam Brannen 826e565b7c Polish GenericTypeResolver
- renamed resolveParameterizedReturnType() to
   resolveReturnTypeForGenericMethod()
 - fleshed out Javadoc for resolveReturnType() and
   resolveReturnTypeForGenericMethod() regarding declaration of formal
   type variables
 - improved wording in log statements and naming of local variables
   within resolveReturnTypeForGenericMethod()

Issue: SPR-9493
2012-08-05 19:09:38 +02:00
Sam Brannen f49b22c78f Introduce MockEnvironment in the spring-test module
For legacy reasons, a MockEnvironment implementation already exists in multiple places within Spring's test suite; however, it is not available to the general public.

This commit promotes MockEnvironment to a first-class citizen in the spring-test module, alongside the existing MockPropertySource.

In addition, the following house cleaning has been performed.

 - deleted MockPropertySource from the spring-expression module
 - deleted MockEnvironment from the "spring" integration testing module
 - updated test copies of MockPropertySource and MockEnvironment
 - documented MockEnvironment and MockPropertySource in the testing
   chapter of the reference manual

Issue: SPR-9492
2012-07-28 20:10:21 +02:00
Chris Beams 2ec7834124 Resolve nested placeholders via PropertyResolver
Prior to this change, PropertySourcesPropertyResolver (and therefore
all AbstractEnvironment) implementations failed to resolve nested
placeholders as in the following example:

    p1=v1
    p2=v2
    p3=${v1}:{$v2}

Calls to PropertySource#getProperty for keys 'p1' and 'v1' would
successfully return their respective values, but for 'p3' the return
value would be the unresolved placeholders. This behavior is
inconsistent with that of PropertyPlaceholderConfigurer.

PropertySourcesPropertyResolver #getProperty variants now resolve any
nested placeholders recursively, throwing IllegalArgumentException for
any unresolvable placeholders (as is the default behavior for
PropertyPlaceholderConfigurer). See SPR-9569 for an enhancement that
will intoduce an 'ignoreUnresolvablePlaceholders' switch to make this
behavior configurable.

This commit also improves error output in
PropertyPlaceholderHelper#parseStringValue by including the original
string in which an unresolvable placeholder was found.

Issue: SPR-9473, SPR-9569
2012-07-06 15:45:40 +02:00
Juergen Hoeller 8bd1fd3715 moved getInputStream() not-null requirement to InputStreamSource itself; removed misleading "throws IllegalStateException" declaration
Issue: SPR-9561
2012-07-04 23:32:49 +02:00
Juergen Hoeller fdb9de1445 Use BufferedInputStream in SimpleMetaDataReader to double performance
Issue: SPR-9528
2012-07-04 22:58:58 +02:00
Chris Beams dc822cdca0 Reflect 3.2=>3.1.2 backports in @since tags etc
Issue: SPR-9443, SPR-6847, SPR-9446, SPR-9444, SPR-9439, SPR-9302,
       SPR-9507, SPR-9238, SPR-9397, SPR-9406, SPR-9502
2012-06-27 23:07:48 +02: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 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
Dave Syer cd6f7de408 SPR-9498: Add support for MultiValueMap to CollectionFactory
This turns out not to be the main problem exposed in SPR-9498
but it seems like a sensible addition anyway.
2012-06-14 11:42:23 +01: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 f55a4a1ac5 Reduce log level for message re: missing annotation
Previously (since Spring 3.1.1) RecursiveAnnotationAttributesVisitor
logs at level WARN when ASM parsing encounters an annotation or an (enum
used within an annotation) that cannot be classloaded. This is not
necessarily indicative of an error, e.g. JSR-305 annotations such as
@Nonnull may be used only for static analysis purposes, but because
these annotations have runtime retention, they remain present in the
bytecode. Per section 9.6.1.2 of the JLS, "An annotation that is present
in the binary may or may not be available at run-time via the reflective
libraries of the Java platform."

This commit lowers the log level of these messages from warn to debug,
but leaves at warn level other messages dealing with the ability
reflectively read enum values from within annotations.

Issue: SPR-9233
2012-05-27 15:04:42 +03:00
Chris Beams bcd44f3798 Support not (!) operator for profile selection
The following syntax is now supported

  <beans profile="p1,!p2">

  @Profile("p1", "!p2")

indicating that the <beans> element or annotated component should
be processed only if profile 'p1' is active or profile 'p2' is not
active.

Issue: SPR-8728
2012-05-27 10:18:11 +03:00
Chris Beams 9fcfd7e827 Introduce ConfigurableEnvironment#merge
Prior to this change, AbstractApplicationContext#setParent replaced the
child context's Environment with the parent's Environment if available.
This has the negative effect of potentially changing the type of the
child context's Environment, and in any case causes property sources
added directly against the child environment to be ignored. This
situation could easily occur if a WebApplicationContext child had a
non-web ApplicationContext set as its parent. In this case the parent
Environment type would (likely) be StandardEnvironment, while the child
Environment type would (likely) be StandardServletEnvironment. By
directly inheriting the parent environment, critical property sources
such as ServletContextPropertySource are lost entirely.

This commit introduces the concept of merging an environment through
the new ConfigurableEnvironment#merge method. Instead of replacing the
child's environment with the parent's,
AbstractApplicationContext#setParent now merges property sources as
well as active and default profile names from the parent into the
child. In this way, distinct environment objects are maintained with
specific types and property sources preserved. See #merge Javadoc for
additional details.

Issue: SPR-9444, SPR-9439
2012-05-26 14:33:53 +03:00
Chris Beams 5874383ef0 Polish
Issue: SPR-9439
2012-05-26 14:33:52 +03:00
Stevo Slavic 18006c72b0 Fix circular placeholder prevention
A set of resolved placeholder references is used for circular
placeholder prevention. For complex property definitions this mechanism
would put property values with unresolved inner placeholder references
in the set, but would try to remove property values with placeholders
resolved, leaving the set in an invalid state and the mechanism broken.

This fix makes sure that the value that is put in the set is same one
that is removed from it, and by doing so avoids false positives in
reporting circular placeholders.

Issue: SPR-5369
2012-05-17 14:48:18 +03:00
Philippe Marschall 13239a0c3d Fix compiler warnings
This patch fixes several compiler warnings that do not point to code
problems. Two kinds of warnings are fixed. First in a lot of cases
@SuppressWarnings("unchecked") is used although there are no unchecked
casts happening. This seems to be a leftover from when the code base
was on Java 1.4, now that the code base was moved to Java 1.5 these are
no longer necessary. Secondly there some places where the raw types of
List and Class are used where there wildcard types (List<?> and
Class<?>) would work just as well without causing any raw type warnings.

These changes are beneficial particularly when working in Eclipse or
other IDEs because it reduces 'noise', helping to isolate actual
potential problems in the code.

The following changes have been made:

 - remove @SuppressWarnings where no longer needed

 - use wildcard types instead of raw types where possible
2012-05-17 14:32:34 +03:00
Chris Beams 1f4b33c4ad Fix compiler warnings in Constants/ConstantsTests 2012-05-17 12:59:21 +03:00
Stevo Slavic 6ffb0436fa Allow null params as advertised in Constants#toCode*
Even though the Javadoc for Constants#toCode and #toCodeForSuffix
specifies that a null value for the 'namePrefix' and 'nameSuffix'
parameters are respectively allowed, before this change passing a null
to either would result in a NullPointerException.

This change fixes constant name lookup for null values of these params
as if an empty string had been passed instead. This way of handling a
null value is consistent with the rest of Constants class API.

Issue: SPR-8278
2012-05-17 12:53:32 +03:00
Chris Beams f1246a4317 Fix locale parsing error with en_en, tr_tr, etc
Previously, StringUtils#parseLocaleString would parse locale strings
having the same lowercase token for both language and country
incorrectly, e.g. 'tr_tr' would parse to 'tr_TR_tr' as opposed to the
expected 'tr_TR'.

This commit fixes this behavior by using using String#lastIndexOf
instead of String#indexOf when determining the location of the country
code token.

Issue: SPR-9420
2012-05-17 09:42:42 +03:00
Petr Janecek ef7e728bb8 Fix annotation search ending too early
In AnnotationUtils#findAnnotation(Method, Class), the search for a
method annotation fails if:

 - the original method does not have the annotation

 - an abstract superclass does not have an equivalent method declared

 - an interface implemented by the superclass has the method and
   the annotation -> this should be found, but is not!

This happens because the try-catch block in #findAnnotation is too wide:
cl.getDeclaredMethod() can throw NoSuchMethodException and skip the
'#searchOnInterfaces' call prematurely.

The try-catch block was made narrower to allow #searchOnInterfaces to
be called even if the abstract class does not have the method declared
at all.

Issue: SPR-9342
2012-05-17 00:45:21 +03:00
Nikita Tovstoles c10d63dc01 Cache MethodParameter annotation lookup results
Prior to this change, Spring's MethodParameter#getParameterAnnotations
called java.lang.Method#getParameterAnnotations on every invocation.
The latter ends up contending for a monitor inside (Sun) JDK code. This
is problematic when dealing with the high number of @RequestMapping
invocations that can occur in a Spring MVC @Controller.

This commit eliminates this contention by caching values returned by
java.lang.Method#getParameterAnnotations in a static ConcurrentMap.

Note that only Method parameter annotations are cached, while
Constructor parameter annotations are not. This is because the
issue of primary concern is, as mentioned above, @RequestMapping
methods. By nature, constructors are called much more infrequently, and
in most cases in a single-threaded fashion.

Issue: SPR-9298
2012-05-16 16:22:38 +03:00
Sam Brannen b50f6e19a6 Fix regression in ClassPathResource descriptions
ClassPathResource.getDescription() now returns consistent, meaningful
results for all variants of ClassPathResource's constructors.

Issue: SPR-9413
2012-05-16 04:24:53 +02:00
Stevo Slavic effb762558 Fix javadoc warnings
Before this change there were numerous javadoc warnings being reported
while building Spring framework API.

This commit resolves most of the javadoc warnings, reducing the total
number from 265 to 103.

Issue: SPR-9113
2012-04-30 11:31:02 +03:00
Rossen Stoyanchev 9833a4c385 Improvement in AntPathMatcher.combine method
Issues: SPR-7970
2012-04-02 15:06:20 -04: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
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 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 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
Chris Beams 81dfef90ef Sync with 3.1.x
* 3.1.x:
  Fix false negative test failure in ResourceTests
  Compensate for Eclipse vs Sun compiler discrepancy
2012-02-13 15:54:14 +01:00
Chris Beams ee36c80ca9 Sync with 3.1.x
* 3.1.x: (61 commits)
  Compensate for changes in JDK 7 Introspector
  Avoid 'type mismatch' errors in ExtendedBeanInfo
  Polish ExtendedBeanInfo and tests
  Infer AnnotationAttributes method return types
  Minor fix in MVC reference doc chapter
  Hibernate 4.1 etc
  TypeDescriptor equals implementation accepts annotations in any order
  "setBasenames" uses varargs now (for programmatic setup; SPR-9106)
  @ActiveProfiles mechanism works with @ImportResource as well (SPR-8992
  polishing
  clarified Resource's "getFilename" method to consistently return null
  substituteNamedParameters detects and unwraps SqlParameterValue object
  Replace spaces with tabs
  Consider security in ClassUtils#getMostSpecificMethod
  Adding null check for username being null.
  Improvements for registering custom SQL exception translators in app c
  SPR-7680 Adding QueryTimeoutException to the DataAccessException hiera
  Minor polish in WebMvcConfigurationSupport
  Detect overridden boolean getters in ExtendedBeanInfo
  Polish ExtendedBeanInfoTests
  ...
2012-02-13 15:17:30 +01:00
Chris Beams 6235a341a7 Remove bundlor support 2012-01-31 14:37:11 +01:00
Chris Beams 02a4473c62 Rename modules {org.springframework.*=>spring-*}
This renaming more intuitively expresses the relationship between
subprojects and the JAR artifacts they produce.

Tracking history across these renames is possible, but it requires
use of the --follow flag to `git log`, for example

    $ git log spring-aop/src/main/java/org/springframework/aop/Advisor.java

will show history up until the renaming event, where

    $ git log --follow spring-aop/src/main/java/org/springframework/aop/Advisor.java

will show history for all changes to the file, before and after the
renaming.

See http://chrisbeams.com/git-diff-across-renamed-directories
2012-01-31 14:37:10 +01:00