All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.wicp.tams.common.spring.schema.TamsBeanDefinitionParser Maven / Gradle / Ivy

There is a newer version: 3.6.1
Show newest version
/*
 * Copyright (C) 2018 Xplat, Inc. All Rights Reserved.
 */
package net.wicp.tams.common.spring.schema;

import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.beans.factory.xml.BeanDefinitionParser;
import org.springframework.beans.factory.xml.ParserContext;
import org.w3c.dom.Element;

/***
 * 
* @author zhoujunhui
 */
public class TamsBeanDefinitionParser implements BeanDefinitionParser {

	private final Class beanClass;

	public TamsBeanDefinitionParser(Class beanClass) {
		this.beanClass = beanClass;
	}

	public BeanDefinition parse(Element element, ParserContext parserContext) {
		return parse(element, parserContext, beanClass);
	}

	private BeanDefinition parse(Element element, ParserContext parserContext, Class beanClass) {
		RootBeanDefinition rootBeanDefinition = new RootBeanDefinition();
		rootBeanDefinition.setBeanClass(beanClass);
		rootBeanDefinition.setLazyInit(false);
		String annotationPackage = element.getAttribute("package");
		rootBeanDefinition.getPropertyValues().addPropertyValue("annotationPackage", annotationPackage);
		String generatedBeanName = beanClass.getName();
		parserContext.getRegistry().registerBeanDefinition(generatedBeanName, rootBeanDefinition);
		return rootBeanDefinition;
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy