List of usage examples for org.springframework.beans.factory.config ConfigurableListableBeanFactory getBeanNamesForType
String[] getBeanNamesForType(ResolvableType type, boolean includeNonSingletons, boolean allowEagerInit);
From source file:com.mmnaseri.dragonfly.runtime.assets.BeanDisposer.java
@Override public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { final String[] disposables = beanFactory.getBeanNamesForType(Disposable.class, false, true); final BeanDefinitionRegistry definitionRegistry = (BeanDefinitionRegistry) beanFactory; for (String disposable : disposables) { dispose(definitionRegistry, disposable); }//ww w. j a v a 2 s . co m dispose(definitionRegistry, disposer); }
From source file:gov.nih.nci.cabig.ctms.tools.spring.BeanNameControllerUrlResolver.java
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { String[] controllerNames = beanFactory.getBeanNamesForType(Controller.class, false, false); for (String controllerName : controllerNames) { controllers.put(controllerName, createResolvedReference(controllerName, beanFactory)); }/*from w w w . j a v a 2 s. com*/ }
From source file:at.porscheinformatik.common.spring.web.extended.annotation.DefaultBeanCondition.java
@Override public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) { Map<String, Object> annotationAttributes = metadata.getAnnotationAttributes(DefaultBean.class.getName()); Class<?>[] classes = (Class<?>[]) annotationAttributes.get("value"); ConfigurableListableBeanFactory factory = context.getBeanFactory(); for (Class<?> c : classes) { String[] beanNamesForType = factory.getBeanNamesForType(c, false, false); if (beanNamesForType != null) { for (String beanName : beanNamesForType) { if (factory.containsBean(beanName)) { return false; }// ww w.ja v a2 s. c o m } } } return true; }
From source file:com.mtgi.analytics.aop.config.ChainingBeanFactoryPostProcessor.java
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { if (!targetFactory.equals(beanFactory)) { String[] bfpps = beanFactory.getBeanNamesForType(BeanFactoryPostProcessor.class, false, false); for (String name : bfpps) { BeanFactoryPostProcessor delegate = (BeanFactoryPostProcessor) beanFactory.getBean(name); if (isAllowed(delegate)) delegate.postProcessBeanFactory(targetFactory); }//from w w w. j a v a 2 s .c om } }
From source file:org.sakaiproject.util.SakaiApplicationContext.java
/** * Add bean-created post processors.//w w w .j av a 2 s. com * @param beanFactory */ public void invokePostProcessorCreators(ConfigurableListableBeanFactory beanFactory) { String[] postProcessorCreatorNames = beanFactory.getBeanNamesForType(BeanFactoryPostProcessorCreator.class, false, false); for (int i = 0; i < postProcessorCreatorNames.length; i++) { BeanFactoryPostProcessorCreator postProcessorCreator = (BeanFactoryPostProcessorCreator) beanFactory .getBean(postProcessorCreatorNames[i]); for (BeanFactoryPostProcessor beanFactoryPostProcessor : postProcessorCreator .getBeanFactoryPostProcessors()) { addBeanFactoryPostProcessor(beanFactoryPostProcessor); } } }
From source file:com.github.steveash.spring.WiringFactoryBeanFactoryPostProcessor.java
@Override public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { log.debug("Post processing the bean factory"); String[] wiringFactories = beanFactory.getBeanNamesForType(WiringFactory.class, false, false); for (String beanDefName : wiringFactories) { Class<?> factoryType = checkNotNull(beanFactory.getType(beanDefName), "cant get type for bean"); Class<?> factoryReturnType = checkNotNull(getPrototypeClassFromFactory(factoryType), "cant get return"); addPrototypeDef(beanFactory, beanDefName, factoryReturnType); }/*from w w w. ja va 2 s . c o m*/ }
From source file:org.cloudfoundry.reconfiguration.spring.DataSourceCloudServiceBeanFactoryPostProcessor.java
@Override protected void filterBeanNames(ConfigurableListableBeanFactory beanFactory, Set<String> beanNames) { if (ClassUtils.isPresent(DELEGATING_DATA_SOURCE_CLASS, null)) { Set<String> delegatingBeanNames = Sets.asSet(beanFactory.getBeanNamesForType( ClassUtils.resolveClassName(DELEGATING_DATA_SOURCE_CLASS, null), true, false)); beanNames.removeAll(delegatingBeanNames); }//from w ww .java2s . co m }
From source file:example.app.config.gemfire.GemFireDependsOnBeanFactoryPostProcessor.java
String[] gemfireCacheBeanNames(ConfigurableListableBeanFactory beanFactory) { List<String> gemfireCacheBeanNames = new ArrayList<>(); for (Class<?> gemfireCacheType : Arrays.asList(GemFireCache.class, Cache.class, ClientCache.class)) { gemfireCacheBeanNames/*from w w w . ja v a 2 s. c o m*/ .addAll(Arrays.asList(beanFactory.getBeanNamesForType(gemfireCacheType, true, false))); } if (gemfireCacheBeanNames.isEmpty()) { gemfireCacheBeanNames.add(GemfireConstants.DEFAULT_GEMFIRE_CACHE_NAME); } return gemfireCacheBeanNames.toArray(new String[gemfireCacheBeanNames.size()]); }
From source file:org.cloudfoundry.reconfiguration.util.StandardPropertyAugmenter.java
@Override public void augment(ConfigurableListableBeanFactory beanFactory, Class<?> beanClass, String key, ManagedProperties additionalProperties) { additionalProperties.setMergeEnabled(true); for (String beanName : beanFactory.getBeanNamesForType(beanClass, true, false)) { MutablePropertyValues propertyValues = getBeanDefinition(beanFactory, beanName).getPropertyValues(); Properties originalValue = extractOriginalValue(beanFactory, propertyValues.getPropertyValue(key)); propertyValues.addPropertyValue(key, additionalProperties.merge(originalValue)); }//from w w w . ja va2 s. co m }
From source file:org.jnap.core.persistence.factory.DaoFactory.java
private boolean isDaoDefinedForEntity(ConfigurableListableBeanFactory beanFactory, Class<? extends PersistentModel> entityClass) { if (alreadyDefinedDaos == null) { alreadyDefinedDaos = new HashSet<Class<? extends PersistentModel>>(); for (String beanName : beanFactory.getBeanNamesForType(Dao.class, true, false)) { BeanDefinition beanDefinition = beanFactory.getBeanDefinition(beanName); final Class<?> daoType = ClassUtils.resolveClassName(beanDefinition.getBeanClassName(), DaoFactory.class.getClassLoader()); Class daoEntityClass = GenericTypeResolver.resolveTypeArgument(daoType, Dao.class); alreadyDefinedDaos.add(daoEntityClass); daoNameCache.put(daoEntityClass, beanName); }//from w w w .ja v a2 s. c o m } return alreadyDefinedDaos.contains(entityClass); }