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


Java BeanDefinitionBuilder.getBeanDefinition方法代码示例

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


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

示例1: createSqlSessionFactoryBean

import org.springframework.beans.factory.support.BeanDefinitionBuilder; //导入方法依赖的package包/类
protected final AbstractBeanDefinition createSqlSessionFactoryBean(String dataSourceName, String mapperPackage,
		String typeAliasesPackage, Dialect dialect, Configuration configuration) {
	configuration.setDatabaseId(dataSourceName);
	BeanDefinitionBuilder bdb = BeanDefinitionBuilder.rootBeanDefinition(SqlSessionFactoryBean.class);
	bdb.addPropertyValue("configuration", configuration);
	bdb.addPropertyValue("failFast", true);
	bdb.addPropertyValue("typeAliases", this.saenTypeAliases(typeAliasesPackage));
	bdb.addPropertyReference("dataSource", dataSourceName);
	bdb.addPropertyValue("plugins", new Interceptor[] { new CustomPageInterceptor(dialect) });
	if (!StringUtils.isEmpty(mapperPackage)) {
		try {
			mapperPackage = new StandardEnvironment().resolveRequiredPlaceholders(mapperPackage);
			String mapperPackages = ClassUtils.convertClassNameToResourcePath(mapperPackage);
			String mapperPackagePath = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX + mapperPackages + "/*.xml";
			Resource[] resources = new PathMatchingResourcePatternResolver().getResources(mapperPackagePath);
			bdb.addPropertyValue("mapperLocations", resources);
		} catch (Exception e) {
			log.error("初始化失败", e);
			throw new RuntimeException( String.format("SqlSessionFactory 初始化失败  mapperPackage=%s", mapperPackage + ""));
		}
	}
	return bdb.getBeanDefinition();
}
 
开发者ID:halober,项目名称:spring-boot-starter-dao,代码行数:24,代码来源:AbstractDataBaseBean.java

示例2: registerBeans

import org.springframework.beans.factory.support.BeanDefinitionBuilder; //导入方法依赖的package包/类
@Override
protected void registerBeans(InjectRpcClient annotation, ResolvableType targetType, BeanDefinitionRegistry registry) {
    String tag = annotation.tag().isEmpty() ? "" : '#' + annotation.tag();

    String name = RpcClientBean.class.getName() + tag + "-" + targetType.toString();

    if (!registry.containsBeanDefinition(name)) {
        BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(RpcClientBean.class)
            .setLazyInit(true)
            .addPropertyValue("rpcInterface", targetType.getType().getTypeName());

        if (!annotation.tag().isEmpty()) {
            builder.addPropertyValue("tag", annotation.tag());
        }

        AbstractBeanDefinition def = builder.getBeanDefinition();

        AutowireCandidateQualifier qualifier = new AutowireCandidateQualifier(annotation.annotationType());

        if (!annotation.tag().isEmpty()) {
            qualifier.setAttribute("tag", annotation.tag());
        }

        def.addQualifier(qualifier);

        registry.registerBeanDefinition(name, def);
    }
}
 
开发者ID:hekate-io,项目名称:hekate,代码行数:29,代码来源:HekateRpcServiceConfigurer.java

示例3: 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);
	}
}
 
开发者ID:melthaw,项目名称:spring-backend-boilerplate,代码行数:20,代码来源:EnableMenuImportSelector.java

示例4: buildPostProcessorDefinition

import org.springframework.beans.factory.support.BeanDefinitionBuilder; //导入方法依赖的package包/类
private BeanDefinition buildPostProcessorDefinition(AnnotationMetadata importMetadata, AnnotationAttributes attributes) {
  SnowdropRepositoryConfigExtension extension = new SnowdropRepositoryConfigExtension();
  BeanDefinitionBuilder builder = BeanDefinitionBuilder
          .rootBeanDefinition(JpaRepositoryFactoryBeanSnowdropPostProcessor.class);

  builder.getRawBeanDefinition().setSource(importMetadata);

  builder.addPropertyValue("queryLookupStrategyKey", attributes.get(QUERY_LOOKUP_STRATEGY));

  NamedQueriesBeanDefinitionBuilder definitionBuilder = new NamedQueriesBeanDefinitionBuilder(
          extension.getDefaultNamedQueryLocation());

  String namedQueriesLocation = attributes.getString(NAMED_QUERIES_LOCATION);
  if (StringUtils.hasText(namedQueriesLocation)) {
    definitionBuilder.setLocations(namedQueriesLocation);
  }
  builder.addPropertyValue("namedQueriesLocation", definitionBuilder.build(importMetadata));

  return builder.getBeanDefinition();
}
 
开发者ID:snowdrop,项目名称:spring-data-snowdrop,代码行数:21,代码来源:JpaWithSnowdropRegistrar.java

示例5: buildExporter

import org.springframework.beans.factory.support.BeanDefinitionBuilder; //导入方法依赖的package包/类
private AbstractBeanDefinition buildExporter(ServiceMetadata metadata) {
	BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(EXPORTER_CLASS);
	// add properties
	builder.addPropertyValue(EXPORTER_RANKING_PROP, metadata.getRanking());
	builder.addPropertyValue(EXPORTER_INTFS_PROP, metadata.getInterfaces());
	builder.addPropertyValue(EXPORTER_PROPS_PROP, metadata.getServiceProperties());
	builder.addPropertyValue(EXPORTER_AUTO_EXPORT_PROP,
			DefaultInterfaceDetector.values()[metadata.getAutoExport() - 1]);

	BeanMetadataElement beanMetadata = BeanMetadataElementFactory.buildBeanMetadata(metadata.getServiceComponent());
	if (beanMetadata instanceof RuntimeBeanReference) {
		builder.addPropertyValue(EXPORTER_TARGET_BEAN_NAME_PROP, beanMetadata);
	} else {
		builder.addPropertyValue(EXPORTER_TARGET_BEAN_PROP, beanMetadata);
	}

	// FIXME: add registration listeners

	return builder.getBeanDefinition();
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:21,代码来源:BeanDefinitionFactory.java

示例6: parseInternal

import org.springframework.beans.factory.support.BeanDefinitionBuilder; //导入方法依赖的package包/类
@Override
protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) {
	BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(AnnotationMBeanExporter.class);

	// Mark as infrastructure bean and attach source location.
	builder.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
	builder.getRawBeanDefinition().setSource(parserContext.extractSource(element));

	String defaultDomain = element.getAttribute(DEFAULT_DOMAIN_ATTRIBUTE);
	if (StringUtils.hasText(defaultDomain)) {
		builder.addPropertyValue("defaultDomain", defaultDomain);
	}

	String serverBeanName = element.getAttribute(SERVER_ATTRIBUTE);
	if (StringUtils.hasText(serverBeanName)) {
		builder.addPropertyReference("server", serverBeanName);
	}
	else {
		AbstractBeanDefinition specialServer = MBeanServerBeanDefinitionParser.findServerForSpecialEnvironment();
		if (specialServer != null) {
			builder.addPropertyValue("server", specialServer);
		}
	}

	String registration = element.getAttribute(REGISTRATION_ATTRIBUTE);
	RegistrationPolicy registrationPolicy = RegistrationPolicy.FAIL_ON_EXISTING;
	if (REGISTRATION_IGNORE_EXISTING.equals(registration)) {
		registrationPolicy = RegistrationPolicy.IGNORE_EXISTING;
	}
	else if (REGISTRATION_REPLACE_EXISTING.equals(registration)) {
		registrationPolicy = RegistrationPolicy.REPLACE_EXISTING;
	}
	builder.addPropertyValue("registrationPolicy", registrationPolicy);

	return builder.getBeanDefinition();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:37,代码来源:MBeanExportBeanDefinitionParser.java

示例7: parseInternal

import org.springframework.beans.factory.support.BeanDefinitionBuilder; //导入方法依赖的package包/类
@Override
protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) {
	BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(EmbeddedDatabaseFactoryBean.class);
	setDatabaseType(element, builder);
	DatabasePopulatorConfigUtils.setDatabasePopulator(element, builder);
	useIdAsDatabaseNameIfGiven(element, builder);
	builder.getRawBeanDefinition().setSource(parserContext.extractSource(element));
	return builder.getBeanDefinition();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:EmbeddedDatabaseBeanDefinitionParser.java

示例8: registerBeanDefinition

import org.springframework.beans.factory.support.BeanDefinitionBuilder; //导入方法依赖的package包/类
public BeanComponentDefinition registerBeanDefinition(BeanDefinitionBuilder builder, Element element, ParserContext parserContext) {
    BeanDefinitionHolder holder
            = new BeanDefinitionHolder(builder.getBeanDefinition(),
                    getId(element, builder, parserContext),
                    parseAliase(element));
    BeanDefinitionReaderUtils
            .registerBeanDefinition(holder, parserContext.getRegistry());
    BeanComponentDefinition componentDefinition
            = new BeanComponentDefinition(holder);
    parserContext.registerComponent(componentDefinition);
    return componentDefinition;
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:13,代码来源:RedissonNamespaceParserSupport.java

示例9: 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);
}
 
