本文整理汇总了Java中org.springframework.beans.factory.support.BeanDefinitionBuilder.genericBeanDefinition方法的典型用法代码示例。如果您正苦于以下问题:Java BeanDefinitionBuilder.genericBeanDefinition方法的具体用法?Java BeanDefinitionBuilder.genericBeanDefinition怎么用?Java BeanDefinitionBuilder.genericBeanDefinition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.beans.factory.support.BeanDefinitionBuilder
的用法示例。
在下文中一共展示了BeanDefinitionBuilder.genericBeanDefinition方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: registerBeanDefinitions
import org.springframework.beans.factory.support.BeanDefinitionBuilder; //导入方法依赖的package包/类
@Override
public void registerBeanDefinitions(AnnotationMetadata metadata, BeanDefinitionRegistry registry) {
AnnotationAttributes enableMenu = AnnotationAttributes.fromMap(metadata.getAnnotationAttributes(EnableMenu.class
.getName(),
false));
if (enableMenu != null) {
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(DefaultMenuPlugin.class);
AbstractBeanDefinition beanDefinition = builder.getBeanDefinition();
MutablePropertyValues mutablePropertyValues = new MutablePropertyValues();
mutablePropertyValues.add("extensionPointId", enableMenu.getString("extensionPointId"));
mutablePropertyValues.add("pluginId", enableMenu.getString("pluginId"));
mutablePropertyValues.add("menu", toMenu(enableMenu.getAnnotationArray("menu")));
beanDefinition.setPropertyValues(mutablePropertyValues);
registry.registerBeanDefinition("menuPlugin:" + enableMenu.getString("pluginId"), beanDefinition);
}
}
示例2: instantiateComponent
import org.springframework.beans.factory.support.BeanDefinitionBuilder; //导入方法依赖的package包/类
public static <T> T instantiateComponent(DefaultListableBeanFactory beanFactory, Class<T> cls, Annotation annotation) {
T extractor;
try {
extractor = beanFactory.getBean(cls);
} catch (BeansException e) {
try {
extractor = (T) beanFactory.getBean(cls.getName());
} catch (BeansException e1) {
BeanDefinitionBuilder beanDefinition = BeanDefinitionBuilder.genericBeanDefinition(cls.getName());
beanFactory.registerBeanDefinition(cls.getName(), beanDefinition.getBeanDefinition());
extractor = (T) beanFactory.getBean(cls.getName());
}
}
return extractor;
}
示例3: registerBean
import org.springframework.beans.factory.support.BeanDefinitionBuilder; //导入方法依赖的package包/类
/**
* 动态注册一个Bean动Spring容器中
*
* @param beanName 名称
* @param beanClazz 定义bean
*/
public void registerBean(String beanName, Class beanClazz, Map<String, Object> propertys) {
Assert.notNull(beanName);
Assert.notNull(beanClazz);
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(beanClazz);
if (propertys != null) {
propertys.forEach((k, v) -> builder.addPropertyValue(k, v));
}
builder.setScope(BeanDefinition.SCOPE_SINGLETON);
registerBean(beanName, builder.getBeanDefinition());
}
示例4: registerBeanDefinitions
import org.springframework.beans.factory.support.BeanDefinitionBuilder; //导入方法依赖的package包/类
@Override
public void registerBeanDefinitions(AnnotationMetadata metadata, BeanDefinitionRegistry registry) {
MultiValueMap<String, Object> attributes = metadata.getAllAnnotationAttributes(EnableMessageSource.class.getName(), false);
boolean fallbackToSystemLocale = (boolean) (attributes != null ? attributes.getFirst("fallbackToSystemLocale") : false);
String[] basenames = (String[]) (attributes != null ? attributes.getFirst("basenames") : null);
BeanDefinitionBuilder bean = BeanDefinitionBuilder.genericBeanDefinition(ConfigMessageSourceConfigurer.class);
bean.addPropertyValue("fallbackToSystemLocale", fallbackToSystemLocale);
if (basenames != null && basenames.length > 0) {
bean.addPropertyValue("basenames", basenames);
}
registry.registerBeanDefinition(ConfigMessageSourceConfigurer.class.getName(), bean.getBeanDefinition());
}
示例5: registerConfigBeanPropertyResolver
import org.springframework.beans.factory.support.BeanDefinitionBuilder; //导入方法依赖的package包/类
/**
* 注册ConfigBeanPropertyResolver
*
* @param registry
*/
public static void registerConfigBeanPropertyResolver(BeanDefinitionRegistry registry) {
if (!registry.containsBeanDefinition(CONFIG_BEAN_PROPERTY_RESOLVER_BEAN_NAME)) {
BeanDefinitionBuilder bean = BeanDefinitionBuilder.genericBeanDefinition(ConfigPropertyResolver.class);
registry.registerBeanDefinition(CONFIG_BEAN_PROPERTY_RESOLVER_BEAN_NAME, bean.getBeanDefinition());
}
}
示例6: runnableReference
import org.springframework.beans.factory.support.BeanDefinitionBuilder; //导入方法依赖的package包/类
private RuntimeBeanReference runnableReference(String ref, String method, Element taskElement, ParserContext parserContext) {
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(
"org.springframework.scheduling.support.ScheduledMethodRunnable");
builder.addConstructorArgReference(ref);
builder.addConstructorArgValue(method);
return beanReference(taskElement, parserContext, builder);
}
示例7: triggerTaskReference
import org.springframework.beans.factory.support.BeanDefinitionBuilder; //导入方法依赖的package包/类
private RuntimeBeanReference triggerTaskReference(String runnableBeanName,
String triggerBeanName, Element taskElement, ParserContext parserContext) {
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(
"org.springframework.scheduling.config.TriggerTask");
builder.addConstructorArgReference(runnableBeanName);
builder.addConstructorArgReference(triggerBeanName);
return beanReference(taskElement, parserContext, builder);
}
示例8: registerConverters
import org.springframework.beans.factory.support.BeanDefinitionBuilder; //导入方法依赖的package包/类
private void registerConverters(BeanDefinitionRegistry registry, List<Class<?>> types) {
// Register ConfigConverter by CustomConverterConfigurer
String name = ConfigBeanConverterConfigurer.class.getName() + "." + EnableConfigService.class.getSimpleName();
// converters
List<ConfigBeanConverter> converters = instantiateConverters(types);
BeanDefinitionBuilder builder = BeanDefinitionBuilder
.genericBeanDefinition(ConfigBeanConverterConfigurer.class);
builder.addPropertyValue("converters", converters);
AbstractBeanDefinition beanDefinition = builder.getBeanDefinition();
registry.registerBeanDefinition(name, beanDefinition);
}
示例9: createScannerConfigurerBean
import org.springframework.beans.factory.support.BeanDefinitionBuilder; //导入方法依赖的package包/类
protected final AbstractBeanDefinition createScannerConfigurerBean(String sqlSessionFactoryName, String basepackage,
Mapper mappers, Order order,Style style) {
BeanDefinitionBuilder bdb = BeanDefinitionBuilder.genericBeanDefinition(MapperScannerConfigurer.class);
Properties properties = new Properties();
if(style!=null){
properties.setProperty("style", style.name());
}
properties.setProperty("notEmpty", "true");
properties.setProperty("ORDER", order != null ? order.order : Order.BEFORE.order);
properties.setProperty("mappers", mappers != null ? mappers.mapper : Mapper.DEFAULT.mapper);
bdb.addPropertyValue("properties", properties);
bdb.addPropertyValue("sqlSessionFactoryBeanName", sqlSessionFactoryName);
bdb.addPropertyValue("basePackage", basepackage);
return bdb.getRawBeanDefinition();
}
示例10: createBeanDefinitionBuilder
import org.springframework.beans.factory.support.BeanDefinitionBuilder; //导入方法依赖的package包/类
public BeanDefinitionBuilder createBeanDefinitionBuilder(Element element, ParserContext parserContext, Class<?> cls) {
BeanDefinitionBuilder builder
= BeanDefinitionBuilder.genericBeanDefinition();
builder.getRawBeanDefinition().setBeanClass(cls);
builder.getRawBeanDefinition()
.setSource(parserContext.extractSource(element));
if (parserContext.isNested()) {
builder.setScope(parserContext.getContainingBeanDefinition()
.getScope());
}
if (parserContext.isDefaultLazyInit()) {
builder.setLazyInit(true);
}
return builder;
}
示例11: registerLepService
import org.springframework.beans.factory.support.BeanDefinitionBuilder; //导入方法依赖的package包/类
private void registerLepService(BeanDefinitionRegistry registry,
AnnotationMetadata annotationMetadata,
Map<String, Object> attributes) {
// has a default, won't be null
boolean primary = (Boolean) attributes.get("primary");
String className = annotationMetadata.getClassName();
BeanDefinitionBuilder definition = BeanDefinitionBuilder
.genericBeanDefinition(LepServiceFactoryBean.class);
definition.addPropertyValue("type", className);
definition.addPropertyValue("annotationMetadata", annotationMetadata);
definition.setAutowireMode(AbstractBeanDefinition.AUTOWIRE_BY_TYPE);
AbstractBeanDefinition beanDefinition = definition.getBeanDefinition();
beanDefinition.setPrimary(primary);
String name = getBeanName(annotationMetadata, attributes);
String alias = name + LepService.class.getSimpleName();
String qualifier = getQualifier(attributes);
if (StringUtils.hasText(qualifier)) {
alias = qualifier;
}
BeanDefinitionHolder holder = new BeanDefinitionHolder(beanDefinition, name,
new String[] {alias});
BeanDefinitionReaderUtils.registerBeanDefinition(holder, registry);
}
示例12: registerListener
import org.springframework.beans.factory.support.BeanDefinitionBuilder; //导入方法依赖的package包/类
private void registerListener(String registerBeanName,Destination destination,Object bean,Method method,int retryTimes,boolean isRetry){
DefaultListableBeanFactory beanFactory = (DefaultListableBeanFactory)this.applicationContext.getAutowireCapableBeanFactory();
BeanDefinitionBuilder beanDefinitionBuilder = BeanDefinitionBuilder.genericBeanDefinition(DefaultMessageListenerContainer.class);
beanDefinitionBuilder.addPropertyValue("connectionFactory",this.connectionFactory);
beanDefinitionBuilder.addPropertyValue("destination", destination);
beanDefinitionBuilder.addPropertyValue("messageListener",new SessionAwareMessageListenerImpl(bean, method,retryTimes,isRetry,this.jmsTemplate));
beanDefinitionBuilder.addPropertyValue("sessionAcknowledgeMode",4);
beanFactory.registerBeanDefinition(registerBeanName, beanDefinitionBuilder.getBeanDefinition());
}
示例13: cronTaskReference
import org.springframework.beans.factory.support.BeanDefinitionBuilder; //导入方法依赖的package包/类
private RuntimeBeanReference cronTaskReference(String runnableBeanName,
String cronExpression, Element taskElement, ParserContext parserContext) {
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(
"org.springframework.scheduling.config.CronTask");
builder.addConstructorArgReference(runnableBeanName);
builder.addConstructorArgValue(cronExpression);
return beanReference(taskElement, parserContext, builder);
}
示例14: registerBeanDefinitions
import org.springframework.beans.factory.support.BeanDefinitionBuilder; //导入方法依赖的package包/类
@Override
public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {
BeanDefinitionBuilder bean = BeanDefinitionBuilder.genericBeanDefinition(ConfigJmxBeanDefinitionRegistryPostProcessor.class);
registry.registerBeanDefinition(ConfigJmxBeanDefinitionRegistryPostProcessor.class.getName(), bean.getBeanDefinition());
}
示例15: registerBeanDefinitions
import org.springframework.beans.factory.support.BeanDefinitionBuilder; //导入方法依赖的package包/类
@Override
public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {
BeanDefinitionBuilder bean = BeanDefinitionBuilder.genericBeanDefinition(ConfigBeanDefinitionRegistryPostProcessor.class);
registry.registerBeanDefinition(ConfigBeanDefinitionRegistryPostProcessor.class.getName(), bean.getBeanDefinition());
}