Commit Graph

91 Commits

Author SHA1 Message Date
Phillip Webb 432c6ebdae Refactor DateTimeFormatterFactory
Refactor DateTimeFormatterFactory into two distinct classes; a general
purpose factory and a specialized FactoryBean.  These changes are
modeled after the existing VelocityEngineFactory and
VelocityEngineFactoryBean classes.

Issue: SPR-9959
2012-11-05 11:30:25 -08:00
Sam Brannen 93c01e0710 Fix timezone issue in DateTimeFormatterFactory
The DateTimeFormatterFactory introduced in SPR-7121 supports a timeZone
property; however, this property is currently not properly supported.

This commit addresses this issue by ensuring that the timeZone properly
is honored.

Issue: SPR-9953
2012-11-04 18:59:01 +01:00
Sam Brannen cef5f0222e Polish Javadoc and imports in datetime package
Issue: SPR-7121
2012-11-04 15:37:26 +01:00
Phillip Webb 6660227d22 Support for custom global Joda DateTimeFormatters
Added dateFormatter, timeFormatter and dateTimeFormatter properties
to JodaTimeFormatterRegistrar allowing for custom global formatting.

DateTimeFormatterFactory can be used when configuring with XML.

Issue: SPR-7121
2012-11-03 16:55:23 -07:00
Phillip Webb a26059f94a Support DateTimeFormat annotation without Joda
Dependency on Joda Time when using the @DateTimeFormat annotation is
now optional. If Joda Time is not present the JDK SimpleDateFormat
will be used to parse and print date patterns. If Joda time is
present it will always be used in preference to SimpleDateFormat.

Issue: SPR-6508
2012-11-03 16:55:15 -07:00
Phillip Webb ddddec8719 Corrected date pattern in JavaDocs
The 'hh' pattern should be 'HH' as ISO dates use 24hr notation.
2012-11-03 15:52:31 -07:00
Phillip Webb a75b6ee5b6 Polish whitespace and formatting 2012-11-03 15:49:52 -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 4cdf46f83c Polish @Imports search code
Issue: SPR-9925
2012-10-31 09:30:17 -07:00
Phillip Webb 3416e058a0 Ensure @Imports are processed in correct order
Issue: SPR-9925
2012-10-31 13:40:06 +01:00
Juergen Hoeller 914a1b2088 @Autowired, @Value and qualifiers may be used as meta-annotations for custom injection annotations 2012-10-31 12:10:17 +01:00
Phillip Webb 6d8b37d8bb Prevent duplicate @Import processing
Refactor ConfigurationClassParser to recursively find values from
all @Import annotations, combining them into a single unique set.

This change prevents ImportBeanDefinitionRegistrars from being
invoked twice.

Issue: SPR-9925
2012-10-31 09:42:27 +01:00
Phillip Webb e6c4840356 Polish Javadoc for @Import 2012-10-31 09:42:27 +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 69763fe249 Added test for custom async annotation 2012-10-31 02:53:22 +01:00
Juergen Hoeller 0e0200769d ManagedResource annotation supports placeholders for String attributes
In particular, the specified object name may use a placeholder for its domain part now, allowing for several instances of the MBean to be registered against the same MBeanServer from different applications.

Issue: SPR-8244
2012-10-31 02:53:21 +01:00
Phillip Webb e9cdb3d24e Polish JavaDoc 2012-10-30 12:07:31 -07:00
Chris Beams 38bfb2bd89 Introduce MessageCodeFormatter abstraction
This commit refactors changes introduced in 21760a8 as follows:

 - Introduce top-level MessageCodeFormatter interface and
   DefaultMessageCodesResolver#setMessageCodeFormatter property to allow
   for user-defined message code formatting strategies

 - Rename DefaultMessageCodesResolver.Style enum => DMCR.Format

 - Refactor DefaultMessageCodesResolver.Format to implement the new
   MessageCodeFormatter interface

The result is that users have convenient access to common formatting
strategies via the Format enum, while retaining the flexibility to
provide their own custom MessageCodeFormatter implementation if desired.

See DefaultMessageCodesResolverTests#shouldSupport*Format tests for
usage examples.

