Java Code Examples for org.springframework.beans.factory.support.AbstractBeanDefinition#setPropertyValues()

The following examples show how to use org.springframework.beans.factory.support.AbstractBeanDefinition#setPropertyValues() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EnableMenuImportSelector.java    From spring-backend-boilerplate with Apache License 2.0 6 votes vote down vote up
@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);
	}
}
 
Example 2
Source File: MulCommonBaseServiceParser.java    From zxl with Apache License 2.0 6 votes vote down vote up
private BeanDefinition buildSessionFactoryBeanDefinition(Element element, String name, BeanDefinitionParserDelegate beanDefinitionParserDelegate, BeanDefinitionRegistry beanDefinitionRegistry) {
	AbstractBeanDefinition beanDefinition = new GenericBeanDefinition();
	beanDefinition.setAttribute(ID_ATTRIBUTE, name + SESSION_FACTORY_SUFFIX);
	beanDefinition.setBeanClass(LocalSessionFactoryBean.class);
	beanDefinition.setParentName(SESSION_FACTORY_PARENT_BEAN_NAME);
	MutablePropertyValues propertyValues = new MutablePropertyValues();
	propertyValues.add("dataSource", new RuntimeBeanReference(name + DATA_SOURCE_SUFFIX));
	if (element.hasAttribute(TABLE_PREFIX_NAME) && !StringUtil.isEmpty(element.getAttribute(TABLE_PREFIX_NAME))) {
		AbstractBeanDefinition namingStrategyBeanDefinition = new GenericBeanDefinition();
		String randomBeanName = UUID.randomUUID().toString();
		namingStrategyBeanDefinition.setAttribute(ID_ATTRIBUTE, randomBeanName);
		namingStrategyBeanDefinition.setBeanClass(HibernateNamingStrategy.class);
		MutablePropertyValues mutablePropertyValues = new MutablePropertyValues();
		mutablePropertyValues.add("prefix", element.getAttribute(TABLE_PREFIX_NAME));
		namingStrategyBeanDefinition.setPropertyValues(mutablePropertyValues);
		beanDefinitionRegistry.registerBeanDefinition(randomBeanName, namingStrategyBeanDefinition);
		propertyValues.addPropertyValue("namingStrategy", new RuntimeBeanReference(randomBeanName));
	}
	beanDefinition.setPropertyValues(propertyValues);
	beanDefinitionParserDelegate.parsePropertyElements(element, beanDefinition);
	return beanDefinition;
}
 
Example 3
Source File: JobDrivenBeanDefinitionParser.java    From niubi-job with Apache License 2.0 5 votes vote down vote up
@Override
public BeanDefinition parse(Element element, ParserContext parserContext) {
    AbstractBeanDefinition beanDefinition = new GenericBeanDefinition();
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    beanDefinition.setBeanClass(SpringContextJobDriver.class);
    propertyValues.addPropertyValue("packagesToScan", element.getAttribute("packagesToScan"));
    beanDefinition.setPropertyValues(propertyValues);
    beanDefinition.setInitMethodName("init");
    BeanDefinitionReaderUtils.registerWithGeneratedName(beanDefinition, parserContext.getRegistry());
    return beanDefinition;
}
 
Example 4
Source File: MulCommonBaseServiceParser.java    From zxl with Apache License 2.0 5 votes vote down vote up
private BeanDefinition buildDataSourceBeanDefinition(Element element, String name) {
	AbstractBeanDefinition beanDefinition = new GenericBeanDefinition();
	beanDefinition.setAttribute(ID_ATTRIBUTE, name + DATA_SOURCE_SUFFIX);
	beanDefinition.setBeanClass(SimpleDataSource.class);
	MutablePropertyValues propertyValues = new MutablePropertyValues();
	propertyValues.add("name", name);
	beanDefinition.setPropertyValues(propertyValues);
	return beanDefinition;
}
 
