deltaspike-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lars-Fredrik Smedberg <itsme...@gmail.com>
Subject Re: Question on ContextUtils
Date Thu, 26 Mar 2015 17:39:21 GMT
@Thomas and also remove the isActive call I guess?
On Mar 26, 2015 5:59 PM, "Thomas Andraschko" <andraschko.thomas@gmail.com>
wrote:

> Hi,
>
> i just added the null check to get sure.
> Removing the check + adding a unit test for it would be a better way.
>
>
> 2015-03-26 17:45 GMT+01:00 Lars-Fredrik Smedberg <itsmeden@gmail.com>:
>
> > 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
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message