List of usage examples for org.springframework.beans.factory.config ConfigurableListableBeanFactory getBeanDefinitionNames
String[] getBeanDefinitionNames();
From source file:me.springframework.di.spring.SpringConfigurationLoader.java
/** * Returns a {@link Map} of {@link MutableInstance MutableInstances}, * indexed by name./*from ww w. jav a 2 s. c o m*/ * * @param registry * The {@link BeanDefinitionRegistry} holding the bean * definitions. * @return A {@link Map} of {@link MutableInstance MutableInstances} * representing the root beans defined by the * {@link ListableBeanFactory}. */ protected static MutableContext loadBeans(ConfigurableListableBeanFactory factory) { MutableContext context = new MutableContext(); for (String name : factory.getBeanDefinitionNames()) { for (String alias : factory.getAliases(name)) { context.addAlias(alias, name); } } for (String name : factory.getBeanDefinitionNames()) { BeanDefinition definition = factory.getBeanDefinition(name); if (!definition.isAbstract()) { BeanDefinition merged = factory.getMergedBeanDefinition(name); MutableInstance instance = new MutableInstance(name); load(instance, merged, context); context.addInstance(name, instance); } } return context; }
From source file:com.isalnikov.config.hendler.BeanHendlerFactoryPostProcessor.java
@Override public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { String[] names = beanFactory.getBeanDefinitionNames(); for (String name : names) { BeanDefinition beanDefinition = beanFactory.getBeanDefinition(name); String beanClassName = beanDefinition.getBeanClassName(); try {/*from ww w.j a v a2 s . co m*/ System.out.println(beanClassName); if (beanClassName != null) { Class<?> beanClass = Class.forName(beanClassName); if (beanClass != null) { /// System.out.println(beanClassName); } } } catch (ClassNotFoundException e) { System.out.println(e); } } }
From source file:org.jdal.beans.ParentBeanFactoryPostProcessor.java
/** * {@inheritDoc}/*from w w w .ja v a 2s . c o m*/ */ @Override public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { String[] names = beanFactory.getBeanDefinitionNames(); for (String beanName : names) { Parent parent = beanFactory.findAnnotationOnBean(beanName, Parent.class); if (parent != null) { BeanDefinition bd = beanFactory.getBeanDefinition(beanName); bd.setParentName(parent.value()); } } }
From source file:com.fitbur.testify.di.spring.SpringServicePostProcessor.java
@Override public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { of(beanFactory.getBeanDefinitionNames()).parallel().map(beanFactory::getBeanDefinition) .forEach(p -> p.setLazyInit(true)); methodTestNeeds.inject(serviceLocator); methodTestNeedContainers.inject(serviceLocator); if (classTestNeeds != null) { classTestNeeds.inject(serviceLocator); }//from www. j a v a 2 s . com if (classTestNeedContainers != null) { classTestNeedContainers.inject(serviceLocator); } }
From source file:org.apache.james.container.spring.bean.factorypostprocessor.FileSystemBeanFactoryPostProcessor.java
/** * @see org.springframework.beans.factory.config.BeanFactoryPostProcessor#postProcessBeanFactory * (org.springframework.beans.factory.config.ConfigurableListableBeanFactory) *///from ww w.ja v a 2 s . c o m public void postProcessBeanFactory(ConfigurableListableBeanFactory factory) throws BeansException { String names[] = factory.getBeanDefinitionNames(); for (int i = 0; i < names.length; i++) { BeanDefinition def = factory.getBeanDefinition(names[i]); visitor.visitBeanDefinition(def); } }
From source file:com.agileapes.motorex.cli.value.impl.SpringValueReaderContext.java
@Override public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { final String[] names = beanFactory.getBeanDefinitionNames(); for (String name : names) { final BeanDefinition definition = beanFactory.getBeanDefinition(name); if (definition.isSingleton()) { final String className = definition.getBeanClassName(); try { final Class<?> beanType = ClassUtils.forName(className, beanFactory.getBeanClassLoader()); if (ValueReader.class.isAssignableFrom(beanType)) { register(beanFactory.getBean(name, ValueReader.class)); }/*from w w w . j av a2 s .co m*/ } catch (ClassNotFoundException e) { throw new BeanCreationNotAllowedException(name, "Failed to access bean"); } } } }
From source file:com.agileapes.motorex.cli.target.impl.SpringExecutionTargetContext.java
@Override public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { final String[] names = beanFactory.getBeanDefinitionNames(); for (String name : names) { final BeanDefinition definition = beanFactory.getBeanDefinition(name); if (definition.isSingleton()) { final String className = definition.getBeanClassName(); try { final Class<?> beanClass = ClassUtils.forName(className, beanFactory.getBeanClassLoader()); if (ExecutionTarget.class.isAssignableFrom(beanClass)) { final ExecutionTarget target = beanFactory.getBean(name, ExecutionTarget.class); if (target instanceof AbstractIdentifiedExecutionTarget) { AbstractIdentifiedExecutionTarget executionTarget = (AbstractIdentifiedExecutionTarget) target; executionTarget.setIdentifier(name); }//from www . jav a 2 s . c om register(target); } } catch (ClassNotFoundException e) { throw new BeanCreationException(name, "Could not access bean class"); } } } }
From source file:it.cosenonjaviste.alfresco.annotations.processors.runtime.AbstractPostProcessorConfigurer.java
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { String[] beanDefinitionNames = beanFactory.getBeanDefinitionNames(); for (String definitionName : beanDefinitionNames) { try {//from w w w . j a va 2 s .c o m final BeanDefinition bd = beanFactory.getBeanDefinition(definitionName); final String beanClassName = bd.getBeanClassName(); if (StringUtils.hasText(beanClassName)) { try { processBeanDefinition(beanFactory, bd, beanClassName, definitionName); } catch (Exception e) { logger.error(e.getMessage(), e); throw new FatalBeanException("Unknown class defined.", e); } } } catch (NoSuchBeanDefinitionException ex) { logger.warn(ex.getMessage()); continue; } } }
From source file:org.bytesoft.bytetcc.supports.spring.TransactionConfigPostProcessor.java
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { String[] beanNameArray = beanFactory.getBeanDefinitionNames(); for (int i = 0; i < beanNameArray.length; i++) { String beanName = beanNameArray[i]; BeanDefinition beanDef = beanFactory.getBeanDefinition(beanName); String beanClassName = beanDef.getBeanClassName(); if (org.springframework.transaction.interceptor.TransactionProxyFactoryBean.class.getName() .equals(beanClassName)) { throw new FatalBeanException(String.format( "Declaring transactions by configuration is not supported yet, please use annotations to declare transactions(beanId= %s).", beanName));/* w w w. ja v a2s.c o m*/ } if (org.springframework.transaction.interceptor.TransactionInterceptor.class.getName() .equals(beanClassName)) { boolean errorExists = true; MutablePropertyValues mpv = beanDef.getPropertyValues(); PropertyValue pv = mpv.getPropertyValue("transactionAttributeSource"); Object value = pv == null ? null : pv.getValue(); if (value != null && RuntimeBeanReference.class.isInstance(value)) { RuntimeBeanReference reference = (RuntimeBeanReference) value; BeanDefinition refBeanDef = beanFactory.getBeanDefinition(reference.getBeanName()); String refBeanClassName = refBeanDef.getBeanClassName(); errorExists = AnnotationTransactionAttributeSource.class.getName() .equals(refBeanClassName) == false; } if (errorExists) { throw new FatalBeanException(String.format( "Declaring transactions by configuration is not supported yet, please use annotations to declare transactions(beanId= %s).", beanName)); } } } }
From source file:com.himanshu.spring.context.loader.sameconfigallcontext.bean.visitor.PrefixPropertyPlaceholderConfigurer.java
@Override protected void processProperties(ConfigurableListableBeanFactory beanFactoryToProcess, Properties props) throws BeansException { String[] beansDefinitionNames = beanFactoryToProcess.getBeanDefinitionNames(); for (String beanDefinitionName : beansDefinitionNames) { BeanDefinition beanDefinitionToProcess = beanFactoryToProcess.getBeanDefinition(beanDefinitionName); BeanVisitor visitor = new BeanVisitor(prefix, "${", "}"); visitor.visit(beanDefinitionToProcess); }//from w w w .jav a 2 s. com super.processProperties(beanFactoryToProcess, props); }