Class WeldUtils

  • @ApplicationScoped
    public class WeldUtils
    extends Object
    Provides weld utilities.
    • Field Detail


        public static final javax.enterprise.util.AnnotationLiteral<javax.enterprise.inject.Any> ANY_LITERAL
    • Constructor Detail

      • WeldUtils

        public WeldUtils()
    • Method Detail

      • getStaticInstanceBeanManager

        public static javax.enterprise.inject.spi.BeanManager getStaticInstanceBeanManager()
      • setStaticInstanceBeanManager

        public static void setStaticInstanceBeanManager​(javax.enterprise.inject.spi.BeanManager theBeanManager)
      • getInstanceFromStaticBeanManager

        public static <T> T getInstanceFromStaticBeanManager​(Class<T> type)
        Method which uses the static instance of the bean manager cached in this class. This method should only be used by objects which are not created by Weld. Objects created by Weld should preferably use the @Inject annotation to get an instance of the WeldUtils injected.
        See Also:
      • getInstance

        public <T> T getInstance​(Class<T> type)
        Return an instance which has the requested class. Ignores inheritance, so if a class A extends a class B, if B is requested then an instance of B is returned and not an instance of A.
        Type Parameters:
        T - the expected class
        type - the type to search, this type and all its subtypes are searched
        an instance of the requested type
      • getInstances

        public static <T> List<T> getInstances​(Class<T> type)
        Returns a set of instances for a specified type/class
      • setBeanManager

        public void setBeanManager​(javax.enterprise.inject.spi.BeanManager beanManager)
        Sets bean manager. The purpose of this setter is to be used just in jUnit test cases. When working within a container, bean manager should be handled by container.