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


Java GenericBeanDefinition.setConstructorArgumentValues方法代码示例

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


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

示例1: registerDataSources

import org.springframework.beans.factory.support.GenericBeanDefinition; //导入方法依赖的package包/类
/**
 * 将数据源注入到Spring中
 *
 * @param registry
 * @param dataSourcesMapping
 */
private void registerDataSources(BeanDefinitionRegistry registry,
                                 Map<String, Map<DataSourceType, DataSource>> dataSourcesMapping) {

    for (Map.Entry<String, Map<DataSourceType, DataSource>> entry : dataSourcesMapping.entrySet()) {
        final String name = entry.getKey();
        for (Map.Entry<DataSourceType, DataSource> subEntry : entry.getValue().entrySet()) {
            GenericBeanDefinition dataSourceBeanDefinition = new GenericBeanDefinition();
            dataSourceBeanDefinition.setBeanClass(DataSourceFactoryBean.class);
            ConstructorArgumentValues constructorArgumentValues = new ConstructorArgumentValues();
            constructorArgumentValues.addIndexedArgumentValue(0, subEntry.getValue());
            dataSourceBeanDefinition.setConstructorArgumentValues(constructorArgumentValues);
            String beanName = name + Character.toUpperCase(subEntry.getKey().name().charAt(0))
                    + subEntry.getKey().name().substring(1) + "DataSource";
            registry.registerBeanDefinition(beanName, dataSourceBeanDefinition);
        }
    }
}
 
开发者ID:baihui212,项目名称:tsharding,代码行数:24,代码来源:DataSourceScanner.java

示例2: 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;
}
 
开发者ID:Indoqa,项目名称:indoqa-spring,代码行数:25,代码来源:DynamicApplicationContextBuilder.java

示例3: testScanWithExplicitSqlSessionTemplate

import org.springframework.beans.factory.support.GenericBeanDefinition; //导入方法依赖的package包/类
@Test
public void testScanWithExplicitSqlSessionTemplate() throws Exception {
  GenericBeanDefinition definition = new GenericBeanDefinition();
  definition.setBeanClass(SqlSessionTemplate.class);
  ConstructorArgumentValues constructorArgs = new ConstructorArgumentValues();
  constructorArgs.addGenericArgumentValue(new RuntimeBeanReference("sqlSessionFactory"));
  definition.setConstructorArgumentValues(constructorArgs);
  applicationContext.registerBeanDefinition("sqlSessionTemplate", definition);

  applicationContext.register(AppConfigWithSqlSessionTemplate.class);
  
  startContext();

  // all interfaces with methods should be loaded
  applicationContext.getBean("mapperInterface");
  applicationContext.getBean("mapperSubinterface");
  applicationContext.getBean("mapperChildInterface");
  applicationContext.getBean("annotatedMapper");
  
}
 
开发者ID:lindzh,项目名称:mybatis-spring-1.2.2,代码行数:21,代码来源:MapperScanTest.java

示例4: createApplicationServlet

import org.springframework.beans.factory.support.GenericBeanDefinition; //导入方法依赖的package包/类
/**
 * Creates a Servlet bean definition for the given JAX-RS application
 *
 * @param applicationClass
 * @param path
 * @return a Servlet bean definition for the given JAX-RS application
 */
private GenericBeanDefinition createApplicationServlet(Class<? extends Application> applicationClass, String path) {
    GenericBeanDefinition applicationServletBean = new GenericBeanDefinition();
    applicationServletBean.setFactoryBeanName(ResteasyApplicationBuilder.BEAN_NAME);
    applicationServletBean.setFactoryMethodName("build");

    Set<Class<?>> resources = allResources;

    ConstructorArgumentValues values = new ConstructorArgumentValues();
    values.addIndexedArgumentValue(0, applicationClass.getName());
    values.addIndexedArgumentValue(1, path);
    values.addIndexedArgumentValue(2, resources);
    values.addIndexedArgumentValue(3, providers);
    applicationServletBean.setConstructorArgumentValues(values);

    applicationServletBean.setAutowireCandidate(false);
    applicationServletBean.setScope("singleton");

    return applicationServletBean;
}
 
开发者ID:paypal,项目名称:resteasy-spring-boot,代码行数:27,代码来源:ResteasyEmbeddedServletInitializer.java

示例5: createBeanDefinition

