protected Bean < ? > getUniqueBeanByBeanName ( BeanManager bm , String batchId ) { Bean < ? > match = null ; // Get all beans with the given EL name (id). EL names are applied via @Named. // If the bean is not annotated with @Named, then it does not have an EL name // and therefore can't be looked up that way. Set < Bean < ? > > beans = bm . getBeans ( batchId ) ; try { match = bm . resolve ( beans ) ; } catch ( AmbiguousResolutionException e ) { return null ; } return match ; }
Use the given BeanManager to lookup a unique CDI - registered bean with bean name equal to batchId using EL matching rules .