Commit Graph

974 Commits

Author SHA1 Message Date
Costin Leau e4ed1f1530 revise cache API
+ update failing test

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4317 50f2f4bb-b051-0410-bef5-90022cba6387
2011-05-17 17:09:49 +00:00
Costin Leau 328fdc5c04 revise cache API
+ add missing files (remember to check "show unversioned files")

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4316 50f2f4bb-b051-0410-bef5-90022cba6387
2011-05-17 16:58:15 +00:00
Costin Leau b22e4dc15a revise cache API
- eliminate unneeded methods
+ introduced value wrapper (name still to be decided) to avoid cache race conditions
+ improved name consistency

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4315 50f2f4bb-b051-0410-bef5-90022cba6387
2011-05-17 16:50:00 +00:00
Costin Leau 8fb6790f7d SPR-8334
+ commit missing configs

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4306 50f2f4bb-b051-0410-bef5-90022cba6387
2011-05-13 16:09:33 +00:00
Costin Leau b6b8e8ecdc SPR-8334
+ commit missing configs

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4305 50f2f4bb-b051-0410-bef5-90022cba6387
2011-05-13 15:59:22 +00:00
Costin Leau f1eaefb4fd SPR-
+ remove duplicate class

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4302 50f2f4bb-b051-0410-bef5-90022cba6387
2011-05-13 15:37:10 +00:00
Chris Beams 26a0e223a4 Fix @Autowired+@PostConstruct+@Configuration issue
A subtle issue existed with the way we relied on isCurrentlyInCreation
to determine whether a @Bean method is being called by the container
or by user code.  This worked in most cases, but in the particular
scenario laid out by SPR-8080, this approach was no longer sufficient.

This change introduces a ThreadLocal that contains the factory method
currently being invoked by the container, such that enhanced @Bean
methods can check against it to see if they are being called by the
container or not.  If so, that is the cue that the user-defined @Bean
method implementation should be invoked in order to actually create
the bean for the first time.  If not, then the cached instance of
the already-created bean should be looked up and returned.

See ConfigurationClassPostConstructAndAutowiringTests for
reproduction cases and more detail.

Issue: SPR-8080

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4296 50f2f4bb-b051-0410-bef5-90022cba6387
2011-05-12 12:28:13 +00:00
Chris Beams 2b0b4a58cb Refine ignored @PropertySource log warning
If the enclosing environment does not implement ConfigurableEnvironment,
then @PropertySource annotations are ignored because there is no way to
add them to the Environment. Now checking first to see if there are any
@PropertySource annotations present before issuing the warning.

Issue: SPR-8314

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4295 50f2f4bb-b051-0410-bef5-90022cba6387
2011-05-12 12:27:14 +00:00
Chris Beams b05cef9574 Introduce @PropertySource
Allows a convenient mechanism for contributing a PropertySource to the
enclosing Spring Environment. See @PropertySource Javadoc for
complete details and PropertySourceAnnotationTests for examples.

Issue: SPR-8314

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4289 50f2f4bb-b051-0410-bef5-90022cba6387
2011-05-11 13:28:33 +00:00
Chris Beams 3f7d5120c9 Support 'required properties' precondition
Users may now call #setRequiredProperties(String...) against the
Environment (via its ConfigurablePropertyResolver interface) in order
to indicate which properties must be present.

Environment#validateRequiredProperties() is invoked by
AbstractApplicationContext during the refresh() lifecycle to perform
the actual check and a MissingRequiredPropertiesException is thrown
if the precondition is not satisfied.

Issue: SPR-8323

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4285 50f2f4bb-b051-0410-bef5-90022cba6387
2011-05-11 07:36:04 +00:00
Chris Beams 653773574e Polish @Configuration Javadoc
Add note that nested @Configuration classes must be static.

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4282 50f2f4bb-b051-0410-bef5-90022cba6387
2011-05-11 06:08:40 +00:00
Chris Beams 4c746017c5 Allow static modifier on @Bean methods
Declaring @Bean methods as 'static' is now permitted, whereas previously
it raised an exception at @Configuration class validation time.

A static @Bean method can be called by the container without requiring
the instantiation of its declaring @Configuration class. This is
particularly useful when dealing with BeanFactoryPostProcessor beans,
as they can interfere with the standard post-processing lifecycle
necessary to handle @Autowired, @Inject, @Value, @PostConstruct and
other annotations.

