SpringJavaConfigService { public List<String> getBeanNames(Class<?> configFile, Project project, Class<?> type) { List<String> beanNames = new ArrayList<>(); List<Class<?>> importedFiles = getConfigImports(configFile, project); for (Class<?> importLocation : importedFiles) { beanNames.addAll(getBeanNames(importLocation, project, type)); } ReflectionUtils.doWithMethods(configFile, method -> { Bean beanAnnotation = method.getAnnotation(Bean.class); if (beanAnnotation.value().length > 0) { Collections.addAll(beanNames, beanAnnotation.value()); } else if (beanAnnotation.name().length > 0) { Collections.addAll(beanNames, beanAnnotation.name()); } else { beanNames.add(method.getName()); } }, method -> method.getAnnotation(Bean.class) != null && method.getReturnType().equals(type)); return beanNames; }  List<Class<?>> getConfigImports(Class<?> configFile, Project project); T getBeanDefinition(Class<?> configFile, Project project, String id, Class<T> type); List<T> getBeanDefinitions(Class<?> configFile, Project project, Class<T> type); List<String> getBeanNames(Class<?> configFile, Project project, Class<?> type); void addBeanDefinition(File configFile, Project project, Object model); void removeBeanDefinition(File configFile, Project project, String id); void removeBeanDefinitions(File configFile, Project project, Class<?> type); void updateBeanDefinition(File configFile, Project project, String id, Object model); void updateBeanDefinitions(File configFile, Project project, Class<?> type, Object model);  }
@Test public void testGetBeanNames() throws Exception { List<String> names = springJavaConfigService.getBeanNames(GetBeanDefinitionConfig.class, project, JmsEndpoint.class); Assert.assertEquals(names.size(), 2L); Assert.assertTrue(names.stream().anyMatch(name -> name.equals("jmsInboundEndpoint"))); Assert.assertTrue(names.stream().anyMatch(name -> name.equals("jmsOutboundEndpoint"))); names = springJavaConfigService.getBeanNames(GetBeanDefinitionConfig.class, project, WebServiceClient.class); Assert.assertEquals(names.size(), 0L); names = springJavaConfigService.getBeanNames(GetBeanDefinitionConfig.class, project, TestActor.class); Assert.assertEquals(names.size(), 1L); Assert.assertTrue(names.stream().anyMatch(name -> name.equals("testActor"))); }