[seam-issues] [JBoss JIRA] Commented: (SOLDER-50) Throw a specialized exception when BeanManagerAware cannot resolve BeanManager

Stuart Douglas (JIRA) jira-events at lists.jboss.org
Fri Dec 10 09:19:52 EST 2010


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

Stuart Douglas commented on SOLDER-50:
--------------------------------------

If this returns false it means that you are not in a CDI environment or you are in some new environment that has not been encountered before (e.g. if OWB decided to release a owb-servlet module).

I think we should get rid of the 'Do not use this under any circumstances' warning in the javadoc of this class for a number of reasons:

1) It is standards compliant: In an ee environment it will always get the BM from JNDI
2) It is the only portable way to get the BM
3) It is not tied to any implementation, so future CDI impls can implement the SPI to maintain compatibility
4) 'the do not use this' comment in the javadoc is just plain wrong (there are no risks associated with using it, and it is more portable than looking up the BM in JNDI), it is actually the complete opposite of what the javadoc says, and portable code should use it where possible to get the BM instead on JNDI lookups.


> Throw a specialized exception when BeanManagerAware cannot resolve BeanManager
> ------------------------------------------------------------------------------
>
>                 Key: SOLDER-50
>                 URL: https://issues.jboss.org/browse/SOLDER-50
>             Project: Seam Solder
>          Issue Type: Feature Request
>          Components: Core
>            Reporter: Dan Allen
>            Assignee: Lincoln Baxter III
>            Priority: Minor
>
> The BeanManagerAware#getBeanManager() method currently throws an IllegalArgumentException when the BeanManager cannot be found by any provider. Because this exception is so generic, it's dangerous to bundle the lookup with other code because you aren't sure whether the IllegalArgumentException came from the BeanManager lookup or from a subsequent call, as in:
> try {
>    BeanManager beanManager = BeanManagerAccessor.getBeanManager();
>    beanManager.fireEvent(payload);
> }
> catch (IllegalArgumentException e) {
>    // what caused this?
> }
> Introduce a specialized checked exception for this unique failure. The proposed name is BeanManagerNotAvailable (or BeanManagerNotFound)

-- 
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the seam-issues mailing list