static @Bean methods cannot recieve CGLIB enhancement for scoping and
AOP concerns. This is acceptable in BFPP cases as they rarely if ever
need it, and should not in typical cases ever be called by another
@Bean method.  Once invoked by the container, the resulting bean will
be cached as usual, but multiple invocations of the static @Bean method
will result in creation of multiple instances of the bean.

static @Bean methods may not, for obvious reasons, refer to normal
instance @Bean methods, but again this is not likely a concern for BFPP
types. In the rare case that they do need a bean reference, parameter
injection into the static @Bean method is technically an option, but
should be avoided as it will potentially cause premature instantiation
of more beans that the user may have intended.

Note particularly that a WARN-level log message is now issued for any
non-static @Bean method with a return type assignable to BFPP.  This
serves as a strong recommendation to users that they always mark BFPP
@Bean methods as static.

See @Bean Javadoc for complete details.

Issue: SPR-8257, SPR-8269

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4281 50f2f4bb-b051-0410-bef5-90022cba6387
2011-05-10 11:55:41 +00:00
Chris Beams ae0dc34f29 Test interaction of @ComponentScan and @Import
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4280 50f2f4bb-b051-0410-bef5-90022cba6387
2011-05-10 11:54:37 +00:00
Chris Beams 11c31085fe Allow recursive use of @ComponentScan
Prior to this change, @ComponentScan annotations were only processed at
the first level of depth.  Now, the set of bean definitions resulting
from each declaration of @ComponentScan is checked for configuration
classes that declare @ComponentScan, and recursion is performed as
necessary.

Cycles between @ComponentScan declarations are detected as well. See
CircularComponentScanException.

Issue: SPR-8307

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4275 50f2f4bb-b051-0410-bef5-90022cba6387
2011-05-08 13:49:35 +00:00
Chris Beams b5d18feb55 Polish @EnableScheduling Javadoc
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4274 50f2f4bb-b051-0410-bef5-90022cba6387
2011-05-08 13:48:02 +00:00
Chris Beams 4f38c21f76 Rename AsyncConfigurer#get{+Async}Executor
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4273 50f2f4bb-b051-0410-bef5-90022cba6387
2011-05-07 09:32:03 +00:00
Chris Beams f0b8bbc04b Polish @EnableScheduling Javadoc
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4272 50f2f4bb-b051-0410-bef5-90022cba6387
2011-05-07 09:31:13 +00:00
Chris Beams fb059b3491 Introduce @EnableScheduling
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4266 50f2f4bb-b051-0410-bef5-90022cba6387
2011-05-06 19:09:24 +00:00
Chris Beams f8d97b009d Introduce @EnableAsync
Introduce @EnableAsync#order

AsyncAnnotationBeanPostProcessor's 'order' property is now mutable;
@EnableAsync's 'order()' attribute allows for setting it, but must
have a default value, thus uses the new Ordered#NOT_ORDERED
constant - a reserved negative number very unlikely to be otherwise
used that may be interpreted as 'not ordered', useful in annotation
defaulting scenarios where null is not an option.

Introduce first working cut of AsyncConfiguration

Remove AsyncCapability

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4265 50f2f4bb-b051-0410-bef5-90022cba6387
2011-05-06 19:08:53 +00:00
Chris Beams f6a4366ebd Introduce @Role
As a mechanism for setting the 'role' hint on BeanDefinitions created
via component-scanning or @Bean methods.

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4264 50f2f4bb-b051-0410-bef5-90022cba6387
2011-05-06 19:08:10 +00:00
Chris Beams a091eb1c86 Introduce ReflectionUtils#getUniqueDeclaredMethods
This change is in support of certain polymorphism cases in
@Configuration class inheritance hierarchies.  Consider the following
scenario:

@Configuration
public abstract class AbstractConfig {
    public abstract Object bean();
}

@Configuration
public class ConcreteConfig {
    @Override
    @Bean
    public BeanPostProcessor bean() { ... }
}

ConcreteConfig overrides AbstractConfig's #bean() method with a
covariant return type, in this case returning an object of type
BeanPostProcessor.  It is critically important that the container
is able to detect the return type of ConcreteConfig#bean() in order
to instantiate the BPP at the right point in the lifecycle.

