test_class.declarator: springExtensionFactory = new SpringExtensionFactory()
test_class.modifier: private
test_class.original_string: private SpringExtensionFactory springExtensionFactory = new SpringExtensionFactory();
test_class.type: SpringExtensionFactory
test_class.var_name: springExtensionFactory
test_class.declarator: context1
test_class.modifier: private
test_class.original_string: private AnnotationConfigApplicationContext context1;
test_class.type: AnnotationConfigApplicationContext
test_class.var_name: context1
test_class.declarator: context2
test_class.modifier: private
test_class.original_string: private AnnotationConfigApplicationContext context2;
test_class.type: AnnotationConfigApplicationContext
test_class.var_name: context2
test_class.file: dubbo-config/dubbo-config-spring/src/test/java/com/alibaba/dubbo/config/spring/extension/SpringExtensionFactoryTest.java
test_class.identifier: SpringExtensionFactoryTest
test_case.body: @Test
      public void testGetExtensionByTypeMultiple() {
          try {
              springExtensionFactory.getExtension(DemoService.class, "beanname-not-exist");
          } catch (Exception e) {
              e.printStackTrace();
              Assert.assertTrue(e instanceof NoUniqueBeanDefinitionException);
          }
      }
test_case.class_method_signature: SpringExtensionFactoryTest.testGetExtensionByTypeMultiple()
test_case.full_signature: @Test public void testGetExtensionByTypeMultiple()
test_case.identifier: testGetExtensionByTypeMultiple
test_case.invocations: getExtension printStackTrace assertTrue
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testGetExtensionByTypeMultiple()
focal_class.declarator: logger = LoggerFactory.getLogger(SpringExtensionFactory.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger logger = LoggerFactory.getLogger(SpringExtensionFactory.class);
focal_class.type: Logger
focal_class.var_name: logger
focal_class.declarator: contexts = new ConcurrentHashSet<ApplicationContext>()
focal_class.modifier: private static final
focal_class.original_string: private static final Set<ApplicationContext> contexts = new ConcurrentHashSet<ApplicationContext>();
focal_class.type: Set<ApplicationContext>
focal_class.var_name: contexts
focal_class.declarator: shutdownHookListener = new ShutdownHookListener()
focal_class.modifier: private static final
focal_class.original_string: private static final ApplicationListener shutdownHookListener = new ShutdownHookListener();
focal_class.type: ApplicationListener
focal_class.var_name: shutdownHookListener
focal_class.file: dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/extension/SpringExtensionFactory.java
focal_class.identifier: SpringExtensionFactory
focal_class.interfaces: implements ExtensionFactory
focal_class.class_method_signature: SpringExtensionFactory.addApplicationContext(ApplicationContext context)
focal_class.full_signature: public static void addApplicationContext(ApplicationContext context)
focal_class.identifier: addApplicationContext
focal_class.modifiers: public static
focal_class.parameters: (ApplicationContext context)
focal_class.return: void
focal_class.signature: void addApplicationContext(ApplicationContext context)
focal_class.class_method_signature: SpringExtensionFactory.removeApplicationContext(ApplicationContext context)
focal_class.full_signature: public static void removeApplicationContext(ApplicationContext context)
focal_class.identifier: removeApplicationContext
focal_class.modifiers: public static
focal_class.parameters: (ApplicationContext context)
focal_class.return: void
focal_class.signature: void removeApplicationContext(ApplicationContext context)
focal_class.class_method_signature: SpringExtensionFactory.getContexts()
focal_class.full_signature: public static Set<ApplicationContext> getContexts()
focal_class.identifier: getContexts
focal_class.modifiers: public static
focal_class.parameters: ()
focal_class.return: Set<ApplicationContext>
focal_class.signature: Set<ApplicationContext> getContexts()
focal_class.class_method_signature: SpringExtensionFactory.clearContexts()
focal_class.full_signature: public static void clearContexts()
focal_class.identifier: clearContexts
focal_class.modifiers: public static
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void clearContexts()
focal_class.class_method_signature: SpringExtensionFactory.getExtension(Class<T> type, String name)
focal_class.full_signature: @Override @SuppressWarnings("unchecked") public T getExtension(Class<T> type, String name)
focal_class.identifier: getExtension
focal_class.modifiers: @Override @SuppressWarnings("unchecked") public
focal_class.parameters: (Class<T> type, String name)
focal_class.return: T
focal_class.signature: T getExtension(Class<T> type, String name)
focal_method.body: @Override
      @SuppressWarnings("unchecked")
      public <T> T getExtension(Class<T> type, String name) {
          for (ApplicationContext context : contexts) {
              if (context.containsBean(name)) {
                  Object bean = context.getBean(name);
                  if (type.isInstance(bean)) {
                      return (T) bean;
                  }
              }
          }
  
          logger.warn("No spring extension (bean) named:" + name + ", try to find an extension (bean) of type " + type.getName());
  
          if (Object.class == type) {
              return null;
          }
  
          for (ApplicationContext context : contexts) {
              try {
                  return context.getBean(type);
              } catch (NoUniqueBeanDefinitionException multiBeanExe) {
                  logger.warn("Find more than 1 spring extensions (beans) of type " + type.getName() + ", will stop auto injection. Please make sure you have specified the concrete parameter type and there's only one extension of that type.");
              } catch (NoSuchBeanDefinitionException noBeanExe) {
                  if (logger.isDebugEnabled()) {
                      logger.debug("Error when get spring extension(bean) for type:" + type.getName(), noBeanExe);
                  }
              }
          }
  
          logger.warn("No spring extension (bean) named:" + name + ", type:" + type.getName() + " found, stop get bean.");
  
          return null;
      }
focal_method.class_method_signature: SpringExtensionFactory.getExtension(Class<T> type, String name)
focal_method.full_signature: @Override @SuppressWarnings("unchecked") public T getExtension(Class<T> type, String name)
focal_method.identifier: getExtension
focal_method.invocations: containsBean getBean isInstance warn getName getBean warn getName isDebugEnabled debug getName warn getName
focal_method.modifiers: @Override @SuppressWarnings("unchecked") public
focal_method.parameters: (Class<T> type, String name)
focal_method.return: T
focal_method.signature: T getExtension(Class<T> type, String name)