[cdi-dev] [JBoss JIRA] (CDI-50) Ability to veto beans, both unconditionally and based on classes visible

Vinicius Carvalho (Commented) (JIRA) jira-events at lists.jboss.org
Wed Nov 30 06:05:41 EST 2011


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

Vinicius Carvalho commented on CDI-50:
--------------------------------------

Having something like @Optional would be great. We have a scenario where we package our apps in modules, but generally there's a jar with the API and all interfaces. So for example, we have a CacheService interface that will be shipped with all apps, it does not mean all apps will have an implementation (through an extension)  of that (say ehcache,infinispan,gemfire).

So imagine now we have another service:

public class MyService {

@Inject @Optional CacheService cache;

private Map noCachefallback;

}


so now, if the caching service is not available I could fallback to the local hashmap for instance.

To overcome that I'm accessing BeanManager directly and querying for the service, checking if it's present or not. But I found a problem when I need to use the bean during initialization.

Any chances we can see this @Optinal (maybe at Solder) one day?

Regards

                
> Ability to veto beans, both unconditionally and based on classes visible
> ------------------------------------------------------------------------
>
>                 Key: CDI-50
>                 URL: https://issues.jboss.org/browse/CDI-50
>             Project: CDI Specification Issues
>          Issue Type: Feature Request
>          Components: Concepts, Packaging and Deployment
>    Affects Versions: 1.0
>            Reporter: Pete Muir
>            Assignee: Pete Muir
>             Fix For: 1.1.EDR2
>
>
> This should support both a straight veto, and conditional based on classes available.
> Seam Solder supports this as @Veto and @Requires({Foo.class, Bar.class}).
> Mark Struberg proposed using @Optional

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the cdi-dev mailing list