當前位置: 首頁>>代碼示例>>Java>>正文


Java GenericBeanDefinition.setAutowireMode方法代碼示例

本文整理匯總了Java中org.springframework.beans.factory.support.GenericBeanDefinition.setAutowireMode方法的典型用法代碼示例。如果您正苦於以下問題:Java GenericBeanDefinition.setAutowireMode方法的具體用法?Java GenericBeanDefinition.setAutowireMode怎麽用?Java GenericBeanDefinition.setAutowireMode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.springframework.beans.factory.support.GenericBeanDefinition的用法示例。


在下文中一共展示了GenericBeanDefinition.setAutowireMode方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: doScan

import org.springframework.beans.factory.support.GenericBeanDefinition; //導入方法依賴的package包/類
@Override
public Set<BeanDefinitionHolder> doScan(String... basePackages) {
    Set<BeanDefinitionHolder> beanDefinitions = super.doScan(basePackages);
    if (beanDefinitions.isEmpty()) {
        logger.warn("No  mapper was found in '" + Arrays.toString(basePackages) + "' package. Please check your configuration.");
    } else {
        for (BeanDefinitionHolder holder : beanDefinitions) {
            GenericBeanDefinition definition = (GenericBeanDefinition) holder.getBeanDefinition();
            if (logger.isDebugEnabled()) {
                logger.debug("Creating MapperFactoryBean with name '" + holder.getBeanName() + "' and '" + definition.getBeanClassName()
                        + "' mapperInterface");
            }
            definition.getPropertyValues().add("mapperProxy", getRegistry().getBeanDefinition("mapperProxy"));
            definition.getPropertyValues().add("mapperInterface", definition.getBeanClassName());
            definition.setBeanClass(MapperFactoryBean.class);
            definition.setAutowireMode(AbstractBeanDefinition.AUTOWIRE_BY_TYPE);
        }
    }
    return beanDefinitions;
}
 
開發者ID:lftao,項目名稱:jkami,代碼行數:21,代碼來源:ClassPathMapperScanner.java

示例2: configurationPropertiesWithFactoryBean

import org.springframework.beans.factory.support.GenericBeanDefinition; //導入方法依賴的package包/類
@Test
public void configurationPropertiesWithFactoryBean() throws Exception {
	ConfigurationPropertiesWithFactoryBean.factoryBeanInit = false;
	this.context = new AnnotationConfigApplicationContext() {
		@Override
		protected void onRefresh() throws BeansException {
			assertThat(ConfigurationPropertiesWithFactoryBean.factoryBeanInit)
					.as("Init too early").isFalse();
			super.onRefresh();
		}
	};
	this.context.register(ConfigurationPropertiesWithFactoryBean.class);
	GenericBeanDefinition beanDefinition = new GenericBeanDefinition();
	beanDefinition.setBeanClass(FactoryBeanTester.class);
	beanDefinition.setAutowireMode(AbstractBeanDefinition.AUTOWIRE_BY_TYPE);
	this.context.registerBeanDefinition("test", beanDefinition);
	this.context.refresh();
	assertThat(ConfigurationPropertiesWithFactoryBean.factoryBeanInit).as("No init")
			.isTrue();
}
 
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:21,代碼來源:ConfigurationPropertiesBindingPostProcessorTests.java

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

示例4: configurationPropertiesWithFactoryBean

import org.springframework.beans.factory.support.GenericBeanDefinition; //導入方法依賴的package包/類
@Test
public void configurationPropertiesWithFactoryBean() throws Exception {
	ConfigurationPropertiesWithFactoryBean.factoryBeanInit = false;
	this.context = new AnnotationConfigApplicationContext() {
		@Override
		protected void onRefresh() throws BeansException {
			assertFalse("Init too early",
					ConfigurationPropertiesWithFactoryBean.factoryBeanInit);
			super.onRefresh();
		}
	};
	this.context.register(ConfigurationPropertiesWithFactoryBean.class);
	GenericBeanDefinition beanDefinition = new GenericBeanDefinition();
	beanDefinition.setBeanClass(FactoryBeanTester.class);
	beanDefinition.setAutowireMode(AbstractBeanDefinition.AUTOWIRE_BY_TYPE);
	this.context.registerBeanDefinition("test", beanDefinition);
	this.context.refresh();
	assertTrue("No init", ConfigurationPropertiesWithFactoryBean.factoryBeanInit);
}
 
開發者ID:Nephilim84,項目名稱:contestparser,代碼行數:20,代碼來源:ConfigurationPropertiesBindingPostProcessorTests.java

示例5: doScan