开发者ID:xm-online,项目名称:xm-commons,代码行数:28,代码来源:LepServicesRegistrar.java

示例10: parseInternal

import org.springframework.beans.factory.support.BeanDefinitionBuilder; //导入方法依赖的package包/类
/**
 * Creates a {@link BeanDefinitionBuilder} instance for the
 * {@link #getBeanClass bean Class} and passes it to the
 * {@link #doParse} strategy method.
 * @param element the element that is to be parsed into a single BeanDefinition
 * @param parserContext the object encapsulating the current state of the parsing process
 * @return the BeanDefinition resulting from the parsing of the supplied {@link Element}
 * @throws IllegalStateException if the bean {@link Class} returned from
 * {@link #getBeanClass(org.w3c.dom.Element)} is {@code null}
 * @see #doParse
 */
@Override
protected final AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) {
	BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition();
	String parentName = getParentName(element);
	if (parentName != null) {
		builder.getRawBeanDefinition().setParentName(parentName);
	}
	Class<?> beanClass = getBeanClass(element);
	if (beanClass != null) {
		builder.getRawBeanDefinition().setBeanClass(beanClass);
	}
	else {
		String beanClassName = getBeanClassName(element);
		if (beanClassName != null) {
			builder.getRawBeanDefinition().setBeanClassName(beanClassName);
		}
	}
	builder.getRawBeanDefinition().setSource(parserContext.extractSource(element));
	if (parserContext.isNested()) {
		// Inner bean definition must receive same scope as containing bean.
		builder.setScope(parserContext.getContainingBeanDefinition().getScope());
	}
	if (parserContext.isDefaultLazyInit()) {
		// Default-lazy-init applies to custom bean definitions as well.
		builder.setLazyInit(true);
	}
	doParse(element, parserContext, builder);
	return builder.getBeanDefinition();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:41,代码来源:AbstractSingleBeanDefinitionParser.java

示例11: buildZookeeperConfigurationBeanDefinition

import org.springframework.beans.factory.support.BeanDefinitionBuilder; //导入方法依赖的package包/类
private AbstractBeanDefinition buildZookeeperConfigurationBeanDefinition(final Element element, final ParserContext parserContext) {
    BeanDefinitionBuilder result = BeanDefinitionBuilder.rootBeanDefinition(ZookeeperConfiguration.class);
    addPropertyValueIfNotEmpty(ZookeeperBeanDefinitionTag.SERVER_LISTS, "serverLists", element, result);
    addPropertyValueIfNotEmpty(ZookeeperBeanDefinitionTag.NAMESPACE, "namespace", element, result);
    addPropertyValueIfNotEmpty(ZookeeperBeanDefinitionTag.BASE_SLEEP_TIME_MS, "baseSleepTimeMilliseconds", element, result);
    addPropertyValueIfNotEmpty(ZookeeperBeanDefinitionTag.MAX_SLEEP_TIME_MS, "maxSleepTimeMilliseconds", element, result);
    addPropertyValueIfNotEmpty(ZookeeperBeanDefinitionTag.MAX_RETRIES, "maxRetries", element, result);
    addPropertyValueIfNotEmpty(ZookeeperBeanDefinitionTag.SESSION_TIMEOUT_MS, "sessionTimeoutMilliseconds", element, result);
    addPropertyValueIfNotEmpty(ZookeeperBeanDefinitionTag.CONNECTION_TIMEOUT_MS, "connectionTimeoutMilliseconds", element, result);
    addPropertyValueIfNotEmpty(ZookeeperBeanDefinitionTag.DIGEST, "digest", element, result);
    return result.getBeanDefinition();
}
 
开发者ID:imadcn,项目名称:idworker,代码行数:13,代码来源:RegistryBeanDefinitionParser.java

示例12: parseInternal

import org.springframework.beans.factory.support.BeanDefinitionBuilder; //导入方法依赖的package包/类
@Override
protected AbstractBeanDefinition parseInternal(final Element element, final ParserContext parserContext) {
    BeanDefinitionBuilder result = BeanDefinitionBuilder.rootBeanDefinition(generatorClass);
    result.addConstructorArgValue(buildWorkerNodeRegisterBeanDefinition(element, parserContext));
    result.setInitMethodName("init");
    return result.getBeanDefinition();
}
 
开发者ID:imadcn,项目名称:idworker,代码行数:8,代码来源:GeneratorBeanDefinitionParser.java

示例13: parseInternal

import org.springframework.beans.factory.support.BeanDefinitionBuilder; //导入方法依赖的package包/类
@Override
protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) {
	BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(DataSourceInitializer.class);
	builder.addPropertyReference("dataSource", element.getAttribute("data-source"));
	builder.addPropertyValue("enabled", element.getAttribute("enabled"));
	DatabasePopulatorConfigUtils.setDatabasePopulator(element, builder);
	builder.getRawBeanDefinition().setSource(parserContext.extractSource(element));
	return builder.getBeanDefinition();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:InitializeDatabaseBeanDefinitionParser.java

示例14: createDatabasePopulator

import org.springframework.beans.factory.support.BeanDefinitionBuilder; //导入方法依赖的package包/类
static private BeanDefinition createDatabasePopulator(Element element, List<Element> scripts, String execution) {
	BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(CompositeDatabasePopulator.class);

	boolean ignoreFailedDrops = element.getAttribute("ignore-failures").equals("DROPS");
	boolean continueOnError = element.getAttribute("ignore-failures").equals("ALL");

	ManagedList<BeanMetadataElement> delegates = new ManagedList<BeanMetadataElement>();
	for (Element scriptElement : scripts) {
		String executionAttr = scriptElement.getAttribute("execution");
		if (!StringUtils.hasText(executionAttr)) {
			executionAttr = "INIT";
		}
		if (!execution.equals(executionAttr)) {
			continue;
		}
		BeanDefinitionBuilder delegate = BeanDefinitionBuilder.genericBeanDefinition(ResourceDatabasePopulator.class);
		delegate.addPropertyValue("ignoreFailedDrops", ignoreFailedDrops);
		delegate.addPropertyValue("continueOnError", continueOnError);

		// Use a factory bean for the resources so they can be given an order if a pattern is used
		BeanDefinitionBuilder resourcesFactory = BeanDefinitionBuilder.genericBeanDefinition(SortedResourcesFactoryBean.class);
		resourcesFactory.addConstructorArgValue(new TypedStringValue(scriptElement.getAttribute("location")));
		delegate.addPropertyValue("scripts", resourcesFactory.getBeanDefinition());
		if (StringUtils.hasLength(scriptElement.getAttribute("encoding"))) {
			delegate.addPropertyValue("sqlScriptEncoding", new TypedStringValue(scriptElement.getAttribute("encoding")));
		}
		if (StringUtils.hasLength(scriptElement.getAttribute("separator"))) {
			delegate.addPropertyValue("separator", new TypedStringValue(scriptElement.getAttribute("separator")));
		}
		delegates.add(delegate.getBeanDefinition());
	}
	builder.addPropertyValue("populators", delegates);

	return builder.getBeanDefinition();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:36,代码来源:DatabasePopulatorConfigUtils.java

示例15: parseInternal

import org.springframework.beans.factory.support.BeanDefinitionBuilder; //导入方法依赖的package包/类
@Override
protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) {
    BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(ServiceBean.class);
    this.setInterface(element, builder);
    this.setGroup(element, builder);
    this.setVersion(element, builder);
    this.setRef(element, builder);
    return builder.getBeanDefinition();
}
 
开发者ID:venus-boot,项目名称:saluki,代码行数:10,代码来源:GrpcServiceBeanDefinitionParser.java


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