@Test public void testAlternativePackages() throws ClassNotFoundException { BeanDefinitionRegistry registry = new MockBeanDefinitionRegistryImpl(); BeanDefinition testUserRepo = BeanDefinitionBuilder .genericBeanDefinition(AltTestRepositoryFactoryBeanSupport.class) .getBeanDefinition(); testUserRepo.getPropertyValues().add("repositoryInterface", AltTestUserRepository.class.getName()); registry.registerBeanDefinition("testUserRepo", testUserRepo); BeanDefinition testUserController = BeanDefinitionBuilder .genericBeanDefinition(AltTestUserController.class) .getBeanDefinition(); registry.registerBeanDefinition("testUserController", testUserController); ReferenceFactory refFactory = new ReferenceFactoryImpl("testUserController"); StatefulFactory factory = new StatefulFactory("org.alternative"); factory.postProcessBeanDefinitionRegistry(registry); BeanDefinition testUserControllerMVCProxy = registry.getBeanDefinition(refFactory.getBinderId("test")); assertNotNull(testUserControllerMVCProxy); Class<?> proxyClass = Class.forName(testUserControllerMVCProxy.getBeanClassName()); assertNotNull(proxyClass); assertEquals(MockProxy.class, proxyClass); BeanDefinition stateOne = registry.getBeanDefinition(refFactory.getStateId(AltTestUserController.ONE_STATE)); assertNotNull(stateOne); BeanDefinition persister = registry.getBeanDefinition(refFactory.getPersisterId()); assertNotNull(persister); }
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);  }