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

Sven Linstaedt (JIRA) issues at jboss.org
Mon Oct 10 10:50:00 EDT 2016


    [ https://issues.jboss.org/browse/CDI-622?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13304963#comment-13304963 ] 

Sven Linstaedt commented on CDI-622:
------------------------------------

>From an integration point of view this proposal may be interesting as afaik there is no "standard" way to configure beans/extensions currently. Each framework and/or extension has their own way to do this. E.g. even deltaspike has several different abstractions of configuration to enable users to customize it for their use.

> 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
>             Fix For: 2.1 (Discussion)
>
>
> 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