[cdi-dev] [JBoss JIRA] (CDI-45) Optional Injection Points

John Ament (JIRA) issues at jboss.org
Wed Oct 12 06:39:01 EDT 2016


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

John Ament edited comment on CDI-45 at 10/12/16 6:38 AM:
---------------------------------------------------------

I'm -1 for adding a method named {{getOptional}} but might be +0.5 on methods like {{optional()}} or {{asOptional()}} since from a callers point of view the chained method calls don't necessarily create new objects.

It would be more ideal if the {{Instance}} object dealt with missing beans better, which is really what this ticket should cover.  I think I'm strongly +1 on adding at least an {{isPresent()}} (the opposite of {{isUnresolved()}} effectively being a positive check rather than those negative checks) and an {{ifPresent(Consumer<T>)}} method.


was (Author: meetoblivion):
I'm -1 for adding a method named {{getOptional}} but might be +0.5 on methods like {{optional()}} or {{asOptional()}} since from a callers point of view 

It would be more ideal if the {{Instance}} object dealt with missing beans better, which is really what this ticket should cover.  I think I'm strongly +1 on adding at least an {{isPresent()}} (the opposite of {{isUnresolved()}} effectively being a positive check rather than those negative checks) and an {{ifPresent(Consumer<T>)}} method.

> Optional Injection Points
> -------------------------
>
>                 Key: CDI-45
>                 URL: https://issues.jboss.org/browse/CDI-45
>             Project: CDI Specification Issues
>          Issue Type: Feature Request
>          Components: Resolution
>    Affects Versions: 1.0
>            Reporter: Stuart Douglas
>            Priority: Optional
>             Fix For: TBD
>
>
> There are occoasions where it may be useful for some injection points to be optional, e.g.
> @Inject
> @Optional 
> MyBean bean; 
> This would behave the same as a normal injection point, however it will not cause the deployment to fail if it is not satisified. 



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


More information about the cdi-dev mailing list