import org.springframework.beans.factory.support.GenericBeanDefinition; //導入方法依賴的package包/類
/**
 * Calls the parent search that will search and register all the candidates. Then the registered objects are post processed to
 * set them as MapperFactoryBeans
 */
@Override
public Set<BeanDefinitionHolder> doScan(String... basePackages) {
	Set<BeanDefinitionHolder> beanDefinitions = super.doScan(basePackages);

	if (beanDefinitions.isEmpty()) {
		logger.warn("No MyBatis mapper was found in '" + Arrays.toString(basePackages)
		      + "' package. Please check your configuration.");
	} else {
		for (BeanDefinitionHolder holder : beanDefinitions) {
			GenericBeanDefinition definition = (GenericBeanDefinition) holder.getBeanDefinition();

			if (logger.isDebugEnabled()) {
				logger.debug("Creating MapperFactoryBean with name '" + holder.getBeanName() + "' and '"
				      + definition.getBeanClassName() + "' mapperInterface");
			}

			// the mapper interface is the original class of the bean
			// but, the actual class of the bean is MapperFactoryBean
			definition.getPropertyValues().add("mapperInterface", definition.getBeanClassName());
			definition.setBeanClass(ZebraMapperFactoryBean.class);

			definition.getPropertyValues().add("addToConfig", this.addToConfig);

			boolean explicitFactoryUsed = false;
			if (StringUtils.hasText(this.sqlSessionFactoryBeanName)) {
				definition.getPropertyValues().add("sqlSessionFactory",
				      new RuntimeBeanReference(this.sqlSessionFactoryBeanName));
				explicitFactoryUsed = true;
			} else if (this.sqlSessionFactory != null) {
				definition.getPropertyValues().add("sqlSessionFactory", this.sqlSessionFactory);
				explicitFactoryUsed = true;
			}

			if (StringUtils.hasText(this.sqlSessionTemplateBeanName)) {
				if (explicitFactoryUsed) {
					logger.warn("Cannot use both: sqlSessionTemplate and sqlSessionFactory together. sqlSessionFactory is ignored.");
				}
				definition.getPropertyValues().add("sqlSessionTemplate",
				      new RuntimeBeanReference(this.sqlSessionTemplateBeanName));
				explicitFactoryUsed = true;
			} else if (this.sqlSessionTemplate != null) {
				if (explicitFactoryUsed) {
					logger.warn("Cannot use both: sqlSessionTemplate and sqlSessionFactory together. sqlSessionFactory is ignored.");
				}
				definition.getPropertyValues().add("sqlSessionTemplate", this.sqlSessionTemplate);
				explicitFactoryUsed = true;
			}

			if (!explicitFactoryUsed) {
				if (logger.isDebugEnabled()) {
					logger.debug("Enabling autowire by type for MapperFactoryBean with name '" + holder.getBeanName()
					      + "'.");
				}
				definition.setAutowireMode(AbstractBeanDefinition.AUTOWIRE_BY_TYPE);
			}
		}
	}

	return beanDefinitions;
}
 
開發者ID:dianping,項目名稱:zebra,代碼行數:65,代碼來源:ZebraClassPathMapperScanner.java

示例6: doScan

import org.springframework.beans.factory.support.GenericBeanDefinition; //導入方法依賴的package包/類
@Override
public Set<BeanDefinitionHolder> doScan(String... basePackages) {
	Set<BeanDefinitionHolder> beanDefinitions = super.doScan(basePackages);

	if (beanDefinitions.isEmpty()) {
		logger.warn("No Dbase mapper was found in '"
				+ Arrays.toString(basePackages)
				+ "' package. Please check your configuration.");
	} else {
		for (BeanDefinitionHolder holder : beanDefinitions) {
			GenericBeanDefinition definition = (GenericBeanDefinition) holder
					.getBeanDefinition();

			if (logger.isDebugEnabled()) {
				logger.debug("Creating MapperFactoryBean with name '"
						+ holder.getBeanName() + "' and '"
						+ definition.getBeanClassName()
						+ "' mapperInterface");
			}

			// the mapper interface is the original class of the bean
			// but, the actual class of the bean is MapperFactoryBean
			definition.getPropertyValues().add("mapperInterface",
					definition.getBeanClassName());
			definition.setBeanClass(MapperFactoryBean.class);

			// definition.getPropertyValues().add("addToConfig",
			// this.addToConfig);

			boolean explicitFactoryUsed = false;
			if (StringUtils.hasText(this.rabbitDbaseFactoryBeanName)) {
				definition.getPropertyValues().add(
						"rabbitDbaseFactory",
						new RuntimeBeanReference(
								this.rabbitDbaseFactoryBeanName));
				explicitFactoryUsed = true;
			}

			if (!explicitFactoryUsed) {
				if (logger.isDebugEnabled()) {
					logger.debug("Enabling autowire by type for MapperFactoryBean with name '"
							+ holder.getBeanName() + "'.");
				}
				definition
						.setAutowireMode(AbstractBeanDefinition.AUTOWIRE_BY_TYPE);
			}
		}
	}

	return beanDefinitions;
}
 