Issue: SPR-9707
2012-10-30 12:19:45 +01:00
Phillip Webb 21760a8b6b Provide alternative message code resolver styles
Introduce new 'style' property to DefaultMessageCodesResolver allowing
for alternative message styles. Current styles are PREFIX_ERROR_CODE
and POSTFIX_ERROR_CODE. The default style retains existing behavior.

Issue: SPR-9707
2012-10-30 10:09:36 +01:00
Gareth Davis 0709c033a0 Allow 'arg-type' matches against element body
Allow the body of 'arg-type' XML elements to be used as an alternative to
'match' attribute when defining a 'replace-method' in XML configuration.

This change has been introduced primarily to support the samples printed
in the Apress 'Pro Spring' book.

Issue: SPR-9812
2012-10-27 19:49:54 -07:00
Phillip Webb 376eeed8b1 Polish whitespace 2012-10-27 19:49:54 -07:00
Chris Beams 5d4d1eaca4 Fix package cycle in @EnableMBeanExport
Prior to this commit, @EnableMBeanExport was declared in the
jmx.export.annotation package. This makes logical sense, but
nevertheless creates a package cycle, because @EnableMBeanExport depends
on MBeanExportConfiguration which in turn depends on context.annotation
types like @Configuration, @Bean, and @Role.

context.annotation.config.MBeanExportBeanDefinitionParser, on the other
hand already has dependencies on types in jmx.support. Together, this
means that a package cycle was introduced.

The solution to this is simple: move @EnableMBeanExport and friends from
jmx.export.annotation => context.annotation. This has been the strategy
for other @Enable annotations and for the same reasons. It also makes a
kind of logical sense: just like you find <context:mbean-export> and
<context:load-time-weaver> under the context: XML namespace, so too do
you find their @Enable* counterparts under the context.annotation
namespace.

Issue: SPR-8943
2012-10-26 15:08:14 +02:00
Phillip Webb cae08db6a9 Introduce @EnableMBeanExport
Add support for @EnableMBeanExport annotation allowing @Configuration
classes to easily export all MBeans and @ManagedResources from the
Spring application context. The annotation is functionally equivalent
to the XML <context:mbean-export/> element.

Issue: SPR-8943
2012-10-25 14:25:42 +02:00
Phillip Webb 6179261d58 Polish whitespace 2012-10-25 12:29:32 +02:00
Phillip Webb 33d37e8680 Polish 2012-10-23 07:07:59 -07:00
Phillip Webb 9582085950 Add DefaultMessageCodesResolverTests
Add unit test for DefaultMessageCodesResolver
2012-10-15 10:06:34 -04:00
Juergen Hoeller a6ce821ad8 Made AutoProxyCreatorTests less dependent on container's own interrogation of FactoryBeans
Issue: SPR-9857
2012-10-12 23:34:22 +02:00
Juergen Hoeller 3cf5572ee8 LoadTimeWeaverAware beans are consistently being created early for JPA weaving to work reliably
Reverted change for @Bean methods that declare FactoryBean as their return type: The effects of trying to create the FactoryBean to find out about its implementation type are too far-reaching. It's better to recommend declaring a specific return type in the method signature if you want the container to specifically react to your implementation type.

Issue: SPR-9857
2012-10-12 23:34:22 +02:00
Juergen Hoeller 0af9244571 LoadTimeWeaverAware beans are consistently being created early for JPA weaving to work reliably
Includes a change for factory methods that declare their return type as FactoryBean: When asked for a specific type match (e.g. LoadTimeWeaverAware), we do check early singleton instances as well (reusing the instances that we create for getObjectType checks). This is necessary in order to make @Bean method introspection as capable as XML bean definition introspection, even in case of the @Bean method using a generic FactoryBean declaration for its return type (instead of the FactoryBean impl class).

Issue: SPR-9857
2012-10-12 23:34:21 +02:00
Juergen Hoeller 3c59725b94 LoadTimeWeaverAware beans are consistently being created early for JPA weaving to work reliably
Includes a change for factory methods that declare their return type as FactoryBean: When asked for a specific type match (e.g. LoadTimeWeaverAware), we do check early singleton instances as well (reusing the instances that we create for getObjectType checks). This is necessary in order to make @Bean method introspection as capable as XML bean definition introspection, even in case of the @Bean method using a generic FactoryBean declaration for its return type (instead of the FactoryBean impl class).

