[cdi-dev] [JBoss JIRA] (CDI-622) External post-configuration of a bean

John Ament (JIRA) issues at jboss.org
Sun Jul 3 11:59:00 EDT 2016


John Ament created CDI-622:
------------------------------

             Summary: External post-configuration of a bean
                 Key: CDI-622
                 URL: https://issues.jboss.org/browse/CDI-622
             Project: CDI Specification Issues
          Issue Type: Feature Request
            Reporter: John Ament


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. 

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

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}}



--
This message was sent by Atlassian JIRA
(v6.4.11#64026)


More information about the cdi-dev mailing list