Skip to content

Introduce SmartContextLoader SPI [SPR-8386] #13033

Closed
@spring-projects-issues

Description

@spring-projects-issues

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

  1. Introduce a new SmartContextLoader SPI that extends ContextLoader 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 for ResourceTypeAwareContextLoader and its ResourceType enum, and it will result in a more flexible SPI that is better suited to support future, unknown requirements.
  2. Refactor existing AnnotationConfigContextLoader, ContextLoaderUtils, and TestContext implementations to take advantage of the SmartContextLoader SPI
  3. Delete ResourceTypeAwareContextLoader
  4. 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:

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions