本文整理匯總了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);
}
示例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;
}
示例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());
}
}
示例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();
}
}
}
示例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