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


Java BeanDefinition.getBeanClassName方法代码示例

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


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

示例1: setConfigBeanFactoryMethod

import org.springframework.beans.factory.config.BeanDefinition; //导入方法依赖的package包/类
/**
 * 修改配置Bean定义,使用静态方法{@link ConfigBeanFactory#FACTORY_METHOD}来实例化。
 *
 * @param registry
 * @param beanName
 * @param beanDefinition
 * @param propertyName
 * @param converterType
 */
public static void setConfigBeanFactoryMethod(BeanDefinitionRegistry registry,
                                              String beanName, BeanDefinition beanDefinition,
                                              String propertyName, Class<?> converterType) {

    // 注册ConfigBeanPropertyResolver
    registerConfigBeanPropertyResolver(registry);

    // 注册ConfigBeanConversionService
    registerConfigBeanConversionService(registry);

    String beanClassName = beanDefinition.getBeanClassName();

    beanDefinition.setBeanClassName(ConfigBeanFactory.class.getName());
    beanDefinition.setFactoryMethodName(ConfigBeanFactory.FACTORY_METHOD);
    ConstructorArgumentValues constructorArgumentValues = new ConstructorArgumentValues();
    constructorArgumentValues.addGenericArgumentValue(propertyName, String.class.getName());
    constructorArgumentValues.addGenericArgumentValue(beanClassName, Class.class.getName());
    constructorArgumentValues.addGenericArgumentValue(converterType);
    constructorArgumentValues.addGenericArgumentValue(new RuntimeBeanReference(CONFIG_BEAN_PROPERTY_RESOLVER_BEAN_NAME));
    constructorArgumentValues.addGenericArgumentValue(new RuntimeBeanReference(CONFIG_BEAN_CONVERSION_SERVICE_BEAN_NAME));
    beanDefinition.getConstructorArgumentValues().addArgumentValues(constructorArgumentValues);
}
 
开发者ID:zouzhirong,项目名称:configx,代码行数:32,代码来源:ConfigBeanConfigUtils.java

示例2: registerFactoryMethodForConfigBean

import org.springframework.beans.factory.config.BeanDefinition; //导入方法依赖的package包/类
/**
 * 为@ConfigBean的bean注册它的Factory Method,通过静态Factory Method来创建@ConfigBean实例
 *
 * @param registry
 * @param beanName
 * @param beanDefinition
 */
private void registerFactoryMethodForConfigBean(BeanDefinitionRegistry registry, String beanName, BeanDefinition beanDefinition) {
    String beanClassName = beanDefinition.getBeanClassName();
    if (beanClassName == null) { // 通过注解@Bean声明的bean,beanClassName=null
        return;
    }

    Class<?> beanClass = ClassUtils.resolveClassName(beanClassName, beanFactory.getBeanClassLoader());
    ConfigBean config = AnnotationUtils.findAnnotation(beanClass, ConfigBean.class);
    if (config == null) {
        return;
    }

    // 为配置bean设置factory method
    String propertyName = config.value();
    ConfigBeanConfigUtils.setConfigBeanFactoryMethod(registry,
            beanName, beanDefinition, propertyName, config.converter());
}
 
开发者ID:zouzhirong,项目名称:configx,代码行数:25,代码来源:ConfigBeanPostProcessor.java

示例3: buildDefaultBeanName

import org.springframework.beans.factory.config.BeanDefinition; //导入方法依赖的package包/类
@Override
protected String buildDefaultBeanName(BeanDefinition definition) {
    if(this.packageDepth < 1){
        return super.buildDefaultBeanName(definition);
    }

    String fullName = definition.getBeanClassName(); //e.g.: com.mobanker.tkj.api.action.UserAction
    char delimiter = dotReplacement > 0 ? dotReplacement : DEFAULT_DOT_REPLACEMENT;
    String[] names = fullName.split("\\.");
    StringBuilder beanName = new StringBuilder("");

    //add package name
    if(names.length > 1){
        for(int i = 0; i < this.packageDepth; i++){
            String name = names[names.length - 2 - i];
            beanName.insert(0, delimiter);
            beanName.insert(0, name);
        }
    }

    //add Class name
    beanName.append(names[names.length - 1]);

    return beanName.toString();
}
 
开发者ID:zjtx2017,项目名称:ocmall,代码行数:26,代码来源:FullPackageBeanNameGenerator.java

示例4: buildDefaultBeanName

import org.springframework.beans.factory.config.BeanDefinition; //导入方法依赖的package包/类
@Override
protected String buildDefaultBeanName(BeanDefinition definition) {
	if(this.packageDepth < 1){
		return super.buildDefaultBeanName(definition);
	}
	
	String fullName = definition.getBeanClassName(); //e.g.: com.tasfe.tkj.api.action.UserAction
	char delimiter = dotReplacement > 0 ? dotReplacement : DEFAULT_DOT_REPLACEMENT;
	String[] names = fullName.split("\\.");
	StringBuilder beanName = new StringBuilder("");

	//add package name
	if(names.length > 1){
		for(int i = 0; i < this.packageDepth; i++){
			String name = names[names.length - 2 - i];
			beanName.insert(0, delimiter);
			beanName.insert(0, name);
		}
	}
	
	//add Class name
	beanName.append(names[names.length - 1]);
	
	return beanName.toString();
}
 
开发者ID:geeker-lait,项目名称:tasfe-framework,代码行数:26,代码来源:FullPackageBeanNameGenerator.java

示例5: buildDefaultBeanName

import org.springframework.beans.factory.config.BeanDefinition; //导入方法依赖的package包/类
@Override
protected String buildDefaultBeanName(BeanDefinition definition) {
    if (this.packageDepth < 1) {
        return super.buildDefaultBeanName(definition);
    }

    String fullName = definition.getBeanClassName(); //e.g.: com.tasfe.tkj.api.action.UserAction
    char delimiter = dotReplacement > 0 ? dotReplacement : DEFAULT_DOT_REPLACEMENT;
    String[] names = fullName.split("\\.");
    StringBuilder beanName = new StringBuilder("");

    //add package name
    if (names.length > 1) {
        for (int i = 0; i < this.packageDepth; i++) {
            String name = names[names.length - 2 - i];
            beanName.insert(0, delimiter);
            beanName.insert(0, name);
        }
    }

    //add Class name
    beanName.append(names[names.length - 1]);

    return beanName.toString();
}
 
开发者ID:geeker-lait,项目名称:tasfe-framework,代码行数:26,代码来源:FullPackageBeanNameGenerator.java

示例6: parse

import org.springframework.beans.factory.config.BeanDefinition; //导入方法依赖的package包/类
public void parse(Set<BeanDefinitionHolder> configCandidates) {
	for (BeanDefinitionHolder holder : configCandidates) {
		BeanDefinition bd = holder.getBeanDefinition();
		try {
			if (bd instanceof AbstractBeanDefinition && ((AbstractBeanDefinition) bd).hasBeanClass()) {
				parse(((AbstractBeanDefinition) bd).getBeanClass(), holder.getBeanName());
			}
			else {
				parse(bd.getBeanClassName(), holder.getBeanName());
			}
		}
		catch (IOException ex) {
			throw new BeanDefinitionStoreException("Failed to load bean class: " + bd.getBeanClassName(), ex);
		}
	}
	processDeferredImportSelectors();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:18,代码来源:ConfigurationClassParser.java

示例7: checkCandidate

import org.springframework.beans.factory.config.BeanDefinition; //导入方法依赖的package包/类
/**
 * Check the given candidate's bean name, determining whether the corresponding
 * bean definition needs to be registered or conflicts with an existing definition.
 * @param beanName the suggested name for the bean
 * @param beanDefinition the corresponding bean definition
 * @return {@code true} if the bean can be registered as-is;
 * {@code false} if it should be skipped because there is an
 * existing, compatible bean definition for the specified name
 * @throws ConflictingBeanDefinitionException if an existing, incompatible
 * bean definition has been found for the specified name
 */
protected boolean checkCandidate(String beanName, BeanDefinition beanDefinition) throws IllegalStateException {
	if (!this.registry.containsBeanDefinition(beanName)) {
		return true;
	}
	BeanDefinition existingDef = this.registry.getBeanDefinition(beanName);
	BeanDefinition originatingDef = existingDef.getOriginatingBeanDefinition();
	if (originatingDef != null) {
		existingDef = originatingDef;
	}
	if (isCompatible(beanDefinition, existingDef)) {
		return false;
	}
	throw new ConflictingBeanDefinitionException("Annotation-specified bean name '" + beanName +
			"' for bean class [" + beanDefinition.getBeanClassName() + "] conflicts with existing, " +
			"non-compatible bean definition of same name and class [" + existingDef.getBeanClassName() + "]");
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:28,代码来源:ClassPathBeanDefinitionScanner.java

示例8: getBeanFactoryClassName

import org.springframework.beans.factory.config.BeanDefinition; //导入方法依赖的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

示例9: getServiceDependencies

import org.springframework.beans.factory.config.BeanDefinition; //导入方法依赖的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: resolveScopeMetadata

import org.springframework.beans.factory.config.BeanDefinition; //导入方法依赖的package包/类
@Override
public ScopeMetadata resolveScopeMetadata(BeanDefinition definition) {
	ScopeMetadata metadata = new ScopeMetadata();
	metadata.setScopeName(BeanDefinition.SCOPE_PROTOTYPE);
	if (definition instanceof AnnotatedBeanDefinition) {
		AnnotatedBeanDefinition annDef = (AnnotatedBeanDefinition) definition;
		Set<String> annTypes = annDef.getMetadata().getAnnotationTypes();
		String found = null;
		for (String annType : annTypes) {
			Set<String> metaAnns = annDef.getMetadata().getMetaAnnotationTypes(annType);
			if (metaAnns.contains("javax.inject.Scope")) {
				if (found != null) {
					throw new IllegalStateException("Found ambiguous scope annotations on bean class [" +
							definition.getBeanClassName() + "]: " + found + ", " + annType);
				}
				found = annType;
				String scopeName = resolveScopeName(annType);
				if (scopeName == null) {
					throw new IllegalStateException(
							"Unsupported scope annotation - not mapped onto Spring scope name: " + annType);
				}
				metadata.setScopeName(scopeName);
			}
		}
	}
	return metadata;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:28,代码来源:Jsr330ScopeMetadataResolver.java

示例11: generateBeanName

import org.springframework.beans.factory.config.BeanDefinition; //导入方法依赖的package包/类
/**
 * Generate a bean name for the given bean definition, unique within the
 * given bean factory.
 * @param definition the bean definition to generate a bean name for
 * @param registry the bean factory that the definition is going to be
 * registered with (to check for existing bean names)
 * @param isInnerBean whether the given bean definition will be registered
 * as inner bean or as top-level bean (allowing for special name generation
 * for inner beans versus top-level beans)
 * @return the generated bean name
 * @throws BeanDefinitionStoreException if no unique name can be generated
 * for the given bean definition
 */
public static String generateBeanName(
		BeanDefinition definition, BeanDefinitionRegistry registry, boolean isInnerBean)
		throws BeanDefinitionStoreException {

	String generatedBeanName = definition.getBeanClassName();
	if (generatedBeanName == null) {
		if (definition.getParentName() != null) {
			generatedBeanName = definition.getParentName() + "$child";
		}
		else if (definition.getFactoryBeanName() != null) {
			generatedBeanName = definition.getFactoryBeanName() + "$created";
		}
	}
	if (!StringUtils.hasText(generatedBeanName)) {
		throw new BeanDefinitionStoreException("Unnamed bean definition specifies neither " +
				"'class' nor 'parent' nor 'factory-bean' - can't generate bean name");
	}

	String id = generatedBeanName;
	if (isInnerBean) {
		// Inner bean: generate identity hashcode suffix.
		id = generatedBeanName + GENERATED_BEAN_NAME_SEPARATOR + ObjectUtils.getIdentityHexString(definition);
	}
	else {
		// Top-level bean: use plain class name.
		// Increase counter until the id is unique.
		int counter = -1;
		while (counter == -1 || registry.containsBeanDefinition(id)) {
			counter++;
			id = generatedBeanName + GENERATED_BEAN_NAME_SEPARATOR + counter;
		}
	}
	return id;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:48,代码来源:BeanDefinitionReaderUtils.java

示例12: postProcessBeanFactory

import org.springframework.beans.factory.config.BeanDefinition; //导入方法依赖的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

示例13: resolveBeanClassname

import org.springframework.beans.factory.config.BeanDefinition; //导入方法依赖的package包/类
/**
 *  Try getting the beanClassName from the definition and if that fails try to get it from 
 *  the parent (and even parent BeanFactory if we have to).
 *  
 *  @param definition 
 *  @param registry
 *  @return class name or null if not found
 */
private String resolveBeanClassname(BeanDefinition definition, BeanDefinitionRegistry registry) 
{
    String beanClassName = definition.getBeanClassName();    
    if (!StringUtils.hasText(beanClassName)) 
    {
        while (definition instanceof ChildBeanDefinition )
        {
            String parentName = ((ChildBeanDefinition)definition).getParentName();                    
            BeanDefinition parentDefinition = findParentDefinition(parentName, registry);
            if (parentDefinition == null)
            {
                if (log.isDebugEnabled()) 
                {
                    log.debug("No parent bean named '" + parentName + "' could be found in the " + 
                              "hierarchy of BeanFactorys. Check you've defined a bean called '" + parentName + "'");
                }
                break;
            }
            beanClassName = parentDefinition.getBeanClassName();
            if (StringUtils.hasText(beanClassName ))
            {
                // found the class name we were looking for
                break;
            }
            definition = parentDefinition;
        }
    }
   
    return beanClassName;
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:39,代码来源:DwrNamespaceHandler.java

示例14: generateBeanName

import org.springframework.beans.factory.config.BeanDefinition; //导入方法依赖的package包/类
@Override
public String generateBeanName(BeanDefinition definition, BeanDefinitionRegistry registry) {
    return definition.getBeanClassName();
}
 
开发者ID:ychaoyang,项目名称:autotest,代码行数:5,代码来源:MultiBeanNameGenerator.java

示例15: buildDefaultBeanName

import org.springframework.beans.factory.config.BeanDefinition; //导入方法依赖的package包/类
@Override
protected String buildDefaultBeanName(BeanDefinition definition) {
	return definition.getBeanClassName();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:5,代码来源:ConfigurationClassPostProcessor.java


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