@Test public void testFSMConstruction() 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 userController = BeanDefinitionBuilder .genericBeanDefinition(UserController.class) .getBeanDefinition(); registry.registerBeanDefinition("userController", userController); ReferenceFactory refFactory = new ReferenceFactoryImpl("userController"); StatefulFactory factory = new StatefulFactory(); factory.postProcessBeanDefinitionRegistry(registry); BeanDefinition userControllerMVCProxy = registry.getBeanDefinition(refFactory.getBinderId("mock")); assertNotNull(userControllerMVCProxy); Class<?> proxyClass = Class.forName(userControllerMVCProxy.getBeanClassName()); assertNotNull(proxyClass); assertEquals(MockProxy.class, proxyClass); BeanDefinition stateFive = registry.getBeanDefinition(refFactory.getStateId(UserController.FIVE_STATE)); assertEquals(true, stateFive.getConstructorArgumentValues().getArgumentValue(2, Boolean.class).getValue()); BeanDefinition fsm = registry.getBeanDefinition(refFactory.getFSMId()); assertNotNull(fsm); assertEquals(20, fsm.getConstructorArgumentValues().getArgumentValue(2, Integer.class).getValue()); assertEquals(250, 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);  }