public static < T > Collection < T > getAllBeansOfType ( WeldContainer weldContainer , Class < T > type ) { Collection < T > beans = Lists . newArrayList ( ) ; Set < Bean < ? > > cdiBeans = weldContainer . getBeanManager ( ) . getBeans ( type , AnyLiteral . INSTANCE ) ; // searches all beans for beans that have the matching goal name, ... for ( Bean < ? > b : cdiBeans ) { @ SuppressWarnings ( "unchecked" ) Bean < T > b2 = ( Bean < T > ) b ; CreationalContext < T > creationalContext = weldContainer . getBeanManager ( ) . createCreationalContext ( b2 ) ; T bean = b2 . create ( creationalContext ) ; beans . add ( bean ) ; } return beans ; }
Searches the container for all beans of a certain type without respecting qualifiers .