開發者ID:xuegongzi,項目名稱:rabbitframework,代碼行數:52,代碼來源:ClassPathMapperScanner.java

示例7: doScan

import org.springframework.beans.factory.support.GenericBeanDefinition; //導入方法依賴的package包/類
/**
 * Calls the parent search that will search and register all the candidates.
 * Then the registered objects are post processed to set them as
 * MapperFactoryBeans
 */
@Override
public Set<BeanDefinitionHolder> doScan(String... basePackages) {
  Set<BeanDefinitionHolder> beanDefinitions = super.doScan(basePackages);

  if (beanDefinitions.isEmpty()) {
    logger.warn("No MyBatis mapper was found in '" + Arrays.toString(basePackages) + "' package. Please check your configuration.");
  } else {
    for (BeanDefinitionHolder holder : beanDefinitions) {
      GenericBeanDefinition definition = (GenericBeanDefinition) holder.getBeanDefinition();

      if (logger.isDebugEnabled()) {
        logger.debug("Creating MapperFactoryBean with name '" + holder.getBeanName() 
            + "' and '" + definition.getBeanClassName() + "' mapperInterface");
      }

      // the mapper interface is the original class of the bean
      // but, the actual class of the bean is MapperFactoryBean
      definition.getPropertyValues().add("mapperInterface", definition.getBeanClassName());
      definition.setBeanClass(MapperFactoryBean.class);

      definition.getPropertyValues().add("addToConfig", this.addToConfig);

      boolean explicitFactoryUsed = false;
      if (StringUtils.hasText(this.sqlSessionFactoryBeanName)) {
        definition.getPropertyValues().add("sqlSessionFactory", new RuntimeBeanReference(this.sqlSessionFactoryBeanName));
        explicitFactoryUsed = true;
      } else if (this.sqlSessionFactory != null) {
        definition.getPropertyValues().add("sqlSessionFactory", this.sqlSessionFactory);
        explicitFactoryUsed = true;
      }

      if (StringUtils.hasText(this.sqlSessionTemplateBeanName)) {
        if (explicitFactoryUsed) {
          logger.warn("Cannot use both: sqlSessionTemplate and sqlSessionFactory together. sqlSessionFactory is ignored.");
        }
        definition.getPropertyValues().add("sqlSessionTemplate", new RuntimeBeanReference(this.sqlSessionTemplateBeanName));
        explicitFactoryUsed = true;
      } else if (this.sqlSessionTemplate != null) {
        if (explicitFactoryUsed) {
          logger.warn("Cannot use both: sqlSessionTemplate and sqlSessionFactory together. sqlSessionFactory is ignored.");
        }
        definition.getPropertyValues().add("sqlSessionTemplate", this.sqlSessionTemplate);
        explicitFactoryUsed = true;
      }

      if (!explicitFactoryUsed) {
        if (logger.isDebugEnabled()) {
          logger.debug("Enabling autowire by type for MapperFactoryBean with name '" + holder.getBeanName() + "'.");
        }
        definition.setAutowireMode(AbstractBeanDefinition.AUTOWIRE_BY_TYPE);
      }
    }
  }

  return beanDefinitions;
}
 
開發者ID:lindzh,項目名稱:mybatis-spring-1.2.2,代碼行數:62,代碼來源:ClassPathMapperScanner.java

示例8: doScan

import org.springframework.beans.factory.support.GenericBeanDefinition; //導入方法依賴的package包/類
/**
 * Calls the parent search that will search and register all the candidates.
 * Then the registered objects are post processed to set them as
 * MapperFactoryBeans
 */