Issue: SPR-9857
2012-10-12 23:34:18 +02:00
Juergen Hoeller ff7dcec5f7 BeanWrapper does not fall back to String constructor if ConversionService attempt failed before
Issue: SPR-9865
2012-10-12 23:34:15 +02:00
Phillip Webb c8061393fb Prevent memory leaks with @Configuration beans
Refactor ConfigurationClassEnhancer to allow cglib caching of
generated classes.  Prior to this commit each enhanced @Configuration
class would consume permgen space when created.

The CallbackFilter and Callback Types are now defined as static final
members so that they can be shared by all enhancers.  Only the
callbackInstances remain specific to a @Configuration class and
these are not used by cglib as part of the cache key.

Issue: SPR-9851
2012-10-12 12:33:42 -07: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
Juergen Hoeller 014f7f0242 Changes along with 3.1.3 backport
Aside from minor polishing, this change sets the "systemProperties" and "systemEnvironment" beans at each factory level as well.

Issue: SPR-9756
Issue: SPR-9764
2012-10-10 23:34:22 +02:00
Sam Brannen 4812c181d4 Polish LiveBeansView Javadoc and suppress warnings 2012-10-04 14:10:52 +02:00
Juergen Hoeller abf341c33a ResourceBundleMessageSource supports "defaultEncoding", "fallbackToSystemLocale", "cacheSeconds"
These features require Java 6 or higher due to their dependency on the ResourceBundle.Control class. To some degree, ResourceBundleMessageSource catches up with ReloadableResourceBundleMessageSource now. However, as noted in the javadoc, there are still severe limitations in the standard ResourceBundle class that justify an ongoing investment in our own ReloadableResourceBundleMessageSource (based on the Spring resource abstraction, with manual parsing of properties files).

Issue: SPR-7392
2012-09-26 16:55:14 +02:00
Juergen Hoeller 3c557bfbc3 LiveBeansView produces a well-defined (and valid) JSON document now
Issue: SPR-9662
2012-09-26 16:55:13 +02:00
Juergen Hoeller 0d88c73523 Calling cancel on a Future returned by a TaskScheduler works reliably now
Issue: SPR-9821
2012-09-25 13:53:07 +02:00
Juergen Hoeller e0bec678da Calling cancel on a Future returned by a TaskScheduler works reliably now
Issue: SPR-9821
2012-09-25 12:06:43 +02:00
Juergen Hoeller e5f3669804 Introduced beta version of LiveBeansView for STS 3.1
LiveBeansView includes MBean exposure as well as Servlet exposure, with JSON as the initial output format. In order to identify an MBean per application, a new "getApplicationName()" method got introduced on the ApplicationContext interface, returning the Servlet container context path in case of a web application and defaulting to the empty String. MBean exposure can be driven by the "spring.liveBeansView.mbeanDomain" property, e.g. specifying "liveBeansView" as its value, leading to "liveBeansView:application=" or "liveBeansView:application=/myapp" style names for the per-application MBean.

Issue: SPR-9662
2012-09-24 23:15:58 +02:00
Juergen Hoeller dc4e0683ae ImportAwareBeanPostProcessor registered with ROLE_INFRASTRUCTURE 2012-09-24 11:26:47 +02: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
Phillip Webb a9a90cabad Protect against non-deterministic method order in JDK7
- Allow reset of GlobalAdvisorAdapterRegistry

   Provide a reset() method allowing the GlobalAdvisorAdapterRegistry
   instance to be replaced with a fresh instance. This method has
   primarily been added to allow unit tests to leave the registry
   in a known state.

 - Protect against the fact that calls to configuration class methods
   my occur in a random order.

Issue: SPR-9779
2012-09-11 15:04:55 +02:00
Juergen Hoeller 0a42c80c11 @Import'ed configuration classes get properly registered in case of same class name (second try)
Issue: SPR-9243
2012-09-10 23:16:20 +02:00
Juergen Hoeller 228a77552d @Import'ed configuration classes get properly registered in case of same class name
Issue: SPR-9243
2012-09-10 15:44:12 +02:00
Juergen Hoeller 10a4e88e0a polishing 2012-09-10 15:14:10 +02:00
Juergen Hoeller 282d961b2e @Import'ed configuration classes get properly registered in case of same class name
Issue: SPR-9243
2012-09-10 15:14:10 +02:00