Java Code Examples for org.springframework.beans.factory.support.BeanDefinitionReaderUtils#GENERATED_BEAN_NAME_SEPARATOR

The following examples show how to use org.springframework.beans.factory.support.BeanDefinitionReaderUtils#GENERATED_BEAN_NAME_SEPARATOR . 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: BeanDefinitionParserDelegate.java    From spring-analysis-note with MIT License 6 votes vote down vote up
@Nullable
private BeanDefinitionHolder parseNestedCustomElement(Element ele, @Nullable BeanDefinition containingBd) {
	BeanDefinition innerDefinition = parseCustomElement(ele, containingBd);
	if (innerDefinition == null) {
		error("Incorrect usage of element '" + ele.getNodeName() + "' in a nested manner. " +
				"This tag cannot be used nested inside <property>.", ele);
		return null;
	}
	String id = ele.getNodeName() + BeanDefinitionReaderUtils.GENERATED_BEAN_NAME_SEPARATOR +
			ObjectUtils.getIdentityHexString(innerDefinition);
	if (logger.isTraceEnabled()) {
		logger.trace("Using generated bean name [" + id +
				"] for nested custom element '" + ele.getNodeName() + "'");
	}
	return new BeanDefinitionHolder(innerDefinition, id);
}
 
Example 2
Source File: BeanNameGenerationTests.java    From spring-analysis-note with MIT License 6 votes vote down vote up
@Test
public void naming() {
	String className = GeneratedNameBean.class.getName();

	String targetName = className + BeanDefinitionReaderUtils.GENERATED_BEAN_NAME_SEPARATOR + "0";
	GeneratedNameBean topLevel1 = (GeneratedNameBean) beanFactory.getBean(targetName);
	assertNotNull(topLevel1);

	targetName = className + BeanDefinitionReaderUtils.GENERATED_BEAN_NAME_SEPARATOR + "1";
	GeneratedNameBean topLevel2 = (GeneratedNameBean) beanFactory.getBean(targetName);
	assertNotNull(topLevel2);

	GeneratedNameBean child1 = topLevel1.getChild();
	assertNotNull(child1.getBeanName());
	assertTrue(child1.getBeanName().startsWith(className));

	GeneratedNameBean child2 = topLevel2.getChild();
	assertNotNull(child2.getBeanName());
	assertTrue(child2.getBeanName().startsWith(className));

	assertFalse(child1.getBeanName().equals(child2.getBeanName()));
}
 
Example 3
Source File: BeanDefinitionParserDelegate.java    From java-technology-stack with MIT License 6 votes vote down vote up
@Nullable
private BeanDefinitionHolder parseNestedCustomElement(Element ele, @Nullable BeanDefinition containingBd) {
	BeanDefinition innerDefinition = parseCustomElement(ele, containingBd);
	if (innerDefinition == null) {
		error("Incorrect usage of element '" + ele.getNodeName() + "' in a nested manner. " +
				"This tag cannot be used nested inside <property>.", ele);
		return null;
	}
	String id = ele.getNodeName() + BeanDefinitionReaderUtils.GENERATED_BEAN_NAME_SEPARATOR +
			ObjectUtils.getIdentityHexString(innerDefinition);
	if (logger.isTraceEnabled()) {
		logger.trace("Using generated bean name [" + id +
				"] for nested custom element '" + ele.getNodeName() + "'");
	}
	return new BeanDefinitionHolder(innerDefinition, id);
}
 
Example 4
Source File: BeanNameGenerationTests.java    From java-technology-stack with MIT License 6 votes vote down vote up
@Test
public void naming() {
	String className = GeneratedNameBean.class.getName();

	String targetName = className + BeanDefinitionReaderUtils.GENERATED_BEAN_NAME_SEPARATOR + "0";
	GeneratedNameBean topLevel1 = (GeneratedNameBean) beanFactory.getBean(targetName);
	assertNotNull(topLevel1);

	targetName = className + BeanDefinitionReaderUtils.GENERATED_BEAN_NAME_SEPARATOR + "1";
	GeneratedNameBean topLevel2 = (GeneratedNameBean) beanFactory.getBean(targetName);
	assertNotNull(topLevel2);

	GeneratedNameBean child1 = topLevel1.getChild();
	assertNotNull(child1.getBeanName());
	assertTrue(child1.getBeanName().startsWith(className));

	GeneratedNameBean child2 = topLevel2.getChild();
	assertNotNull(child2.getBeanName());
	assertTrue(child2.getBeanName().startsWith(className));

	assertFalse(child1.getBeanName().equals(child2.getBeanName()));
}
 
Example 5
Source File: BeanNameGenerationTests.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@Test
public void naming() {
	String className = GeneratedNameBean.class.getName();

	String targetName = className + BeanDefinitionReaderUtils.GENERATED_BEAN_NAME_SEPARATOR + "0";
	GeneratedNameBean topLevel1 = (GeneratedNameBean) beanFactory.getBean(targetName);
	assertNotNull(topLevel1);

	targetName = className + BeanDefinitionReaderUtils.GENERATED_BEAN_NAME_SEPARATOR + "1";
	GeneratedNameBean topLevel2 = (GeneratedNameBean) beanFactory.getBean(targetName);
	assertNotNull(topLevel2);

	GeneratedNameBean child1 = topLevel1.getChild();
	assertNotNull(child1.getBeanName());
	assertTrue(child1.getBeanName().startsWith(className));

	GeneratedNameBean child2 = topLevel2.getChild();
	assertNotNull(child2.getBeanName());
	assertTrue(child2.getBeanName().startsWith(className));

	assertFalse(child1.getBeanName().equals(child2.getBeanName()));
}
 
Example 6
Source File: BeanDefinitionParserDelegate.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
private BeanDefinitionHolder parseNestedCustomElement(Element ele, BeanDefinition containingBd) {
	BeanDefinition innerDefinition = parseCustomElement(ele, containingBd);
	if (innerDefinition == null) {
		error("Incorrect usage of element '" + ele.getNodeName() + "' in a nested manner. " +
				"This tag cannot be used nested inside <property>.", ele);
		return null;
	}
	String id = ele.getNodeName() + BeanDefinitionReaderUtils.GENERATED_BEAN_NAME_SEPARATOR +
			ObjectUtils.getIdentityHexString(innerDefinition);
	if (logger.isDebugEnabled()) {
		logger.debug("Using generated bean name [" + id +
				"] for nested custom element '" + ele.getNodeName() + "'");
	}
	return new BeanDefinitionHolder(innerDefinition, id);
}
 
Example 7
Source File: BeanDefinitionParserDelegate.java    From blog_demos with Apache License 2.0 5 votes vote down vote up
private BeanDefinitionHolder parseNestedCustomElement(Element ele, BeanDefinition containingBd) {
	BeanDefinition innerDefinition = parseCustomElement(ele, containingBd);
	if (innerDefinition == null) {
		error("Incorrect usage of element '" + ele.getNodeName() + "' in a nested manner. " +
				"This tag cannot be used nested inside <property>.", ele);
		return null;
	}
	String id = ele.getNodeName() + BeanDefinitionReaderUtils.GENERATED_BEAN_NAME_SEPARATOR +
			ObjectUtils.getIdentityHexString(innerDefinition);
	if (logger.isDebugEnabled()) {
		logger.debug("Using generated bean name [" + id +
				"] for nested custom element '" + ele.getNodeName() + "'");
	}
	return new BeanDefinitionHolder(innerDefinition, id);
}
 
Example 8
Source File: BeanDefinitionParserDelegate.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
private BeanDefinitionHolder parseNestedCustomElement(Element ele, BeanDefinition containingBd) {
	BeanDefinition innerDefinition = parseCustomElement(ele, containingBd);
	if (innerDefinition == null) {
		error("Incorrect usage of element '" + ele.getNodeName() + "' in a nested manner. " +
				"This tag cannot be used nested inside <property>.", ele);
		return null;
	}
	String id = ele.getNodeName() + BeanDefinitionReaderUtils.GENERATED_BEAN_NAME_SEPARATOR +
			ObjectUtils.getIdentityHexString(innerDefinition);
	if (logger.isDebugEnabled()) {
		logger.debug("Using generated bean name [" + id +
				"] for nested custom element '" + ele.getNodeName() + "'");
	}
	return new BeanDefinitionHolder(innerDefinition, id);
}