Sorry, was supposed to go to the DeltaSpike mailinglist....
On Mar 26, 2015 5:42 PM, "Lars-Fredrik Smedberg" <[email protected]> wrote:

> Hi
>
> Curious, I saw the following in the ContextUtils sourcecode when I was
> looking for some ideas to solve a problem....
>
>     public static boolean isContextActive(Class<? extends Annotation>
> scopeAnnotationClass, BeanManager beanManager)
>     {
>         try
>         {
>             if (beanManager.getContext(scopeAnnotationClass) == null
>                     ||
> !beanManager.getContext(scopeAnnotationClass).isActive())
>             {
>                 return false;
>             }
>         }
>         catch (ContextNotActiveException e)
>         {
>             return false;
>         }
>
>         return true;
>     }
>
> When I looked at the documentation for BeanManager I saw that getContext
> always returns a Context or throw a ContextNotActiveException (amongst
> other exceptions), so the null check should not be needed or?
>
> The documenation also mention that the getContext method always return an
> active context...
>
> Is the code there to solve some compatibility issues or for other
> historical reasons or should it read (or similar):
>
>     public static boolean isContextActive(Class<? extends Annotation>
> scopeAnnotationClass, BeanManager beanManager)
>     {
>         try
>         {
>     beanManager.getContext(scopeAnnotationClass);
>     return true;
>         }
>         catch (ContextNotActiveException e)
>         {
>             return false;
>         }
>     }
>
> Regards
> LF
>

Reply via email to