Example 5
Source File: MulCommonBaseServiceParser.java    From zxl with Apache License 2.0 5 votes vote down vote up
private BeanDefinition buildSqlSessionFactoryBeanDefinition(Element element, String name) {
	AbstractBeanDefinition beanDefinition = new GenericBeanDefinition();
	beanDefinition.setAttribute(ID_ATTRIBUTE, name + SQL_SESSION_FACTORY_SUFFIX);
	beanDefinition.setBeanClass(SqlSessionFactoryBean.class);
	beanDefinition.setParentName(SQL_SESSION_FACTORY_PARENT_BEAN_NAME);
	MutablePropertyValues propertyValues = new MutablePropertyValues();
	propertyValues.add("dataSource", new RuntimeBeanReference(name + DATA_SOURCE_SUFFIX));
	propertyValues.add("mapperLocations", MAPPER_LOCATIONS_PREFIX + name + MAPPER_LOCATIONS_SUFFIX);
	beanDefinition.setPropertyValues(propertyValues);
	return beanDefinition;
}
 
Example 6
Source File: MulCommonBaseServiceParser.java    From zxl with Apache License 2.0 5 votes vote down vote up
private BeanDefinition buildCommonBaseDaoBeanDefinition(Element element, String name) {
	AbstractBeanDefinition beanDefinition = new GenericBeanDefinition();
	beanDefinition.setAttribute(ID_ATTRIBUTE, name + COMMON_BASE_DAO_SUFFIX);
	beanDefinition.setBeanClass(COMMON_BASE_DAO_CLASS);
	MutablePropertyValues propertyValues = new MutablePropertyValues();
	propertyValues.add("sessionFactory", new RuntimeBeanReference(name + SESSION_FACTORY_SUFFIX));
	propertyValues.add("sqlSessionTemplate", new RuntimeBeanReference(name + SQL_SESSION_TEMPLATE_SUFFIX));
	propertyValues.add("tablePrefix", element.getAttribute(TABLE_PREFIX_NAME));
	beanDefinition.setPropertyValues(propertyValues);
	return beanDefinition;
}
 
Example 7
Source File: MulCommonBaseServiceParser.java    From zxl with Apache License 2.0 5 votes vote down vote up
private BeanDefinition buildHibernateTransactionManagerBeanDefinition(Element element, String name) {
	AbstractBeanDefinition beanDefinition = new GenericBeanDefinition();
	beanDefinition.setAttribute(ID_ATTRIBUTE, name + HIBERNATE_TRANSACTION_MANAGER_SUFFIX);
	beanDefinition.setBeanClass(HibernateTransactionManager.class);
	MutablePropertyValues propertyValues = new MutablePropertyValues();
	propertyValues.add("sessionFactory", new RuntimeBeanReference(name + SESSION_FACTORY_SUFFIX));
	beanDefinition.setPropertyValues(propertyValues);
	return beanDefinition;
}
 
Example 8
Source File: MulCommonBaseServiceParser.java    From zxl with Apache License 2.0 5 votes vote down vote up
private BeanDefinition buildHibernateAdviceBeanDefinition(Element element, String name) {
	AbstractBeanDefinition beanDefinition = new GenericBeanDefinition();
	beanDefinition.setAttribute(ID_ATTRIBUTE, name + HIBERNATE_ADVICE_SUFFIX);
	beanDefinition.setBeanClass(TransactionInterceptor.class);
	MutablePropertyValues propertyValues = new MutablePropertyValues();
	propertyValues.add("transactionManager", new RuntimeBeanReference(name + HIBERNATE_TRANSACTION_MANAGER_SUFFIX));
	propertyValues.add("transactionAttributeSource", new RuntimeBeanReference(name + TRANSACTION_ATTRIBUTE_SOURCE_SUFFIX));
	beanDefinition.setPropertyValues(propertyValues);
	return beanDefinition;
}
 
Example 9
Source File: MqBeanParser.java    From zxl with Apache License 2.0 5 votes vote down vote up
protected void buildConnectionFactoryBeanDefinition(String beanName, String host, BeanDefinitionRegistry beanDefinitionRegistry) {
	AbstractBeanDefinition connectionFactoryBeanDefinition = new GenericBeanDefinition();
	connectionFactoryBeanDefinition.setBeanClass(CachingConnectionFactory.class);
	if (!StringUtil.isEmpty(host)) {
		MutablePropertyValues connectionFactoryPropertyValues = new MutablePropertyValues();
		connectionFactoryPropertyValues.add("host", host);
		connectionFactoryBeanDefinition.setPropertyValues(connectionFactoryPropertyValues);
	}
	beanDefinitionRegistry.registerBeanDefinition(beanName, connectionFactoryBeanDefinition);
}