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


Java BeanDefinitionBuilder.rootBeanDefinition方法代码示例

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


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

示例1: registerBeanDefinitions

import org.springframework.beans.factory.support.BeanDefinitionBuilder; //导入方法依赖的package包/类
@Override
public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata,
		BeanDefinitionRegistry registry) {
	ComposedTaskProperties properties = composedTaskProperties();
	TaskParser taskParser = new TaskParser("bean-registration",
			properties.getGraph(), false, true);
	Map<String, Integer> taskSuffixMap = getTaskApps(taskParser);
	for (String taskName : taskSuffixMap.keySet()) {
		//handles the possibility that multiple instances of
		// task definition exist in a composed task
		for (int taskSuffix = 0; taskSuffixMap.get(taskName) >= taskSuffix; taskSuffix++) {
			BeanDefinitionBuilder builder = BeanDefinitionBuilder
					.rootBeanDefinition(ComposedTaskRunnerStepFactory.class);
			builder.addConstructorArgValue(properties);
			builder.addConstructorArgValue(String.format("%s_%s",
					taskName, taskSuffix));
			builder.addPropertyValue("taskSpecificProps",
					getPropertiesForTask(taskName, properties));
			builder.addPropertyValue("arguments", properties.getComposedTaskArguments());

			registry.registerBeanDefinition(String.format("%s_%s",
					taskName, taskSuffix), builder.getBeanDefinition());
		}
	}
}
 
开发者ID:spring-cloud-task-app-starters,项目名称:composed-task-runner,代码行数:26,代码来源:StepBeanDefinitionRegistrar.java

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

示例3: parseDeclareParents

import org.springframework.beans.factory.support.BeanDefinitionBuilder; //导入方法依赖的package包/类
/**
 * Parse a '{@code declare-parents}' element and register the appropriate
 * DeclareParentsAdvisor with the BeanDefinitionRegistry encapsulated in the
 * supplied ParserContext.
 */
private AbstractBeanDefinition parseDeclareParents(Element declareParentsElement, ParserContext parserContext) {
	BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(DeclareParentsAdvisor.class);
	builder.addConstructorArgValue(declareParentsElement.getAttribute(IMPLEMENT_INTERFACE));
	builder.addConstructorArgValue(declareParentsElement.getAttribute(TYPE_PATTERN));

	String defaultImpl = declareParentsElement.getAttribute(DEFAULT_IMPL);
	String delegateRef = declareParentsElement.getAttribute(DELEGATE_REF);

	if (StringUtils.hasText(defaultImpl) && !StringUtils.hasText(delegateRef)) {
		builder.addConstructorArgValue(defaultImpl);
	}
	else if (StringUtils.hasText(delegateRef) && !StringUtils.hasText(defaultImpl)) {
		builder.addConstructorArgReference(delegateRef);
	}
	else {
		parserContext.getReaderContext().error(
				"Exactly one of the " + DEFAULT_IMPL + " or " + DELEGATE_REF + " attributes must be specified",
				declareParentsElement, this.parseState.snapshot());
	}

	AbstractBeanDefinition definition = builder.getBeanDefinition();
	definition.setSource(parserContext.extractSource(declareParentsElement));
	parserContext.getReaderContext().registerWithGeneratedName(definition);
	return definition;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:31,代码来源:ConfigBeanDefinitionParser.java

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

示例5: parse

import org.springframework.beans.factory.support.BeanDefinitionBuilder; //导入方法依赖的package包/类
public BeanDefinition parse(Element element, ParserContext parserContext)
{
    BeanDefinitionBuilder dwrController = BeanDefinitionBuilder.rootBeanDefinition(DwrController.class);
    List configurators = new ManagedList();
    configurators.add(new RuntimeBeanReference(DEFAULT_SPRING_CONFIGURATOR_ID));
    dwrController.addPropertyValue("configurators", configurators);

    String debug = element.getAttribute("debug");
    if (StringUtils.hasText(debug))
    {
        dwrController.addPropertyValue("debug", debug);
    }

    String beanName = element.getAttribute(BeanDefinitionParserDelegate.ID_ATTRIBUTE);
    String nameAttr = element.getAttribute(BeanDefinitionParserDelegate.NAME_ATTRIBUTE);
    String[] aliases = null;
    if (!StringUtils.hasText(beanName))
    {
        beanName = element.getAttribute("name");
    }
    else
    {
        String aliasName = element.getAttribute("name");
        if (StringUtils.hasText(aliasName))
        {
            aliases = StringUtils.tokenizeToStringArray(nameAttr, BeanDefinitionParserDelegate.BEAN_NAME_DELIMITERS);
        }
    }

    parseControllerParameters(dwrController, element);
    
    BeanDefinitionHolder holder = new BeanDefinitionHolder(dwrController.getBeanDefinition(), beanName, aliases);
    BeanDefinitionReaderUtils.registerBeanDefinition(holder, parserContext.getRegistry());

    return dwrController.getBeanDefinition();
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:37,代码来源:DwrNamespaceHandler.java

示例6: parseInternal

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

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

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

示例9: registryMangoInstance

import org.springframework.beans.factory.support.BeanDefinitionBuilder; //导入方法依赖的package包/类
/**
 * 向spring中注入mango实例
 * @param beanFactory
 */
private void registryMangoInstance(DefaultListableBeanFactory beanFactory){
    BeanDefinitionBuilder mangoBuilder = BeanDefinitionBuilder.rootBeanDefinition(Mango.class);

    mangoBuilder.setFactoryMethod("newInstance");
    mangoBuilder.addPropertyValue("checkColumn",config.isCheckColumn());
    mangoBuilder.addPropertyValue("compatibleWithEmptyList",config.isCompatibleWithEmptyList());
    mangoBuilder.addPropertyValue("lazyInit",config.isLazyInit());
    mangoBuilder.addPropertyValue("useActualParamName",config.isUseActualParamName());
    mangoBuilder.addPropertyValue("useTransactionForBatchUpdate",config.isUseTransactionForBatchUpdate());

    configCacheHandler(mangoBuilder);

    beanFactory.registerBeanDefinition(Mango.class.getName(),mangoBuilder.getBeanDefinition());
}
 
开发者ID:jfaster,项目名称:mango-spring-boot-starter,代码行数:19,代码来源:MangoDaoAutoCreator.java

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

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

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

示例13: registerSpringConfiguratorIfNecessary

import org.springframework.beans.factory.support.BeanDefinitionBuilder; //导入方法依赖的package包/类
protected BeanDefinition registerSpringConfiguratorIfNecessary(BeanDefinitionRegistry registry)
{
    if (!registry.containsBeanDefinition(DEFAULT_SPRING_CONFIGURATOR_ID))
    {
        BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(SpringConfigurator.class);
        builder.addPropertyValue("creators", new ManagedMap());
        builder.addPropertyValue("converters", new ManagedMap());
        registry.registerBeanDefinition(DEFAULT_SPRING_CONFIGURATOR_ID, builder.getBeanDefinition());
    }
    return registry.getBeanDefinition(DEFAULT_SPRING_CONFIGURATOR_ID);
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:12,代码来源:DwrNamespaceHandler.java

示例14: decorate

import org.springframework.beans.factory.support.BeanDefinitionBuilder; //导入方法依赖的package包/类
/**
 * Registers an &lt;dwr:remote ... /&gt; element.
 */
public BeanDefinitionHolder decorate(Node node, BeanDefinitionHolder definition, ParserContext parserContext)
{
    Element element = (Element) node;

    String javascript = element.getAttribute("javascript");

    BeanDefinitionBuilder beanCreator = BeanDefinitionBuilder.rootBeanDefinition(BeanCreator.class);

    try
    {
        String beanClassName = resolveBeanClassname(definition.getBeanDefinition(), parserContext.getRegistry());
        if (beanClassName == null) 
        {
            throw new FatalBeanException("Unabled to find type for beanName '" + definition.getBeanName() + 
                                         "'. " + "Check your bean has a correctly configured parent or provide a class for " + 
                                         " the bean definition");
        }
        beanCreator.addPropertyValue("beanClass", ClassUtils.forName(beanClassName));
    }
    catch (ClassNotFoundException e)
    {
        throw new FatalBeanException("Unable to create DWR bean creator for '" + definition.getBeanName() + "'.", e);
    }

    String name = definition.getBeanName();
    if (name.startsWith("scopedTarget."))
    {
        name = name.substring(name.indexOf(".") + 1);
    }
    beanCreator.addPropertyValue("beanId", name);
    beanCreator.addPropertyValue("javascript", javascript);

    BeanDefinitionBuilder creatorConfig = BeanDefinitionBuilder.rootBeanDefinition(CreatorConfig.class);
    creatorConfig.addPropertyValue("creator", beanCreator.getBeanDefinition());            
    registerCreator(parserContext.getRegistry(), javascript, creatorConfig, new HashMap(), node.getChildNodes());

    return definition;
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:42,代码来源:DwrNamespaceHandler.java

示例15: registerHermes

import org.springframework.beans.factory.support.BeanDefinitionBuilder; //导入方法依赖的package包/类
/**
 * 注册Hermes
 *
 * @param registry spring bean注册器
 */
private void registerHermes(BeanDefinitionRegistry registry)
        throws InstantiationException, IllegalAccessException {
    String[] zones = this.environment.getProperty("hermes.center-zone").split(",");
    List<Center> centers = new ArrayList<>(zones.length);
    String name = this.environment.getProperty("spring.application.name");
    for (String zone : zones) {
        Center center = new Center(zone);
        center.register(name, this.environment.getProperty("server.port"));
        centers.add(center);
    }
    // 扫描所有类,forPackage放空字符串表示扫描主包
    Reflections reflections = new Reflections(new ConfigurationBuilder()
            .setUrls(ClasspathHelper.forPackage(""))
            .setExpandSuperTypes(false)
    );
    // 注册spring上下文帮助
    BeanDefinitionBuilder bdb = BeanDefinitionBuilder.rootBeanDefinition(ApplicationContextHelper.class);
    registry.registerBeanDefinition("applicationContextHelper", bdb.getBeanDefinition());
    // 注册注册中心bean
    bdb = BeanDefinitionBuilder.rootBeanDefinition(Centers.class)
            .addPropertyValue("centers", centers);
    registry.registerBeanDefinition(Constant.CENTERS_BEAN_NAME, bdb.getBeanDefinition());
    // 注册监听
    Set<String> urlMappings = new HashSet<>(1);
    urlMappings.add("/hermes");
    bdb = BeanDefinitionBuilder.rootBeanDefinition(ServletRegistrationBean.class)
            .addPropertyValue("servlet", new HermesServlet(this.getMethodMap(reflections)))
            .addPropertyValue("urlMappings", urlMappings);
    registry.registerBeanDefinition("hermesServlet", bdb.getBeanDefinition());
    // 注册client
    registerClient(reflections, registry);
}
 
开发者ID:cwdtom,项目名称:hermes-java,代码行数:38,代码来源:HermesRegister.java


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