import org.springframework.beans.factory.support.GenericBeanDefinition; //导入方法依赖的package包/类
private BeanDefinition createBeanDefinition(Object settings, Object setting, String factoryBeanName, Method factoryMethod) {
    final GenericBeanDefinition definition = new GenericBeanDefinition();
    definition.setFactoryBeanName(factoryBeanName);
    definition.setFactoryMethodName(factoryMethod.getName());
    
    //Create method arguments (confusingly called constructor arguments in spring)
    final ConstructorArgumentValues arguments = new ConstructorArgumentValues();
    arguments.addIndexedArgumentValue(0, setting);
    
    final int parameterCount = factoryMethod.getParameterTypes().length;
    if (parameterCount == 2) {
        arguments.addIndexedArgumentValue(1, settings);
    } else if (parameterCount > 2) {
        throw getExceptionFactory().createInvalidArgumentsException(factoryMethod);
    }
    
    //TODO more checking of method arguments to ensure they're correct
    
    definition.setConstructorArgumentValues(arguments);

    return definition;
}
 
开发者ID:Capgemini,项目名称:spring-boot-capgemini,代码行数:23,代码来源:SettingBackedBeanFactoryPostProcessor.java

示例6: setupSqlSessionTemplate

import org.springframework.beans.factory.support.GenericBeanDefinition; //导入方法依赖的package包/类
private GenericApplicationContext setupSqlSessionTemplate() {

    GenericApplicationContext genericApplicationContext = setupSqlSessionFactory();
    GenericBeanDefinition definition = new GenericBeanDefinition();
    definition.setBeanClass(SqlSessionTemplate.class);
    ConstructorArgumentValues constructorArgs = new ConstructorArgumentValues();
    constructorArgs.addGenericArgumentValue(new RuntimeBeanReference("sqlSessionFactory"));
    definition.setConstructorArgumentValues(constructorArgs);
    genericApplicationContext.registerBeanDefinition("sqlSessionTemplate", definition);
    return genericApplicationContext;
  }
 
开发者ID:lindzh,项目名称:mybatis-spring-1.2.2,代码行数:12,代码来源:NamespaceTest.java

示例7: testScanWithExplicitSqlSessionTemplate

import org.springframework.beans.factory.support.GenericBeanDefinition; //导入方法依赖的package包/类
@Test
public void testScanWithExplicitSqlSessionTemplate() throws Exception {
  GenericBeanDefinition definition = new GenericBeanDefinition();
  definition.setBeanClass(SqlSessionTemplate.class);
  ConstructorArgumentValues constructorArgs = new ConstructorArgumentValues();
  constructorArgs.addGenericArgumentValue(new RuntimeBeanReference("sqlSessionFactory"));
  definition.setConstructorArgumentValues(constructorArgs);
  applicationContext.registerBeanDefinition("sqlSessionTemplate", definition);

  applicationContext.getBeanDefinition("mapperScanner").getPropertyValues().add(
      "sqlSessionTemplateBeanName", "sqlSessionTemplate");

  testInterfaceScan();
}
 
开发者ID:lindzh,项目名称:mybatis-spring-1.2.2,代码行数:15,代码来源:MapperScannerConfigurerTest.java

示例8: getBeanDefinition

import org.springframework.beans.factory.support.GenericBeanDefinition; //导入方法依赖的package包/类
@Override
public BeanDefinition getBeanDefinition() {
    GenericBeanDefinition def = new GenericBeanDefinition();
    def.setBeanClass(MockFactoryBean.class);
    ConstructorArgumentValues constructorArgumentValues = new ConstructorArgumentValues();
    constructorArgumentValues.addIndexedArgumentValue(0, mockClass);
    def.setConstructorArgumentValues(constructorArgumentValues);
    return def;
}
 
开发者ID:ksaua,项目名称:remock,代码行数:10,代码来源:MockDefinition.java

示例9: registerSingleton

import org.springframework.beans.factory.support.GenericBeanDefinition; //导入方法依赖的package包/类
public void registerSingleton(String name, Class clazz,
		ConstructorArgumentValues ctorArgs) throws BeansException {
	GenericBeanDefinition bd = new GenericBeanDefinition();
	bd.setBeanClass(clazz);
	bd.setConstructorArgumentValues(ctorArgs);
	getDefaultListableBeanFactory().registerBeanDefinition(name, bd);
}
 
开发者ID:williamd1618,项目名称:solace.common-java,代码行数:8,代码来源:ConfigurableApplicationContext.java

示例10: registerPrototype

import org.springframework.beans.factory.support.GenericBeanDefinition; //导入方法依赖的package包/类
public void registerPrototype(String name, Class clazz,
		ConstructorArgumentValues ctorArgs) throws BeansException {
	GenericBeanDefinition bd = new GenericBeanDefinition();
	bd.setBeanClass(clazz);
	bd.setScope(GenericBeanDefinition.SCOPE_PROTOTYPE);
	bd.setConstructorArgumentValues(ctorArgs);
	getDefaultListableBeanFactory().registerBeanDefinition(name, bd);
}
 
开发者ID:williamd1618,项目名称:solace.common-java,代码行数:9,代码来源:ConfigurableApplicationContext.java


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