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


Java BeanDefinition.setBeanClassName方法代码示例

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


在下文中一共展示了BeanDefinition.setBeanClassName方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: registerOrEscalateApcAsRequired

import org.springframework.beans.factory.config.BeanDefinition; //导入方法依赖的package包/类
private static BeanDefinition registerOrEscalateApcAsRequired(Class<?> cls, BeanDefinitionRegistry registry, Object source) {
	Assert.notNull(registry, "BeanDefinitionRegistry must not be null");
	if (registry.containsBeanDefinition(AUTO_PROXY_CREATOR_BEAN_NAME)) {
		BeanDefinition apcDefinition = registry.getBeanDefinition(AUTO_PROXY_CREATOR_BEAN_NAME);
		if (!cls.getName().equals(apcDefinition.getBeanClassName())) {
			int currentPriority = findPriorityForClass(apcDefinition.getBeanClassName());
			int requiredPriority = findPriorityForClass(cls);
			if (currentPriority < requiredPriority) {
				apcDefinition.setBeanClassName(cls.getName());
			}
		}
		return null;
	}
	RootBeanDefinition beanDefinition = new RootBeanDefinition(cls);
	beanDefinition.setSource(source);
	beanDefinition.getPropertyValues().add("order", Ordered.HIGHEST_PRECEDENCE);
	beanDefinition.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
	registry.registerBeanDefinition(AUTO_PROXY_CREATOR_BEAN_NAME, beanDefinition);
	return beanDefinition;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:21,代码来源:AopConfigUtils.java

示例3: postProcessBeanFactory

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

示例4: 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

示例5: postProcessBeanDefinitionRegistry

import org.springframework.beans.factory.config.BeanDefinition; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void postProcessBeanDefinitionRegistry(final BeanDefinitionRegistry registry) throws BeansException
{
    final BeanDefinition renditionServiceDefinition = registry.getBeanDefinition("renditionService");
    if (renditionServiceDefinition != null
            && renditionServiceDefinition.getBeanClassName().equals(RenditionServiceImpl.class.getName()))
    {
        renditionServiceDefinition.setBeanClassName(ArchiveSupportingRenditionServiceImpl.class.getName());
        renditionServiceDefinition.getPropertyValues().add("nodeArchiveService", new RuntimeBeanReference("nodeArchiveService"));
    }
}
 
开发者ID:AFaust,项目名称:alfresco-better-trashmanagement,代码行数:15,代码来源:RenditionServiceBeanDefinitionPostProcessor.java


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