Closed
Description
Sam Brannen opened SPR-8386 and commented
Status Quo
The current ContextLoader
SPI has the following shortcomings:
- it only supports String-based resource locations, but we need first-class support for Class-based resources for
@Configuration
classes - it does not support the notion of bean definition profiles that were introduced in Spring 3.1 M1
Deliverables
- Introduce a new
SmartContextLoader
SPI that extendsContextLoader
and supports both String[] and Class[] resources, likely retrieved from a new "context" parameter object as opposed to hard-coded, inflexible method signatures. This will replace the need forResourceTypeAwareContextLoader
and itsResourceType
enum, and it will result in a more flexible SPI that is better suited to support future, unknown requirements. - Refactor existing
AnnotationConfigContextLoader
,ContextLoaderUtils
, andTestContext
implementations to take advantage of theSmartContextLoader
SPI - Delete
ResourceTypeAwareContextLoader
- Delete
ContextLoaderUtils.LocationsResolver
and implementations
Implementation Notes Regarding Profiles
Design the SmartContextLoader
SPI so that a reference to the configured active profiles can be passed to a variant of loadContext()
. This reference may potentially take the form of the "context" parameter object introduced with the new SmartContextLoader
SPI. See AbstractGenericContextLoader
's loadContext()
method for an example of where the profiles would need to be set in the code (i.e., prior to refreshing the context).
Affects: 3.1 M2
Issue Links:
- Provide TestContext support for @Configuration classes [SPR-6184] #10852 Provide TestContext support for
@Configuration
classes ("depends on") - TestContext framework should support declarative configuration of bean definition profiles [SPR-7960] #12615 TestContext framework should support declarative configuration of bean definition profiles ("is depended on by")
- Introduce a DelegatingSmartContextLoader [SPR-8387] #13034 Introduce a DelegatingSmartContextLoader ("is depended on by")