Skip to content

Expose more AbstractBeanDefinition methods in BeanDefinition [SPR-17275] #21808

Closed

Description

@spring-projects-issues

Sébastien Deleuze opened SPR-17275 and commented

When using functional bean registration, BeanDefinitionCustomizer lambda gives access to a BeanDefinition lambda parameter that does not give access to various AbstractBeanDefinition methods, requiring a cast to AbstractBeanDefinition which is not elegant and make our API not very discoverable for those use cases.

I think it could be useful to expose those methods in BeanDefinition interface:  

  • setAbstract
  • setAutowireMode
  • getAutowireMode
  • setDependencyCheck
  • getDependencyCheck
  • setInitMethodName
  • getInitMethodName
  • getDestroyMethodName
  • setDestroyMethodName
  • setRole
  • getRole
  • setDescription
  • getDescription

Those ones are candidates as well, but I have no real use case in mind for them for the moment, so they are not mandatory to expose:

  • addQualifier
  • getQualifiers
  • hasQualifier
  • getQualifier
  • setLenientConstructorResolution
  • isLenientConstructorResolution
  • setResourceDescription
  • getResourceDescription

Issue Links:

Referenced from: commits f783967, c4aea62, 97cea7f

Activity

  1. spring-projects-issues commented on Sep 13, 2018

    @spring-projects-issues
    CollaboratorAuthor

    Juergen Hoeller commented

    The BeanDefinition interface exposes initMethodName and destroyMethodName now, and includes setters for role and description (for which it previously only had getters).

    As for abstract, autowireMode and dependencyCheck, those are really quite specific to somewhat outdated concepts such as parent/child bean definitions and XML-driven autowiring by convention. For that reason, I'd rather leave them on AbstractBeanDefinition.

  2. spring-projects-issues commented on Sep 13, 2018

    @spring-projects-issues
    CollaboratorAuthor

    Sébastien Deleuze commented

    Thanks!

  3. spring-projects-issues commented on Sep 17, 2018

    @spring-projects-issues
    CollaboratorAuthor

    Sébastien Deleuze commented

    Juergen Hoeller While doing a review of the Kotlin BeanDefinitionDsl to take care of these new API, I found that autowireMode is actually needed and exposed. I currently define it to AUTOWIRE_CONSTRUCTOR here in order to get contructor args injected (since this is the pattern I promote with Kotlin which is using a lot immutable constructor parameters) with a regular GenericApplicationContext and I allow users to change that optionally via the DSL. So I am wondering if autowireMode should be exposed in BeanDefinition? Or maybe it should not and we shold advise user to setup a AutowiredAnnotationBeanPostProcessor that will do that instead (which I am not sure partially because in functional mode we do not use annotation so the class name could be confusing)?

     

  4. spring-projects-issues commented on Sep 19, 2018

    @spring-projects-issues
    CollaboratorAuthor

    Sébastien Deleuze commented

    Solved via #21825.

  5. added
    type: enhancement
    in: core
    on Jan 11, 2019
  6. added this to the 5.1 GA milestone on Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

in: coretype: enhancement

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions