org.springframework.beans.factory.NamedBean Java Examples

The following examples show how to use org.springframework.beans.factory.NamedBean. 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: ExposeBeanNameAdvisorsTests.java    From spring-analysis-note with MIT License 6 votes vote down vote up
@Test
public void testWithIntroduction() {
	String beanName = "foo";
	TestBean target = new RequiresBeanNameBoundTestBean(beanName);
	ProxyFactory pf = new ProxyFactory(target);
	pf.addAdvisor(ExposeInvocationInterceptor.ADVISOR);
	pf.addAdvisor(ExposeBeanNameAdvisors.createAdvisorIntroducingNamedBean(beanName));
	ITestBean proxy = (ITestBean) pf.getProxy();

	assertTrue("Introduction was made", proxy instanceof NamedBean);
	// Requires binding
	proxy.getAge();

	NamedBean nb = (NamedBean) proxy;
	assertEquals("Name returned correctly", beanName, nb.getBeanName());
}
 
Example #2
Source File: ExposeBeanNameAdvisorsTests.java    From java-technology-stack with MIT License 6 votes vote down vote up
@Test
public void testWithIntroduction() {
	String beanName = "foo";
	TestBean target = new RequiresBeanNameBoundTestBean(beanName);
	ProxyFactory pf = new ProxyFactory(target);
	pf.addAdvisor(ExposeInvocationInterceptor.ADVISOR);
	pf.addAdvisor(ExposeBeanNameAdvisors.createAdvisorIntroducingNamedBean(beanName));
	ITestBean proxy = (ITestBean) pf.getProxy();

	assertTrue("Introduction was made", proxy instanceof NamedBean);
	// Requires binding
	proxy.getAge();

	NamedBean nb = (NamedBean) proxy;
	assertEquals("Name returned correctly", beanName, nb.getBeanName());
}
 
Example #3
Source File: ExposeBeanNameAdvisorsTests.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@Test
public void testWithIntroduction() {
	String beanName = "foo";
	TestBean target = new RequiresBeanNameBoundTestBean(beanName);
	ProxyFactory pf = new ProxyFactory(target);
	pf.addAdvisor(ExposeInvocationInterceptor.ADVISOR);
	pf.addAdvisor(ExposeBeanNameAdvisors.createAdvisorIntroducingNamedBean(beanName));
	ITestBean proxy = (ITestBean) pf.getProxy();

	assertTrue("Introduction was made", proxy instanceof NamedBean);
	// Requires binding
	proxy.getAge();

	NamedBean nb = (NamedBean) proxy;
	assertEquals("Name returned correctly", beanName, nb.getBeanName());
}
 
Example #4
Source File: ExposeBeanNameAdvisorsTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void testNoIntroduction() {
	String beanName = "foo";
	TestBean target = new RequiresBeanNameBoundTestBean(beanName);
	ProxyFactory pf = new ProxyFactory(target);
	pf.addAdvisor(ExposeInvocationInterceptor.ADVISOR);
	pf.addAdvisor(ExposeBeanNameAdvisors.createAdvisorWithoutIntroduction(beanName));
	ITestBean proxy = (ITestBean) pf.getProxy();

	assertFalse("No introduction", proxy instanceof NamedBean);
	// Requires binding
	proxy.getAge();
}
 
Example #5
Source File: ExposeBeanNameAdvisorsTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void testNoIntroduction() {
	String beanName = "foo";
	TestBean target = new RequiresBeanNameBoundTestBean(beanName);
	ProxyFactory pf = new ProxyFactory(target);
	pf.addAdvisor(ExposeInvocationInterceptor.ADVISOR);
	pf.addAdvisor(ExposeBeanNameAdvisors.createAdvisorWithoutIntroduction(beanName));
	ITestBean proxy = (ITestBean) pf.getProxy();

	assertFalse("No introduction", proxy instanceof NamedBean);
	// Requires binding
	proxy.getAge();
}
 
Example #6
Source File: ExposeBeanNameAdvisorsTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
public void testNoIntroduction() {
	String beanName = "foo";
	TestBean target = new RequiresBeanNameBoundTestBean(beanName);
	ProxyFactory pf = new ProxyFactory(target);
	pf.addAdvisor(ExposeInvocationInterceptor.ADVISOR);
	pf.addAdvisor(ExposeBeanNameAdvisors.createAdvisorWithoutIntroduction(beanName));
	ITestBean proxy = (ITestBean) pf.getProxy();

	assertFalse("No introduction", proxy instanceof NamedBean);
	// Requires binding
	proxy.getAge();
}