static public AbstractApplicationContext load() { AbstractApplicationContext context; try { context = AnnotationConfigApplicationContext.class.newInstance(); } catch (InstantiationException | IllegalAccessException e) { throw new RuntimeException(e); } AnnotationConfigRegistry registry = (AnnotationConfigRegistry) context; registry.register(BaseConfiguration.class); registry.register(GraphQLJavaToolsAutoConfiguration.class); context.refresh(); return context; }
private void scanAppRepository(AbstractApplicationContext context, Component component) { String appRepository = component.getManifestAttribute(APP_REPOSITORY); if (StringUtils.isEmpty(appRepository)) { return; } int count; if (context instanceof AnnotationConfigRegistry) { int before = context.getBeanDefinitionCount(); ((AnnotationConfigRegistry) context).scan(StringUtils.split(appRepository, CONFIG_LOCATION_DELIMITERS)); count = context.getBeanDefinitionCount() - before; } else { ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner((BeanDefinitionRegistry) context); scanner.setEnvironment(context.getEnvironment()); scanner.setResourceLoader(context); scanner.setIncludeAnnotationConfig(false); count = scanner.scan(StringUtils.split(appRepository, CONFIG_LOCATION_DELIMITERS)); } if (count > 0 && logger.isDebugEnabled()) { logger.debug("Scanned {} beans in {}", count, component.getDisplayName()); String[] names = context.getBeanDefinitionNames(); for (String name : names) { BeanDefinition definition = ((GenericApplicationContext) context).getBeanDefinition(name); if (definition instanceof ScannedGenericBeanDefinition) { ScannedGenericBeanDefinition sgbd = (ScannedGenericBeanDefinition) definition; Class<?> beanClass; try { beanClass = sgbd.resolveBeanClass(context.getClassLoader()); } catch (ClassNotFoundException e) { continue; } if (beanClass != null) { logger.debug("\t{}", beanClass.getName()); } } } } }