Skip to content

Provide an API/Event so that library authors can detect when user has modified SpringApplication #22379

@dsyer

Description

@dsyer

If a library provides a listener for ApplicationEnvironmentPreparedEvent (for instance) in spring.factories it can modify the SpringApplication (add sources, change the application context class, etc.) but there is no way to know if the user has already done that before calling run(). It would be useful in general to be able to do that, so that the library can respect the user's wishes and still provide defaults. Specifically I am interested in the application context factory, but maybe also other things.

Various ideas popped up when we discussed informally:

  1. public getters for everything in SpringApplication is an option, but not likely to be desirable.
  2. a new ApplicationEvent that can be fired from the constructor.
  3. extracting "default provider" concern to a new component (so the library can override that instead of calling setters directly).

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: declinedA suggestion or change that we don't feel we should currently applytype: enhancementA general enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions