本文整理汇总了Java中org.springframework.beans.factory.support.GenericBeanDefinition.setBeanClassName方法的典型用法代码示例。如果您正苦于以下问题:Java GenericBeanDefinition.setBeanClassName方法的具体用法?Java GenericBeanDefinition.setBeanClassName怎么用?Java GenericBeanDefinition.setBeanClassName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.beans.factory.support.GenericBeanDefinition
的用法示例。
在下文中一共展示了GenericBeanDefinition.setBeanClassName方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createBeanDefinition
import org.springframework.beans.factory.support.GenericBeanDefinition; //导入方法依赖的package包/类
private static BeanDefinition createBeanDefinition(ComponentDefinition componentDefinition) {
GenericBeanDefinition beanDefinition = new GenericBeanDefinition();
beanDefinition.setBeanClassName(componentDefinition.getComponentClass());
beanDefinition.setScope(getScope(componentDefinition.getScope()));
beanDefinition.setAutowireCandidate(true);
beanDefinition.setAutowireMode(AutowireCapableBeanFactory.AUTOWIRE_BY_NAME);
beanDefinition.setDependsOn(componentDefinition.getDependsOn());
beanDefinition.setLazyInit(componentDefinition.isLazyInit());
ConstructorArgumentValues constructorArgumentValues = new ConstructorArgumentValues();
for (Object value : componentDefinition.getConstructorArguments()) {
constructorArgumentValues.addIndexedArgumentValue(constructorArgumentValues.getArgumentCount(), value);
}
beanDefinition.setConstructorArgumentValues(constructorArgumentValues);
MutablePropertyValues propertyValues = new MutablePropertyValues();
for (PropertyValue propertyValue : componentDefinition.getPropertyValues()) {
propertyValues.add(propertyValue.getName(), propertyValue.getValue());
}
beanDefinition.setPropertyValues(propertyValues);
return beanDefinition;
}
示例2: toInternal
import org.springframework.beans.factory.support.GenericBeanDefinition; //导入方法依赖的package包/类
/**
* Convert from a DTO to an internal Spring bean definition.
*
* @param beanDefinitionDto The DTO object.
* @return Returns a Spring bean definition.
*/
public BeanDefinition toInternal(BeanDefinitionInfo beanDefinitionInfo) {
if (beanDefinitionInfo instanceof GenericBeanDefinitionInfo) {
GenericBeanDefinitionInfo genericInfo = (GenericBeanDefinitionInfo) beanDefinitionInfo;
GenericBeanDefinition def = new GenericBeanDefinition();
def.setBeanClassName(genericInfo.getClassName());
if (genericInfo.getPropertyValues() != null) {
MutablePropertyValues propertyValues = new MutablePropertyValues();
for (Entry<String, BeanMetadataElementInfo> entry : genericInfo.getPropertyValues().entrySet()) {
BeanMetadataElementInfo info = entry.getValue();
propertyValues.add(entry.getKey(), toInternal(info));
}
def.setPropertyValues(propertyValues);
}
return def;
} else if (beanDefinitionInfo instanceof ObjectBeanDefinitionInfo) {
ObjectBeanDefinitionInfo objectInfo = (ObjectBeanDefinitionInfo) beanDefinitionInfo;
return createBeanDefinitionByIntrospection(objectInfo.getObject());
} else {
throw new IllegalArgumentException("Conversion to internal of " + beanDefinitionInfo.getClass().getName()
+ " not implemented");
}
}
示例3: createBeans
import org.springframework.beans.factory.support.GenericBeanDefinition; //导入方法依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
public List<BeanDefinitionHolder> createBeans(Map<String, Object> parameters) throws RuntimeConfigException {
GenericBeanDefinition def = new GenericBeanDefinition();
def.setBeanClassName(className);
MutablePropertyValues propertyValues = new MutablePropertyValues();
List<NamedObject> namedObjects = new ArrayList<NamedObject>();
if (checkCollection(BEAN_REFS, NamedObject.class, parameters) != Priority.NONE) {
namedObjects.addAll((Collection) parameters.get(BEAN_REFS));
}
for (String name : parameters.keySet()) {
if (!ignoredParams.contains(name)) {
propertyValues.addPropertyValue(name, beanDefinitionDtoConverterService
.createBeanMetadataElementByIntrospection(parameters.get(name), namedObjects));
}
}
def.setPropertyValues(propertyValues);
BeanDefinitionHolder holder = new BeanDefinitionHolder(def, (String) parameters.get(BEAN_NAME));
List<BeanDefinitionHolder> holders = new ArrayList<BeanDefinitionHolder>();
holders.add(holder);
return holders;
}
示例4: registryMangoDao
import org.springframework.beans.factory.support.GenericBeanDefinition; //导入方法依赖的package包/类
/**
* 向spring中注入dao代理
* @param beanFactory
*/
private void registryMangoDao(DefaultListableBeanFactory beanFactory){
for (Class<?> daoClass : findMangoDaoClasses(config.getScanPackage())) {
GenericBeanDefinition bf = new GenericBeanDefinition();
bf.setBeanClassName(daoClass.getName());
MutablePropertyValues pvs = bf.getPropertyValues();
pvs.addPropertyValue("daoClass", daoClass);
bf.setBeanClass(factoryBeanClass);
bf.setPropertyValues(pvs);
bf.setLazyInit(false);
beanFactory.registerBeanDefinition(daoClass.getName(), bf);
}
}
示例5: registerBeanDefinitions
import org.springframework.beans.factory.support.GenericBeanDefinition; //导入方法依赖的package包/类
@Override
public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {
GenericBeanDefinition beanDefinition = new GenericBeanDefinition();
beanDefinition.setBeanClassName(String.class.getName());
registry.registerBeanDefinition("registrarImportedBean", beanDefinition);
GenericBeanDefinition beanDefinition2 = new GenericBeanDefinition();
beanDefinition2.setBeanClass(OtherImportedConfig.class);
registry.registerBeanDefinition("registrarImportedConfig", beanDefinition2);
Assert.state(!called, "ImportedRegistrar called twice");
called = true;
}
示例6: registerBean
import org.springframework.beans.factory.support.GenericBeanDefinition; //导入方法依赖的package包/类
/**
* Add's a new bean to Spring's context
*
* @param name
*/
public void registerBean(final String name) {
if (registeredbeans.containsKey(name)) {
return;
}
GenericBeanDefinition beanDefinition = new GenericBeanDefinition();
beanDefinition.setBeanClassName(name);
beanDefinition.setAutowireCandidate(true);
AutowireCapableBeanFactory factory = applicationContext.getAutowireCapableBeanFactory();
BeanDefinitionRegistry registry = (BeanDefinitionRegistry) factory;
registry.registerBeanDefinition(name, beanDefinition);
factory.autowireBeanProperties(this,
AutowireCapableBeanFactory.AUTOWIRE_BY_NAME, false);
registeredbeans.put(name, Boolean.TRUE);
}
示例7: createAndRegisterScriptBeanFactoryBean
import org.springframework.beans.factory.support.GenericBeanDefinition; //导入方法依赖的package包/类
private void createAndRegisterScriptBeanFactoryBean(BeanDefinitionRegistry registry,
String beanName, String location) {
GenericBeanDefinition scriptBd = new GenericBeanDefinition();
scriptBd.setBeanClassName(DEFAULT_SCRIPT_FACTORY_CLASS_NAME);
ConstructorArgumentValues cav = scriptBd.getConstructorArgumentValues();
int constructorArgNum = 0;
cav.addIndexedArgumentValue(constructorArgNum++, location);
scriptBd.getConstructorArgumentValues().addArgumentValues(cav);
registry.registerBeanDefinition(DEFAULT_SCRIPT_FACTORY_NAME + beanName,scriptBd);
}
示例8: createScriptFactoryBeanDefinition
import org.springframework.beans.factory.support.GenericBeanDefinition; //导入方法依赖的package包/类
/**
* Create a ScriptFactory bean definition based on the given script definition,
* extracting only the definition data that is relevant for the ScriptFactory
* (that is, only bean class and constructor arguments).
* @param bd the full script bean definition
* @return the extracted ScriptFactory bean definition
* @see org.springframework.scripting.ScriptFactory
*/
protected BeanDefinition createScriptFactoryBeanDefinition(BeanDefinition bd) {
GenericBeanDefinition scriptBd = new GenericBeanDefinition();
scriptBd.setBeanClassName(bd.getBeanClassName());
scriptBd.getConstructorArgumentValues().addArgumentValues(bd.getConstructorArgumentValues());
return scriptBd;
}
示例9: createScriptFactoryBeanDefinition
import org.springframework.beans.factory.support.GenericBeanDefinition; //导入方法依赖的package包/类
/**
* Create a ScriptFactory bean definition based on the given script
* definition, extracting only the definition data that is relevant for the
* ScriptFactory (that is, only bean class and constructor arguments).
*
* @param bd
* the full script bean definition
* @return the extracted ScriptFactory bean definition
* @see org.springframework.scripting.ScriptFactory
*/
protected BeanDefinition createScriptFactoryBeanDefinition(BeanDefinition bd) {
GenericBeanDefinition scriptBd = new GenericBeanDefinition();
scriptBd.setBeanClassName(bd.getBeanClassName());
scriptBd.getConstructorArgumentValues().addArgumentValues(bd.getConstructorArgumentValues());
return scriptBd;
}