org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport Java Examples

The following examples show how to use org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: StatefulFactory.java    From statefulj with Apache License 2.0 5 votes vote down vote up
/**
 * Iterate thru all beans and fetch the StatefulControllers
 *
 * @param reg
 * @return
 * @throws ClassNotFoundException
 */
private void mapControllerAndEntityClasses(
		BeanDefinitionRegistry reg,
		Map<String, Class<?>> controllerToEntityMapping,
		Map<Class<?>, String> entityToRepositoryMapping,
		Map<Class<?>, Set<String>> entityToControllerMappings) throws ClassNotFoundException {

	// Loop thru the bean registry
	//
	for(String bfName : reg.getBeanDefinitionNames()) {

		BeanDefinition bf = reg.getBeanDefinition(bfName);

		if (bf.isAbstract()) {
			logger.debug("Skipping abstract bean " + bfName);
			continue;
		}

		Class<?> clazz = getClassFromBeanDefinition(bf, reg);

		if (clazz == null) {
			logger.debug("Unable to resolve class for bean " + bfName);
			continue;
		}

		// If it's a StatefulController, map controller to the entity and the entity to the controller
		//
		if (ReflectionUtils.isAnnotationPresent(clazz, StatefulController.class)) {
			mapEntityWithController(controllerToEntityMapping, entityToControllerMappings, bfName, clazz);
		}

		// Else, if the Bean is a Repository, then map the
		// Entity associated with the Repo to the PersistenceSupport object
		//
		else if (RepositoryFactoryBeanSupport.class.isAssignableFrom(clazz)) {
			mapEntityToRepository(entityToRepositoryMapping, bfName, bf);
		}
	}
}