@Override
public Set<BeanDefinitionHolder> doScan(String... basePackages) {
  Set<BeanDefinitionHolder> beanDefinitions = super.doScan(basePackages);

  if (beanDefinitions.isEmpty()) {
    logger.warn("No MyBatis mapper was found in '" + Arrays.toString(basePackages) + "' package. Please check your configuration.");
  } else {
    for (BeanDefinitionHolder holder : beanDefinitions) {
      GenericBeanDefinition definition = (GenericBeanDefinition) holder.getBeanDefinition();

      if (logger.isDebugEnabled()) {
        logger.debug("Creating MapperFactoryBean with name '" + holder.getBeanName() + "' and '" + definition.getBeanClassName() + "' mapperInterface");
      }

      // the mapper interface is the original class of the bean
      // but, the actual class of the bean is MapperFactoryBean
      definition.getPropertyValues().add("mapperInterface", definition.getBeanClassName());
      definition.setBeanClass(MapperFactoryBean.class);

      definition.getPropertyValues().add("addToConfig", this.addToConfig);

      boolean explicitFactoryUsed = false;
      if (StringUtils.hasText(this.sqlSessionFactoryBeanName)) {
        definition.getPropertyValues().add("sqlSessionFactory", new RuntimeBeanReference(this.sqlSessionFactoryBeanName));
        explicitFactoryUsed = true;
      } else if (this.sqlSessionFactory != null) {
        definition.getPropertyValues().add("sqlSessionFactory", this.sqlSessionFactory);
        explicitFactoryUsed = true;
      }

      if (StringUtils.hasText(this.sqlSessionTemplateBeanName)) {
        if (explicitFactoryUsed) {
          logger.warn("Cannot use both: sqlSessionTemplate and sqlSessionFactory together. sqlSessionFactory is ignored.");
        }
        definition.getPropertyValues().add("sqlSessionTemplate", new RuntimeBeanReference(this.sqlSessionTemplateBeanName));
        explicitFactoryUsed = true;
      } else if (this.sqlSessionTemplate != null) {
        if (explicitFactoryUsed) {
          logger.warn("Cannot use both: sqlSessionTemplate and sqlSessionFactory together. sqlSessionFactory is ignored.");
        }
        definition.getPropertyValues().add("sqlSessionTemplate", this.sqlSessionTemplate);
        explicitFactoryUsed = true;
      }

      if (!explicitFactoryUsed) {
        if (logger.isDebugEnabled()) {
          logger.debug("Enabling autowire by type for MapperFactoryBean with name '" + holder.getBeanName() + "'.");
        }
        definition.setAutowireMode(AbstractBeanDefinition.AUTOWIRE_BY_TYPE);
      }
    }
  }

  return beanDefinitions;
}
 
開發者ID:colin-lee,項目名稱:mybatis-spring-support,代碼行數:61,代碼來源:ClassPathMapperScanner.java

示例9: processBeanDefinition

import org.springframework.beans.factory.support.GenericBeanDefinition; //導入方法依賴的package包/類
private void processBeanDefinition(GenericBeanDefinition definition)
{
	definition.getPropertyValues().add("sqlMapInterface", definition.getBeanClassName());
	definition.setBeanClass(SqlMapFactoryBean.class);
	definition.setAutowireMode(AbstractBeanDefinition.AUTOWIRE_BY_TYPE);
}
 
開發者ID:liulhdarks,項目名稱:darks-orm,代碼行數:7,代碼來源:MapperClassDefinitionScanner.java

示例10: createBeanDefinition

import org.springframework.beans.factory.support.GenericBeanDefinition; //導入方法依賴的package包/類
protected GenericBeanDefinition createBeanDefinition(Class<?> beanClass) {
    GenericBeanDefinition beanDefinition = new GenericBeanDefinition();
    beanDefinition.setBeanClass(beanClass);
    beanDefinition.setAutowireMode(GenericBeanDefinition.AUTOWIRE_BY_NAME);
    return beanDefinition;
}
 
開發者ID:grails,項目名稱:grails-boot,代碼行數:7,代碼來源:GspAutoConfiguration.java

示例11: doScan

import org.springframework.beans.factory.support.GenericBeanDefinition; //導入方法依賴的package包/類
/**
 * Calls the parent search that will search and register all the candidates.
 * Then the registered objects are post processed to set them as
 * MapperFactoryBeans
 */
@Override
public Set<BeanDefinitionHolder> doScan(String... basePackages) {
  Set<BeanDefinitionHolder> beanDefinitions = super.doScan(basePackages);

  if (beanDefinitions.isEmpty()) {
    logger.warn("No MyBatis mapper was found in '" + Arrays.toString(basePackages) + "' package. Please check your configuration.");
  } else {
    for (BeanDefinitionHolder holder : beanDefinitions) {
      GenericBeanDefinition definition = (GenericBeanDefinition) holder.getBeanDefinition();

      if (logger.isDebugEnabled()) {
        logger.debug("Creating MapperFactoryBean with name '" + holder.getBeanName() 
            + "' and '" + definition.getBeanClassName() + "' mapperInterface");
      }

      // the mapper interface is the original class of the bean
      // but, the actual class of the bean is MapperFactoryBean

// 此處使用addPropertyValue方法,Spring2.5的MutablePropertyValues
// 沒有add(String propertyName, Object propertyValue)方法
      definition.getPropertyValues().addPropertyValue("mapperInterface", definition.getBeanClassName());
      definition.setBeanClass(MapperFactoryBean.class);

      definition.getPropertyValues().addPropertyValue("addToConfig", this.addToConfig);

      boolean explicitFactoryUsed = false;
      if (StringUtils.hasText(this.sqlSessionFactoryBeanName)) {
        definition.getPropertyValues().addPropertyValue("sqlSessionFactory", new RuntimeBeanReference(this.sqlSessionFactoryBeanName));
        explicitFactoryUsed = true;
      } else if (this.sqlSessionFactory != null) {
        definition.getPropertyValues().addPropertyValue("sqlSessionFactory", this.sqlSessionFactory);
        explicitFactoryUsed = true;
      }

      if (StringUtils.hasText(this.sqlSessionTemplateBeanName)) {
        if (explicitFactoryUsed) {
          logger.warn("Cannot use both: sqlSessionTemplate and sqlSessionFactory together. sqlSessionFactory is ignored.");
        }
        definition.getPropertyValues().addPropertyValue("sqlSessionTemplate", new RuntimeBeanReference(this.sqlSessionTemplateBeanName));
        explicitFactoryUsed = true;
      } else if (this.sqlSessionTemplate != null) {
        if (explicitFactoryUsed) {
          logger.warn("Cannot use both: sqlSessionTemplate and sqlSessionFactory together. sqlSessionFactory is ignored.");
        }
        definition.getPropertyValues().addPropertyValue("sqlSessionTemplate", this.sqlSessionTemplate);
        explicitFactoryUsed = true;
      }

      if (!explicitFactoryUsed) {
        if (logger.isDebugEnabled()) {
          logger.debug("Enabling autowire by type for MapperFactoryBean with name '" + holder.getBeanName() + "'.");
        }
        definition.setAutowireMode(AbstractBeanDefinition.AUTOWIRE_BY_TYPE);
      }
    }
  }

  return beanDefinitions;
}
 
開發者ID:moishalo,項目名稱:MybatisSpring2.5.X,代碼行數:65,代碼來源:ClassPathMapperScanner.java

示例12: doScan

import org.springframework.beans.factory.support.GenericBeanDefinition; //導入方法依賴的package包/類
/**
 * Calls the parent search that will search and register all the candidates.
 * Then the registered objects are post processed to set them as
 * MapperFactoryBeans
 */
@Override
public Set<BeanDefinitionHolder> doScan(String... basePackages) {
	Set<BeanDefinitionHolder> beanDefinitions = super.doScan(basePackages);

	if (beanDefinitions.isEmpty()) {
		logger.warn("No DaoService was found in '"
				+ Arrays.toString(basePackages)
				+ "' package. Please check your configuration.");
	} else {
		for (BeanDefinitionHolder holder : beanDefinitions) {
			GenericBeanDefinition definition = (GenericBeanDefinition) holder
					.getBeanDefinition();

			if (logger.isDebugEnabled()) {
				logger.debug("Creating DaoFactoryBean with name '"
						+ holder.getBeanName() + "' and '"
						+ definition.getBeanClassName() + "' daoInterface");
			}

			// the mapper interface is the original class of the bean
			// but, the actual class of the bean is HibernateDaoFactoryBean
			definition.getPropertyValues().add("daoInterface",
					definition.getBeanClassName());
			definition.getPropertyValues().add("funcs", functions);
			String className = definition.getBeanClassName();
			int idx = className.lastIndexOf(".");
			if (idx > 0)
				className = className.substring(idx + 1);
			String em = daoEntityManagerNames.get(className);
			if (em == null)
				em = entityManagerName;
			String sf = daoSessionFactoryNames.get(className);
			if (sf == null)
				sf = sessionFactoryName;
			definition.getPropertyValues().add("entityManagerName", em);
			definition.getPropertyValues().add("sessionFactoryName", sf);
			definition.setBeanClass(DaoFactoryBean.class);

			definition
					.setAutowireMode(AbstractBeanDefinition.AUTOWIRE_BY_TYPE);
		}
	}

	return beanDefinitions;
}
 
開發者ID:yangjm,項目名稱:winlet,代碼行數:51,代碼來源:DaoScanner.java


注:本文中的org.springframework.beans.factory.support.GenericBeanDefinition.setAutowireMode方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。