Uploaded image for project: 'CDI Specification Issues'
  1. CDI Specification Issues
  2. CDI-622

External post-configuration of a bean

    XMLWordPrintable

Details

    • Feature Request
    • Resolution: Obsolete
    • Major
    • 2.1 (Discussion)
    • None
    • None
    • None

    Description

      The use case here is that a framework has provided the application developer with some bean, X. While the framework can provide internal post construction support for this bean, the application developer has some need to set additional attributes on the bean prior to the bean being injected into its final target.

      The application developer currently has no way to do this. To accomplish this feat, the framework developer must put the burden on the application developer to do both configuration and bootstrapping of this bean. This is a bit of a pain point to be honest.

      One idea I had was to introduce a @Configures annotation that could be used, similar to observers. These methods (plural) could be called (based on priority) during the post construct phase and may exist in any managed bean.

      @Configures
      public void setupWebServer(WebServer webserver, Configuration configuration) {
          webserver.setPort(configuration.getWebServerPort());
      }
      

      In this case, webserver is the bean being configured, configuration is some other bean that retains the configuration data. This should support normal qualifiers, and perhaps provide an injection point for the underlying InjectionTarget

      Attachments

        Activity

          People

            Unassigned Unassigned
            meetoblivion_jira John Ament (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: