@Test @SuppressWarnings("unchecked") public void createHandleConditionMatcher_BeanType_NonSingleton() throws Exception { Set<ExtensionIdCondition> annotations = AnnotationUtils.getRepeatableAnnotations( TestHandler.class, ExtensionIdCondition.class); ExtensionIdConditionMatcher matcher = cekRequestMappingHandlerMapping.createHandleConditionMatcher( ExtensionIdConditionMatcherFactory.class, annotations); Collection<String> extensionIds = (Collection<String>) ReflectionTestUtils.getField(matcher, "extensionIds"); assertThat(extensionIds).containsOnlyOnce("foo"); }
<F extends CEKHandleConditionMatcherFactory<M, A>, M extends CEKHandleConditionMatcher, A extends Annotation> M createHandleConditionMatcher(Class<F> factoryType, Collection<A> annotations) { F factory; try { factory = beanFactory.getBean(factoryType); } catch (NoSuchBeanDefinitionException e) { factory = BeanUtils.instantiateClass(factoryType); } return factory.create(annotations); }
CEKRequestMappingHandlerMapping implements BeanFactoryAware, InitializingBean { <F extends CEKHandleConditionMatcherFactory<M, A>, M extends CEKHandleConditionMatcher, A extends Annotation> M createHandleConditionMatcher(Class<F> factoryType, Collection<A> annotations) { F factory; try { factory = beanFactory.getBean(factoryType); } catch (NoSuchBeanDefinitionException e) { factory = BeanUtils.instantiateClass(factoryType); } return factory.create(annotations); } }
CEKRequestMappingHandlerMapping implements BeanFactoryAware, InitializingBean { <F extends CEKHandleConditionMatcherFactory<M, A>, M extends CEKHandleConditionMatcher, A extends Annotation> M createHandleConditionMatcher(Class<F> factoryType, Collection<A> annotations) { F factory; try { factory = beanFactory.getBean(factoryType); } catch (NoSuchBeanDefinitionException e) { factory = BeanUtils.instantiateClass(factoryType); } return factory.create(annotations); }  }
CEKRequestMappingHandlerMapping implements BeanFactoryAware, InitializingBean { <F extends CEKHandleConditionMatcherFactory<M, A>, M extends CEKHandleConditionMatcher, A extends Annotation> M createHandleConditionMatcher(Class<F> factoryType, Collection<A> annotations) { F factory; try { factory = beanFactory.getBean(factoryType); } catch (NoSuchBeanDefinitionException e) { factory = BeanUtils.instantiateClass(factoryType); } return factory.create(annotations); }  @Override void afterPropertiesSet(); }
CEKRequestMappingHandlerMapping implements BeanFactoryAware, InitializingBean { <F extends CEKHandleConditionMatcherFactory<M, A>, M extends CEKHandleConditionMatcher, A extends Annotation> M createHandleConditionMatcher(Class<F> factoryType, Collection<A> annotations) { F factory; try { factory = beanFactory.getBean(factoryType); } catch (NoSuchBeanDefinitionException e) { factory = BeanUtils.instantiateClass(factoryType); } return factory.create(annotations); }  @Override void afterPropertiesSet();  }