Commit Graph

4002 Commits

Author SHA1 Message Date
Arjen Poutsma 8190b4f70a Javadoc 2011-05-12 09:00:39 +00:00
Andy Clement 580f35f6ee SFW-8228 2011-05-11 23:41:30 +00:00
Andy Clement 2f733bedc5 SFW-8224: distance can be used when computing method matches in ReflectiveMethodResolver 2011-05-11 21:44:24 +00:00
Sam Brannen 5d8de5c449 polishing 2011-05-11 20:09:08 +00:00
Rossen Stoyanchev 726e920857 Rename EnableMvcConfiguration->EnableWebMvc, refine method names in WebMvcConfigurer, fix issue with MappedInterceptors 2011-05-11 18:02:07 +00:00
Chris Beams c8bc54e0cc 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
2011-05-11 13:28:33 +00:00
Chris Beams 314a054a9b Introduce ResourcePropertySource
Allows convenient creation of a Properties-based PropertySource from a
Spring Resource object or resource location string such as
"classpath:com/myco/app.properties" or "file:/path/to/file.properties"

Issue: SPR-8328
2011-05-11 13:28:05 +00:00
Arjen Poutsma 9b0c66dc6c Make HTTP methods a RequestCondition 2011-05-11 10:38:30 +00:00
Chris Beams 80f0eabbd9 Add MockEnvironment to .integration-tests 2011-05-11 07:51:32 +00:00
Chris Beams 404f798048 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
2011-05-11 07:36:04 +00:00
Chris Beams 3622c6f340 Pull up default getProperty variants to base class
Issue: SPR-8322
2011-05-11 07:35:16 +00:00
Chris Beams dc2d5c107f Add default-value getProperty convenience variants
Issue: SPR-8322
2011-05-11 06:09:06 +00:00
Chris Beams 693204aef8 Polish @Configuration Javadoc
Add note that nested @Configuration classes must be static.
2011-05-11 06:08:40 +00:00
Chris Beams 52bef0b7b0 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
2011-05-10 11:55:41 +00:00
Chris Beams 859185d086 Test interaction of @ComponentScan and @Import 2011-05-10 11:54:37 +00:00
Arjen Poutsma 71aae405d5 SPR-7354 - Added equivalent of JAX-RS @Consumes to Spring MVC 2011-05-10 09:23:00 +00:00
Costin Leau 7f247a6b27 SPR-8256
+ doc updates
2011-05-09 17:40:23 +00:00
Arjen Poutsma b058d1e07a Made comparators public, as they are needed elsewhere. 2011-05-09 11:20:49 +00:00
Rossen Stoyanchev 8d0ab1d2e5 Refine HandlerMethod registration to allow detection by handler instance as well as by bean name 2011-05-08 19:31:29 +00:00
Chris Beams d0c31ad84c 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
2011-05-08 13:49:35 +00:00
Chris Beams c2b030a50d Polish @EnableScheduling Javadoc 2011-05-08 13:48:02 +00:00
Chris Beams 7e398f101c Rename AsyncConfigurer#get{+Async}Executor 2011-05-07 09:32:03 +00:00
Chris Beams 358cbf4301 Polish @EnableScheduling Javadoc 2011-05-07 09:31:13 +00:00
Chris Beams b7f4f2b546 Expose return-value-handlers in mvc namespace
Mirroring the MvcConfigurer#addCustomReturnValueHandlers callback which
allows for providing a list of HandlerMethodReturnValueHandler types
2011-05-06 19:13:44 +00:00
Chris Beams 1efb82d7cb Rename RequestMapping types for concision
Remove 'Method' from RequestMappingHandlerMethodMapping and
RequestMappingHandlerMethodAdapter
2011-05-06 19:13:05 +00:00
Chris Beams 2092a31f9d Rename DataBinderFactory subtypes for concision 2011-05-06 19:12:14 +00:00
Chris Beams 446dfdbff2 Introduce @EnableMvcConfiguration 2011-05-06 19:11:19 +00:00
Chris Beams 01e5120a26 Introduce @EnableTransactionManagement 2011-05-06 19:10:25 +00:00
Chris Beams d9a89529f0 Introduce @EnableScheduling 2011-05-06 19:09:24 +00:00
Chris Beams de50789cb6 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
2011-05-06 19:08:53 +00:00
Chris Beams cf0fc278bb Introduce @Role
As a mechanism for setting the 'role' hint on BeanDefinitions created
via component-scanning or @Bean methods.
2011-05-06 19:08:10 +00:00
Chris Beams 17892a8ab2 Introduce Ordered#NOT_ORDERED
To provide a reasonable default value for annotations that expose
int-returning #order attributes.
2011-05-06 19:07:41 +00:00
Chris Beams 7b999c676f 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.
2011-05-06 19:07:25 +00:00
Chris Beams 2bc3527f76 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
2011-05-06 19:06:37 +00:00
Chris Beams 9a271ce6c9 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.
2011-05-06 19:06:02 +00:00
Chris Beams cdb01cbd37 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.
2011-05-06 19:05:42 +00:00
Chris Beams 89005a5b70 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.
2011-05-06 19:05:15 +00:00
Chris Beams 856da7edb9 Provide dedicated @ComponentScan processing
@ComponentScan is now checked for explicitly and handled immediately
when parsing @Configuration classes.
2011-05-06 19:04:35 +00:00
Chris Beams cd4fb665d9 Delegate ComponentScanBDP environment to scanner
Enables @Profile filtering within ComponentScanBeanDefinitionParser
2011-05-06 19:04:11 +00:00
Chris Beams 111fb71fe1 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
2011-05-06 19:03:52 +00:00
Chris Beams 0a790c143f Rename ConfigurationClassMethod => BeanMethod 2011-05-06 19:01:56 +00:00
Chris Beams f683f781c5 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.
2011-05-06 19:01:35 +00:00
Chris Beams 84a63b6d4b Prevent empty calls to ACAC #register and #scan 2011-05-06 19:01:11 +00:00
Chris Beams d2faef44fa Add comment on DisposableBean use in @Configuration
Issue: SPR-7901
2011-05-06 19:00:55 +00:00
Chris Beams d3678caa37 Polish Javadoc 2011-05-06 19:00:38 +00:00
Chris Beams f30b7e3125 Fix generics and serialization warnings 2011-05-06 19:00:14 +00:00
Chris Beams 6d84f06d8c Remove unused MethodMetadata#getMethodReturnType
Introduced to support checking return types on @Bean methods but never
actually used.  May be reintroduced as necessary in the future.
2011-05-06 18:59:26 +00:00
Chris Beams 4b5208faad Introduce PropertyResolver#getPropertyAsClass 2011-05-06 18:59:05 +00:00
Chris Beams 275d43dfde Rename Property{SourcesProperty}ResolverTests 2011-05-06 18:58:41 +00:00
Chris Beams c51c340881 Update MockEnvironment / MockPropertySource types
Reflecting signature changes in getProperty() methods
2011-05-06 18:57:41 +00:00