@Test public void testFSMConstructionWithNonDefaultRetry() throws ClassNotFoundException, NoSuchMethodException, SecurityException { BeanDefinitionRegistry registry = new MockBeanDefinitionRegistryImpl(); BeanDefinition userRepo = BeanDefinitionBuilder .genericBeanDefinition(MockRepositoryFactoryBeanSupport.class) .getBeanDefinition(); userRepo.getPropertyValues().add("repositoryInterface", UserRepository.class.getName()); registry.registerBeanDefinition("userRepo", userRepo); BeanDefinition noRetryController = BeanDefinitionBuilder .genericBeanDefinition(NoRetryController.class) .getBeanDefinition(); registry.registerBeanDefinition("noRetryController", noRetryController); ReferenceFactory refFactory = new ReferenceFactoryImpl("noRetryController"); StatefulFactory factory = new StatefulFactory(); factory.postProcessBeanDefinitionRegistry(registry); BeanDefinition fsm = registry.getBeanDefinition(refFactory.getFSMId()); assertNotNull(fsm); assertEquals(1, fsm.getConstructorArgumentValues().getArgumentValue(2, Integer.class).getValue()); assertEquals(1, fsm.getConstructorArgumentValues().getArgumentValue(3, Integer.class).getValue()); }
public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry reg) throws BeansException { logger.debug("postProcessBeanDefinitionRegistry : enter"); try { Reflections reflections = new Reflections((Object[])this.packages); Map<String, EndpointBinder> binders = new HashMap<String, EndpointBinder>(); loadEndpointBinders(reflections, binders); Map<Class<?>, PersistenceSupportBeanFactory> persistenceFactories = new HashMap<Class<?>, PersistenceSupportBeanFactory>(); loadPersistenceSupportBeanFactories(reflections, persistenceFactories); Map<String, Class<?>> controllerToEntityMapping = new HashMap<String, Class<?>>(); Map<Class<?>, String> entityToRepositoryMappings = new HashMap<Class<?>, String>(); mapControllerAndEntityClasses( reg, controllerToEntityMapping, entityToRepositoryMappings, this.entityToControllerMappings); for (Entry<String, Class<?>> entry : controllerToEntityMapping.entrySet()) { buildFramework( entry.getKey(), entry.getValue(), reg, entityToRepositoryMappings, binders, persistenceFactories); } } catch(Exception e) { throw new BeanCreationException("Unable to create bean", e); } logger.debug("postProcessBeanDefinitionRegistry : exit"); }
StatefulFactory implements BeanDefinitionRegistryPostProcessor, ApplicationContextAware { public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry reg) throws BeansException { logger.debug("postProcessBeanDefinitionRegistry : enter"); try { Reflections reflections = new Reflections((Object[])this.packages); Map<String, EndpointBinder> binders = new HashMap<String, EndpointBinder>(); loadEndpointBinders(reflections, binders); Map<Class<?>, PersistenceSupportBeanFactory> persistenceFactories = new HashMap<Class<?>, PersistenceSupportBeanFactory>(); loadPersistenceSupportBeanFactories(reflections, persistenceFactories); Map<String, Class<?>> controllerToEntityMapping = new HashMap<String, Class<?>>(); Map<Class<?>, String> entityToRepositoryMappings = new HashMap<Class<?>, String>(); mapControllerAndEntityClasses( reg, controllerToEntityMapping, entityToRepositoryMappings, this.entityToControllerMappings); for (Entry<String, Class<?>> entry : controllerToEntityMapping.entrySet()) { buildFramework( entry.getKey(), entry.getValue(), reg, entityToRepositoryMappings, binders, persistenceFactories); } } catch(Exception e) { throw new BeanCreationException("Unable to create bean", e); } logger.debug("postProcessBeanDefinitionRegistry : exit"); } }
StatefulFactory implements BeanDefinitionRegistryPostProcessor, ApplicationContextAware { public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry reg) throws BeansException { logger.debug("postProcessBeanDefinitionRegistry : enter"); try { Reflections reflections = new Reflections((Object[])this.packages); Map<String, EndpointBinder> binders = new HashMap<String, EndpointBinder>(); loadEndpointBinders(reflections, binders); Map<Class<?>, PersistenceSupportBeanFactory> persistenceFactories = new HashMap<Class<?>, PersistenceSupportBeanFactory>(); loadPersistenceSupportBeanFactories(reflections, persistenceFactories); Map<String, Class<?>> controllerToEntityMapping = new HashMap<String, Class<?>>(); Map<Class<?>, String> entityToRepositoryMappings = new HashMap<Class<?>, String>(); mapControllerAndEntityClasses( reg, controllerToEntityMapping, entityToRepositoryMappings, this.entityToControllerMappings); for (Entry<String, Class<?>> entry : controllerToEntityMapping.entrySet()) { buildFramework( entry.getKey(), entry.getValue(), reg, entityToRepositoryMappings, binders, persistenceFactories); } } catch(Exception e) { throw new BeanCreationException("Unable to create bean", e); } logger.debug("postProcessBeanDefinitionRegistry : exit"); } StatefulFactory();  StatefulFactory(String... packages); }
StatefulFactory implements BeanDefinitionRegistryPostProcessor, ApplicationContextAware { public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry reg) throws BeansException { logger.debug("postProcessBeanDefinitionRegistry : enter"); try { Reflections reflections = new Reflections((Object[])this.packages); Map<String, EndpointBinder> binders = new HashMap<String, EndpointBinder>(); loadEndpointBinders(reflections, binders); Map<Class<?>, PersistenceSupportBeanFactory> persistenceFactories = new HashMap<Class<?>, PersistenceSupportBeanFactory>(); loadPersistenceSupportBeanFactories(reflections, persistenceFactories); Map<String, Class<?>> controllerToEntityMapping = new HashMap<String, Class<?>>(); Map<Class<?>, String> entityToRepositoryMappings = new HashMap<Class<?>, String>(); mapControllerAndEntityClasses( reg, controllerToEntityMapping, entityToRepositoryMappings, this.entityToControllerMappings); for (Entry<String, Class<?>> entry : controllerToEntityMapping.entrySet()) { buildFramework( entry.getKey(), entry.getValue(), reg, entityToRepositoryMappings, binders, persistenceFactories); } } catch(Exception e) { throw new BeanCreationException("Unable to create bean", e); } logger.debug("postProcessBeanDefinitionRegistry : exit"); } StatefulFactory();  StatefulFactory(String... packages); void postProcessBeanFactory(final ConfigurableListableBeanFactory reg); @Override void setApplicationContext(ApplicationContext applicationContext); void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry reg); }
StatefulFactory implements BeanDefinitionRegistryPostProcessor, ApplicationContextAware { public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry reg) throws BeansException { logger.debug("postProcessBeanDefinitionRegistry : enter"); try { Reflections reflections = new Reflections((Object[])this.packages); Map<String, EndpointBinder> binders = new HashMap<String, EndpointBinder>(); loadEndpointBinders(reflections, binders); Map<Class<?>, PersistenceSupportBeanFactory> persistenceFactories = new HashMap<Class<?>, PersistenceSupportBeanFactory>(); loadPersistenceSupportBeanFactories(reflections, persistenceFactories); Map<String, Class<?>> controllerToEntityMapping = new HashMap<String, Class<?>>(); Map<Class<?>, String> entityToRepositoryMappings = new HashMap<Class<?>, String>(); mapControllerAndEntityClasses( reg, controllerToEntityMapping, entityToRepositoryMappings, this.entityToControllerMappings); for (Entry<String, Class<?>> entry : controllerToEntityMapping.entrySet()) { buildFramework( entry.getKey(), entry.getValue(), reg, entityToRepositoryMappings, binders, persistenceFactories); } } catch(Exception e) { throw new BeanCreationException("Unable to create bean", e); } logger.debug("postProcessBeanDefinitionRegistry : exit"); } StatefulFactory();  StatefulFactory(String... packages); void postProcessBeanFactory(final ConfigurableListableBeanFactory reg); @Override void setApplicationContext(ApplicationContext applicationContext); void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry reg);  }