Prior to this change, the container could not do this.
AbstractAutowireCapableBeanFactory#getTypeForFactoryMethod called
ReflectionUtils#getAllDeclaredMethods, which returned Method objects
for both the Object and BeanPostProcessor signatures of the #bean()
method.  This confused the implementation sufficiently as not to
choose a type for the factory method at all.  This means that the
BPP never gets detected as a BPP.

The new method being introduced here, #getUniqueDeclaredMethods, takes
covariant return types into account, and filters out duplicates,
favoring the most specific / narrow return type.

Additionally, it filters out any CGLIB 'rewritten' methods, which
is important in the case of @Configuration classes, which are
enhanced by CGLIB.  See the implementation for further details.

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4262 50f2f4bb-b051-0410-bef5-90022cba6387
2011-05-06 19:07:25 +00:00
Chris Beams c61a0aeb83 Consolidate annotation processing constants
Consolidating internal bean name and aspect class name constats within
AnnotationConfigUtils to allow access from both the context.config
and context.annotation packages without creating a relationship between
the two of them (they are unrelated leaf nodes in the packaging
currently).

The .transaction module does not have a similar utils class and already
has a relationship from transaction.config -> transaction.annotation,
so placing the constants in .annotation.TransactionManagementCapability
to be referenced by .config.AnnotationDrivenBeanDefinitionParser

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4261 50f2f4bb-b051-0410-bef5-90022cba6387
2011-05-06 19:06:37 +00:00
Chris Beams 528ae46f9f Introduce ImportSelector interface
Allows @Enable* a layer of indirection for deciding which @Configuration
class(es) to @Import.

The @Import annotation may now accept @Configuration class literals
and/or ImportSelector class literals.

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4260 50f2f4bb-b051-0410-bef5-90022cba6387
2011-05-06 19:06:02 +00:00
Chris Beams 7ef92dccfa Introduce ImportAware interface
@Configuration classes may implement ImportAware in order to be injected
with the AnnotationMetadata of their @Import'ing class.

Includes the introduction of a new PriorityOrdered
ImportAwareBeanPostProcessor that handles injection of the
importing class metadata.

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4259 50f2f4bb-b051-0410-bef5-90022cba6387
2011-05-06 19:05:42 +00:00
Chris Beams 56b5ea610c Process all meta and local @Import declarations
Includes the introduction of AnnotationUtils#findAllAnnotationAttributes
to support iterating through all annotations declared on a given type
and interrogating each for the presence of a meta-annotation. See tests
for details.

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4258 50f2f4bb-b051-0410-bef5-90022cba6387
2011-05-06 19:05:15 +00:00
Chris Beams 0fa00811d7 Provide dedicated @ComponentScan processing
@ComponentScan is now checked for explicitly and handled immediately
when parsing @Configuration classes.

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4257 50f2f4bb-b051-0410-bef5-90022cba6387
2011-05-06 19:04:35 +00:00
Chris Beams 962eea2d35 Delegate ComponentScanBDP environment to scanner
Enables @Profile filtering within ComponentScanBeanDefinitionParser

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4256 50f2f4bb-b051-0410-bef5-90022cba6387
2011-05-06 19:04:11 +00:00
Chris Beams c892028705 Remove "Feature" support introduced in 3.1 M1
Feature-related support such as @Feature, @FeatureConfiguration,
and FeatureSpecification types will be replaced by framework-provided
@Configuration classes and convenience annotations such as
@ComponentScan (already exists), @EnableAsync, @EnableScheduling,
@EnableTransactionManagement and others.

Issue: SPR-8012,SPR-8034,SPR-8039,SPR-8188,SPR-8206,SPR-8223,
SPR-8225,SPR-8226,SPR-8227

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4255 50f2f4bb-b051-0410-bef5-90022cba6387
2011-05-06 19:03:52 +00:00
Chris Beams e6f3fd2de0 Rename ConfigurationClassMethod => BeanMethod
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4254 50f2f4bb-b051-0410-bef5-90022cba6387
2011-05-06 19:01:56 +00:00
Chris Beams 84ace01244 Revert deprecation of BDRU#registerWithGeneratedName
The overloading necessary to preserve the new signature as well as
the old causes ambiguities leading to deprecation warnings in some
caller scenarios.

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4253 50f2f4bb-b051-0410-bef5-90022cba6387
2011-05-06 19:01:35 +00:00
Chris Beams 8bc5338de6 Prevent empty calls to ACAC #register and #scan
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4252 50f2f4bb-b051-0410-bef5-90022cba6387
2011-05-06 19:01:11 +00:00
Chris Beams 791206060e Add comment on DisposableBean use in @Configuration
Issue: SPR-7901

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4251 50f2f4bb-b051-0410-bef5-90022cba6387
2011-05-06 19:00:55 +00:00
Chris Beams e21da602b7 Polish Javadoc
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4250 50f2f4bb-b051-0410-bef5-90022cba6387
2011-05-06 19:00:38 +00:00
Chris Beams e8d1df5037 Fix generics and serialization warnings
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4249 50f2f4bb-b051-0410-bef5-90022cba6387
2011-05-06 19:00:14 +00:00
Chris Beams 0b1f42ef66 Update MockEnvironment / MockPropertySource types
Reflecting signature changes in getProperty() methods

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4245 50f2f4bb-b051-0410-bef5-90022cba6387
2011-05-06 18:57:41 +00:00
Costin Leau f42da75682 SPR-8238
+ add NPE test

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4231 50f2f4bb-b051-0410-bef5-90022cba6387
2011-04-21 08:07:12 +00:00
Costin Leau bff57c7925 SPR-8238
+ add handling for null arguments to prevent NPE in default key generation

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4230 50f2f4bb-b051-0410-bef5-90022cba6387
2011-04-21 08:00:42 +00:00
Micha Kiener fb40ff59ab SPR-6416, adding basic conversation object tests, improving the access time of the conversation object
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4222 50f2f4bb-b051-0410-bef5-90022cba6387
2011-04-12 19:51:50 +00:00
Micha Kiener c3db0f1abc SPR-6416, adding repository timeout setting tests
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4221 50f2f4bb-b051-0410-bef5-90022cba6387
2011-04-12 18:11:18 +00:00
Micha Kiener 41045f3b19 SPR-6416, adding conversation manager test
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4220 50f2f4bb-b051-0410-bef5-90022cba6387
2011-04-12 16:02:46 +00:00
Micha Kiener 57e7223cde SPR-6416, reshaping removal of hierarchical conversations and adding repository test
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4219 50f2f4bb-b051-0410-bef5-90022cba6387
2011-04-12 14:53:09 +00:00
Micha Kiener ab4a3568b1 SPR-6416, initial commit for the conversation management
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4217 50f2f4bb-b051-0410-bef5-90022cba6387
2011-04-12 13:21:18 +00:00
Sam Brannen b953ffc0be polishing
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4176 50f2f4bb-b051-0410-bef5-90022cba6387
2011-04-04 22:05:49 +00:00
Chris Beams 30fc529379 Touch up ApplicationContextInitializer Javadoc
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4172 50f2f4bb-b051-0410-bef5-90022cba6387
2011-04-04 14:57:51 +00:00
Chris Beams 1dd763da18 Make ConfigurationClassBeanDefinitionReader public
Issue: SPR-8200

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4171 50f2f4bb-b051-0410-bef5-90022cba6387
2011-04-04 14:14:17 +00:00
Rossen Stoyanchev 3473219bad Predictable index position for BindingResult keys and parameter annotation convenience methods in MethodParameter
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4149 50f2f4bb-b051-0410-bef5-90022cba6387
2011-03-31 14:16:37 +00:00
Sam Brannen 2bee329d1e [SPR-8089] Added TODOs.
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4126 50f2f4bb-b051-0410-bef5-90022cba6387
2011-03-28 19:01:33 +00:00
Sam Brannen 956905a88d [SPR-8089] re-ignoring JMX tests that require the presence of jmxremote_optional.jar.
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4124 50f2f4bb-b051-0410-bef5-90022cba6387
2011-03-28 18:38:34 +00:00
Sam Brannen 607d73b161 [SPR-8089] re-ignoring JMX tests that require the presence of jmxremote_optional.jar.
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4123 50f2f4bb-b051-0410-bef5-90022cba6387
2011-03-28 18:26:30 +00:00
Sam Brannen 6a134d83f3 [SPR-8091] developer notes
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4121 50f2f4bb-b051-0410-bef5-90022cba6387
2011-03-28 18:09:14 +00:00