Skip to content

Conditional Bean Definitions [SPR-5261] #9935

@spring-projects-issues

Description

@spring-projects-issues

Bernard Macours opened SPR-5261 and commented

We would like to conditionally remotely expose some beans in our integration testing environment, but this is currently not possible (there is no out-of-the-box solution). Typically the condition would be based on a property value (a system property or a property from a property file), for example:

<bean id="MyHttpExporterToBeUsedInIntegrationTestingEnvironmentOnly" class="...">
<condition property-name="environment" property-value="INTEGRATION.*"/>
</bean>

Where "property-name" gives a property name and "property-value" a regular expression the property value must match for the bean to be instanciated.

To ease error detection, it would also be nice to get an exception like "ConditionalBeanAccessException" when trying to reference a conditional bean which has not been instanciated.


Affects: 2.5.5

Issue Links:

Metadata

Metadata

Assignees

No one assigned

    Labels

    in: coreIssues in core modules (aop, beans, core, context, expression)status: duplicateA duplicate of another issuetype: enhancementA general enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions