当前位置: 首页>>代码示例>>Java>>正文


Java ConfigurableListableBeanFactory.getBeanDefinition方法代码示例

本文整理汇总了Java中org.springframework.beans.factory.config.ConfigurableListableBeanFactory.getBeanDefinition方法的典型用法代码示例。如果您正苦于以下问题:Java ConfigurableListableBeanFactory.getBeanDefinition方法的具体用法?Java ConfigurableListableBeanFactory.getBeanDefinition怎么用?Java ConfigurableListableBeanFactory.getBeanDefinition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.beans.factory.config.ConfigurableListableBeanFactory的用法示例。


在下文中一共展示了ConfigurableListableBeanFactory.getBeanDefinition方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: buildComponentMetadataFor

import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; //导入方法依赖的package包/类
public static List<ComponentMetadata> buildComponentMetadataFor(ConfigurableListableBeanFactory factory) {
	List<ComponentMetadata> metadata = new ArrayList<ComponentMetadata>();
	String[] components = factory.getBeanDefinitionNames();

	for (String beanName : components) {
		BeanDefinition definition = factory.getBeanDefinition(beanName);

		// filter generated definitions
		if (!definition.hasAttribute(PROMOTED_REF)) {
			// add metadata for top-level definitions
			metadata.add(MetadataFactory.buildComponentMetadataFor(beanName, definition));
			// look for nested ones
			metadata.addAll(MetadataFactory.buildNestedComponentMetadataFor(definition));
		}
	}

	return metadata;
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:19,代码来源:ComponentMetadataFactory.java

示例2: postProcessBeanFactory

import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; //导入方法依赖的package包/类
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {

		boolean trace = log.isTraceEnabled();

		String[] names = beanFactory.getBeanDefinitionNames();
		for (String name : names) {
			BeanDefinition definition = beanFactory.getBeanDefinition(name);
			if (definition.hasAttribute(ParsingUtils.BLUEPRINT_MARKER_NAME)) {
				ConstructorArgumentValues cArgs = definition.getConstructorArgumentValues();
				if (trace)
					log.trace("Inspecting cycles for (blueprint) bean " + name);

				tag(cArgs.getGenericArgumentValues(), name, definition);
				tag(cArgs.getIndexedArgumentValues().values(), name, definition);
			}
		}
	}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:18,代码来源:CycleOrderingProcessor.java

示例3: postProcessBeanFactory

import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; //导入方法依赖的package包/类
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override public void postProcessBeanFactory(
    ConfigurableListableBeanFactory configurableListableBeanFactory) throws BeansException {
    String[] igniteConfigNames = configurableListableBeanFactory.getBeanNamesForType(IgniteConfiguration.class);
    if (igniteConfigNames.length != 1) {
        throw new IllegalArgumentException("Spring config must contain exactly one ignite configuration!");
    }
    String[] activeStoreConfigNames = configurableListableBeanFactory.getBeanNamesForType(BaseActiveStoreConfiguration.class);
    if (activeStoreConfigNames.length != 1) {
        throw new IllegalArgumentException("Spring config must contain exactly one active store configuration!");
    }
    BeanDefinition igniteConfigDef = configurableListableBeanFactory.getBeanDefinition(igniteConfigNames[0]);
    MutablePropertyValues propertyValues = igniteConfigDef.getPropertyValues();
    if (!propertyValues.contains(USER_ATTRS_PROP_NAME)) {
        propertyValues.add(USER_ATTRS_PROP_NAME, new ManagedMap());
    }
    PropertyValue propertyValue = propertyValues.getPropertyValue(USER_ATTRS_PROP_NAME);
    Map userAttrs = (Map)propertyValue.getValue();
    TypedStringValue key = new TypedStringValue(CONFIG_USER_ATTR);
    RuntimeBeanReference value = new RuntimeBeanReference(beanName);
    userAttrs.put(key, value);
}
 
开发者ID:epam,项目名称:Lagerta,代码行数:24,代码来源:BaseActiveStoreConfiguration.java

示例4: getBeanFactoryClassName

import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; //导入方法依赖的package包/类
/**
 * Get the Factory class name which corresponds to given bean definition.
 * @param definition Bean definition
 * @param beanFactory Bean factory
 * @return Factory class name, or <code>null</code> if not found
 */
private static String getBeanFactoryClassName(BeanDefinition definition,
		ConfigurableListableBeanFactory beanFactory) {
	if (definition instanceof AnnotatedBeanDefinition) {
		return ((AnnotatedBeanDefinition) definition).getMetadata().getClassName();
	} else {
		if (definition.getFactoryBeanName() != null) {
			BeanDefinition fd = beanFactory.getBeanDefinition(definition.getFactoryBeanName());
			if (fd != null) {
				return fd.getBeanClassName();
			}
		} else {
			return definition.getBeanClassName();
		}
	}
	return null;
}
 
开发者ID:holon-platform,项目名称:holon-core,代码行数:23,代码来源:BeanRegistryUtils.java

示例5: postProcessBeanFactory

import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; //导入方法依赖的package包/类
@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
    this.beanFactory = beanFactory;
    for (String name : beanFactory.getBeanDefinitionNames()) {
        BeanDefinition definition = beanFactory.getBeanDefinition(name);
        String method = definition.getFactoryMethodName();
        String bean = definition.getFactoryBeanName();
        if (method != null && bean != null) {
            this.beans.put(name, new MetaData(bean, method));
        }
    }
}
 
开发者ID:zouzhirong,项目名称:configx,代码行数:13,代码来源:ConfigurationBeanFactoryMetaData.java

示例6: postProcessBeanFactory

import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; //导入方法依赖的package包/类
/**
 * @see org.springframework.beans.factory.config.BeanFactoryPostProcessor#postProcessBeanFactory(org.springframework.beans.factory.config.ConfigurableListableBeanFactory)
 */
@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory)
{
    ParameterCheck.mandatory("beanName", beanName);
    ParameterCheck.mandatory("extendingBeanName", extendingBeanName);

    // check for bean name
    if (!beanFactory.containsBean(beanName))
    {
        throw new NoSuchBeanDefinitionException("Can't find bean '" + beanName + "' to be extended.");
    }

    // check for extending bean
    if (!beanFactory.containsBean(extendingBeanName))
    {
        throw new NoSuchBeanDefinitionException("Can't find bean '" + extendingBeanName + "' that is going to extend original bean definition.");
    }

    // get the bean definitions
    BeanDefinition beanDefinition = beanFactory.getBeanDefinition(beanName);
    BeanDefinition extendingBeanDefinition = beanFactory.getBeanDefinition(extendingBeanName);

    // update class
    if (StringUtils.isNotBlank(extendingBeanDefinition.getBeanClassName()) &&
        !beanDefinition.getBeanClassName().equals(extendingBeanDefinition.getBeanClassName()))
    {
        beanDefinition.setBeanClassName(extendingBeanDefinition.getBeanClassName());
    }

    // update properties
    MutablePropertyValues properties = beanDefinition.getPropertyValues();
    MutablePropertyValues extendingProperties = extendingBeanDefinition.getPropertyValues();
    for (PropertyValue propertyValue : extendingProperties.getPropertyValueList())
    {
        properties.add(propertyValue.getName(), propertyValue.getValue());
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:41,代码来源:BeanExtender.java

示例7: findBeanDefinition

import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; //导入方法依赖的package包/类
private BeanDefinition findBeanDefinition(ConfigurableListableBeanFactory beanFactory,
                                          String beanName, boolean considerHierarchy) {
    if (beanFactory.containsBeanDefinition(beanName)) {
        return beanFactory.getBeanDefinition(beanName);
    }
    if (considerHierarchy && beanFactory.getParentBeanFactory() instanceof ConfigurableListableBeanFactory) {
        return findBeanDefinition(((ConfigurableListableBeanFactory) beanFactory.getParentBeanFactory()), beanName, considerHierarchy);
    }
    return null;
}
 
开发者ID:drtrang,项目名称:spring-boot-autoconfigure,代码行数:11,代码来源:OnBeansCondition.java

示例8: getFactoryMethod

import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; //导入方法依赖的package包/类
private Method getFactoryMethod(ConfigurableListableBeanFactory beanFactory,
                                BeanDefinition definition) throws Exception {
    if (definition instanceof AnnotatedBeanDefinition) {
        MethodMetadata factoryMethodMetadata = ((AnnotatedBeanDefinition) definition).getFactoryMethodMetadata();
        if (factoryMethodMetadata instanceof StandardMethodMetadata) {
            return ((StandardMethodMetadata) factoryMethodMetadata).getIntrospectedMethod();
        }
    }
    BeanDefinition factoryDefinition = beanFactory.getBeanDefinition(definition.getFactoryBeanName());
    Class<?> factoryClass = ClassUtils.forName(factoryDefinition.getBeanClassName(), beanFactory.getBeanClassLoader());
    return getFactoryMethod(definition, factoryClass);
}
 
开发者ID:drtrang,项目名称:spring-boot-autoconfigure,代码行数:13,代码来源:BeanTypeRegistry.java

示例9: getServiceDependencies

import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; //导入方法依赖的package包/类
public Collection<OsgiServiceDependency> getServiceDependencies(BundleContext bundleContext,
		ConfigurableListableBeanFactory beanFactory) throws BeansException, InvalidSyntaxException, BundleException {

	Set<OsgiServiceDependency> dependencies = new LinkedHashSet<OsgiServiceDependency>();

	String[] beanDefinitionNames = beanFactory.getBeanDefinitionNames();
	for (String definitionName : beanDefinitionNames) {
		BeanDefinition definition = beanFactory.getBeanDefinition(definitionName);
		String className = definition.getBeanClassName();
		// Ignore internal stuff
		if (className == null
			|| className.equals(OsgiServiceProxyFactoryBean.class.getName())
			|| className.equals(OsgiServiceFactoryBean.class.getName())
			|| className.equals(OsgiServiceCollectionProxyFactoryBean.class.getName())) {
			continue;
		}
		try {
			Class<?> clazz = Class.forName(className, true, beanFactory.getBeanClassLoader());
			dependencies.addAll(getClassServiceDependencies(clazz, definitionName, definition));
		}
		catch (ClassNotFoundException cnfe) {
			if (logger.isDebugEnabled())
				logger.debug("Could not load class [" + className + "] for ["
						+ bundleContext.getBundle().getSymbolicName() + "]");
		}
	}
	if (logger.isDebugEnabled())
		logger.debug("Processing annotations for [" + bundleContext.getBundle().getSymbolicName() + "] found "
				+ dependencies);

	return dependencies;
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:33,代码来源:ServiceReferenceDependencyBeanFactoryPostProcessor.java

示例10: processProperties

import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; //导入方法依赖的package包/类
@Override
protected void processProperties(ConfigurableListableBeanFactory beanFactoryToProcess, Properties props) throws BeansException {
	StringValueResolver valueResolver = new StringValueResolver() {

		@Override
		public String resolveStringValue(String strVal) {
			StringBuffer sb = new StringBuffer(strVal);
			/**
			 * 给变量加上${XXXXXXX}
			 */
			boolean start = strVal.startsWith(Constant.PLACEHOLDER_PREFIX);
			boolean end = strVal.endsWith(Constant.PLACEHOLDER_SUFFIX);
			while(start && end) {
				String key = sb.substring(placeholderPrefix.length(), sb.length() - placeholderSuffix.length());
				String zkValue = ShiZiQiuConfClient.get(key, "");
				logger.info(">>>>>>>>>>> resolved placeholder '" + key + "' to value [" + zkValue + "]");
				sb = new StringBuffer(zkValue);
				start = sb.toString().startsWith(placeholderPrefix);
				end = sb.toString().endsWith(placeholderSuffix);
			}
			return sb.toString();
		}
	};
	BeanDefinitionVisitor visitor = new BeanDefinitionVisitor(valueResolver);
	String[] beanNames = beanFactoryToProcess.getBeanDefinitionNames();
	if (null != beanNames && beanNames.length > 0) {
		for (String beanName : beanNames) {
			if(!(beanName.equals(this.beanName)) && beanFactoryToProcess.equals(this.beanFactory)) {
				BeanDefinition bd = beanFactoryToProcess.getBeanDefinition(beanName);
				visitor.visitBeanDefinition(bd);
			}
		}
	}
}
 
开发者ID:shiziqiu,项目名称:shiziqiu-configuration,代码行数:35,代码来源:ShiZiQiuConfPlaceholderConfigurer.java

示例11: postProcessBeanFactory

import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; //导入方法依赖的package包/类
@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
    String[] autoInitBeanNames = beanFactory.getBeanNamesForType(AbstractCacheAutoInit.class, false, false);
    if (autoInitBeanNames != null) {
        BeanDefinition bd = beanFactory.getBeanDefinition(JetCacheAutoConfiguration.GLOBAL_CACHE_CONFIG_NAME);
        String[] dependsOn = bd.getDependsOn();
        if (dependsOn == null) {
            dependsOn = new String[0];
        }
        int oldLen = dependsOn.length;
        dependsOn = Arrays.copyOf(dependsOn, dependsOn.length + autoInitBeanNames.length);
        System.arraycopy(autoInitBeanNames,0, dependsOn, oldLen, autoInitBeanNames.length);
        bd.setDependsOn(dependsOn);
    }
}
 
开发者ID:alibaba,项目名称:jetcache,代码行数:16,代码来源:BeanDependencyManager.java

示例12: generateJson

import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; //导入方法依赖的package包/类
/**
 * Actually generate a JSON snapshot of the beans in the given ApplicationContexts.
 * <p>This implementation doesn't use any JSON parsing libraries in order to avoid
 * third-party library dependencies. It produces an array of context description
 * objects, each containing a context and parent attribute as well as a beans
 * attribute with nested bean description objects. Each bean object contains a
 * bean, scope, type and resource attribute, as well as a dependencies attribute
 * with a nested array of bean names that the present bean depends on.
 * @param contexts the set of ApplicationContexts
 * @return the JSON document
 */
protected String generateJson(Set<ConfigurableApplicationContext> contexts) {
	StringBuilder result = new StringBuilder("[\n");
	for (Iterator<ConfigurableApplicationContext> it = contexts.iterator(); it.hasNext();) {
		ConfigurableApplicationContext context = it.next();
		result.append("{\n\"context\": \"").append(context.getId()).append("\",\n");
		if (context.getParent() != null) {
			result.append("\"parent\": \"").append(context.getParent().getId()).append("\",\n");
		}
		else {
			result.append("\"parent\": null,\n");
		}
		result.append("\"beans\": [\n");
		ConfigurableListableBeanFactory bf = context.getBeanFactory();
		String[] beanNames = bf.getBeanDefinitionNames();
		boolean elementAppended = false;
		for (String beanName : beanNames) {
			BeanDefinition bd = bf.getBeanDefinition(beanName);
			if (isBeanEligible(beanName, bd, bf)) {
				if (elementAppended) {
					result.append(",\n");
				}
				result.append("{\n\"bean\": \"").append(beanName).append("\",\n");
				String scope = bd.getScope();
				if (!StringUtils.hasText(scope)) {
					scope = BeanDefinition.SCOPE_SINGLETON;
				}
				result.append("\"scope\": \"").append(scope).append("\",\n");
				Class<?> beanType = bf.getType(beanName);
				if (beanType != null) {
					result.append("\"type\": \"").append(beanType.getName()).append("\",\n");
				}
				else {
					result.append("\"type\": null,\n");
				}
				String resource = StringUtils.replace(bd.getResourceDescription(), "\\", "/");
				result.append("\"resource\": \"").append(resource).append("\",\n");
				result.append("\"dependencies\": [");
				String[] dependencies = bf.getDependenciesForBean(beanName);
				if (dependencies.length > 0) {
					result.append("\"");
				}
				result.append(StringUtils.arrayToDelimitedString(dependencies, "\", \""));
				if (dependencies.length > 0) {
					result.append("\"");
				}
				result.append("]\n}");
				elementAppended = true;
			}
		}
		result.append("]\n");
		result.append("}");
		if (it.hasNext()) {
			result.append(",\n");
		}
	}
	result.append("]");
	return result.toString();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:70,代码来源:LiveBeansView.java

示例13: shouldSkip

import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; //导入方法依赖的package包/类
/**
 * Check whether the given bean definition is not subject to the annotation-based
 * required property check as performed by this post-processor.
 * <p>The default implementations check for the presence of the
 * {@link #SKIP_REQUIRED_CHECK_ATTRIBUTE} attribute in the bean definition, if any.
 * It also suggests skipping in case of a bean definition with a "factory-bean"
 * reference set, assuming that instance-based factories pre-populate the bean.
 * @param beanFactory the BeanFactory to check against
 * @param beanName the name of the bean to check against
 * @return {@code true} to skip the bean; {@code false} to process it
 */
protected boolean shouldSkip(ConfigurableListableBeanFactory beanFactory, String beanName) {
	if (beanFactory == null || !beanFactory.containsBeanDefinition(beanName)) {
		return false;
	}
	BeanDefinition beanDefinition = beanFactory.getBeanDefinition(beanName);
	if (beanDefinition.getFactoryBeanName() != null) {
		return true;
	}
	Object value = beanDefinition.getAttribute(SKIP_REQUIRED_CHECK_ATTRIBUTE);
	return (value != null && (Boolean.TRUE.equals(value) || Boolean.valueOf(value.toString())));
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:23,代码来源:RequiredAnnotationBeanPostProcessor.java

示例14: postProcessBeanFactory

import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; //导入方法依赖的package包/类
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory)
        throws BeansException {

    // get names of all BeanDefinition
    String[] beanDefinitionNames = beanFactory.getBeanDefinitionNames();

    for (String name: beanDefinitionNames) {

        // get BeanDefinition by name
        BeanDefinition beanDefinition = beanFactory.getBeanDefinition(name);

        /* получаем имя класса создавамого бина, чтобы проверить , 
         * содержит ли он аннотацию UnsupportedCameraRoll 
         */ 
        String className = beanDefinition.getBeanClassName();

        try {
            // get class by name
            Class<?> beanClass = Class.forName(className);

            /* пытаемся получить объект аннотации и ее значение,
             * если  класс не содержит данную аннотацию, то  метод вернет null
             */
            UnproducableCameraRoll annotation = beanClass.getAnnotation(UnproducableCameraRoll.class);

            // проверяем, содержал ли класс эту аннотацию
            if (annotation != null) {
                // получаем значение указанное в параметрах аннотации(класс пленки, которую необходимо использовать)
                Class usingCameraRollName =annotation.usingCameraRollClass();
                // меняем класс будущего бина!
                beanDefinition.setBeanClassName(usingCameraRollName.getName());	
            }
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }
}
 
开发者ID:biblelamp,项目名称:JavaEE,代码行数:38,代码来源:UnproducableCameraRollBeanFactoryPostProcessor.java

示例15: postProcessBeanFactory

import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; //导入方法依赖的package包/类
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory)
        throws BeansException {

    // get names of all BeanDefinition defined of use
    String[] beanDefinitionNames = beanFactory.getBeanDefinitionNames();

    for (String name: beanDefinitionNames) {
        // get BeanDefinition by name
        BeanDefinition beanDefinition = beanFactory.getBeanDefinition(name);
        System.out.println(beanDefinition.toString());
    }
}
 
开发者ID:biblelamp,项目名称:JavaEE,代码行数:13,代码来源:TestBFPP.java


注:本文中的org.springframework.beans.factory.config.ConfigurableListableBeanFactory.getBeanDefinition方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。