org.springframework.beans.factory.BeanNameAware Java Examples

The following examples show how to use org.springframework.beans.factory.BeanNameAware. 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: AbstractAutowireCapableBeanFactory.java    From spring-analysis-note with MIT License 6 votes vote down vote up
private void invokeAwareMethods(final String beanName, final Object bean) {
	if (bean instanceof Aware) {
		if (bean instanceof BeanNameAware) {
			((BeanNameAware) bean).setBeanName(beanName);
		}
		if (bean instanceof BeanClassLoaderAware) {
			ClassLoader bcl = getBeanClassLoader();
			if (bcl != null) {
				((BeanClassLoaderAware) bean).setBeanClassLoader(bcl);
			}
		}
		if (bean instanceof BeanFactoryAware) {
			((BeanFactoryAware) bean).setBeanFactory(AbstractAutowireCapableBeanFactory.this);
		}
	}
}
 
Example #2
Source File: AbstractAutowireCapableBeanFactory.java    From java-technology-stack with MIT License 6 votes vote down vote up
private void invokeAwareMethods(final String beanName, final Object bean) {
	if (bean instanceof Aware) {
		if (bean instanceof BeanNameAware) {
			((BeanNameAware) bean).setBeanName(beanName);
		}
		if (bean instanceof BeanClassLoaderAware) {
			ClassLoader bcl = getBeanClassLoader();
			if (bcl != null) {
				((BeanClassLoaderAware) bean).setBeanClassLoader(bcl);
			}
		}
		if (bean instanceof BeanFactoryAware) {
			((BeanFactoryAware) bean).setBeanFactory(AbstractAutowireCapableBeanFactory.this);
		}
	}
}
 
Example #3
Source File: AbstractAutowireCapableBeanFactory.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create a new AbstractAutowireCapableBeanFactory.
 */
public AbstractAutowireCapableBeanFactory() {
	super();
	ignoreDependencyInterface(BeanNameAware.class);
	ignoreDependencyInterface(BeanFactoryAware.class);
	ignoreDependencyInterface(BeanClassLoaderAware.class);
}
 
Example #4
Source File: DataSourceCciBuilder.java    From ByteJTA with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void validateXADataSourceInstance() {
	InvocationHandler handler = Proxy.isProxyClass(this.xaDataSourceInstance.getClass())
			? Proxy.getInvocationHandler(this.xaDataSourceInstance) : null;
	ManagedConnectionFactoryHandler mcfh = //
			(handler == null || ManagedConnectionFactoryHandler.class.isInstance(handler) == false) ? null
					: (ManagedConnectionFactoryHandler) handler;
	if (BeanNameAware.class.isInstance(this.xaDataSourceInstance) == false
			&& (mcfh == null || StringUtils.isBlank(mcfh.getIdentifier()))) {
		throw new IllegalStateException("XADataSource is not properly configured!");
	}
}
 
Example #5
Source File: AbstractAutowireCapableBeanFactory.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
private void invokeAwareMethods(final String beanName, final Object bean) {
	if (bean instanceof Aware) {
		if (bean instanceof BeanNameAware) {
			((BeanNameAware) bean).setBeanName(beanName);
		}
		if (bean instanceof BeanClassLoaderAware) {
			((BeanClassLoaderAware) bean).setBeanClassLoader(getBeanClassLoader());
		}
		if (bean instanceof BeanFactoryAware) {
			((BeanFactoryAware) bean).setBeanFactory(AbstractAutowireCapableBeanFactory.this);
		}
	}
}
 
Example #6
Source File: AbstractAutowireCapableBeanFactory.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
/**
 * Create a new AbstractAutowireCapableBeanFactory.
 */
public AbstractAutowireCapableBeanFactory() {
	super();
	ignoreDependencyInterface(BeanNameAware.class);
	ignoreDependencyInterface(BeanFactoryAware.class);
	ignoreDependencyInterface(BeanClassLoaderAware.class);
}
 
Example #7
Source File: AbstractAutowireCapableBeanFactory.java    From blog_demos with Apache License 2.0 5 votes vote down vote up
private void invokeAwareMethods(final String beanName, final Object bean) {
	if (bean instanceof Aware) {
		if (bean instanceof BeanNameAware) {
			((BeanNameAware) bean).setBeanName(beanName);
		}
		if (bean instanceof BeanClassLoaderAware) {
			((BeanClassLoaderAware) bean).setBeanClassLoader(getBeanClassLoader());
		}
		if (bean instanceof BeanFactoryAware) {
			((BeanFactoryAware) bean).setBeanFactory(AbstractAutowireCapableBeanFactory.this);
		}
	}
}
 
Example #8
Source File: AbstractAutowireCapableBeanFactory.java    From blog_demos with Apache License 2.0 5 votes vote down vote up
/**
 * Create a new AbstractAutowireCapableBeanFactory.
 */
public AbstractAutowireCapableBeanFactory() {
	super();
	ignoreDependencyInterface(BeanNameAware.class);
	ignoreDependencyInterface(BeanFactoryAware.class);
	ignoreDependencyInterface(BeanClassLoaderAware.class);
}
 
Example #9
Source File: AbstractAutowireCapableBeanFactory.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
private void invokeAwareMethods(final String beanName, final Object bean) {
	if (bean instanceof Aware) {
		if (bean instanceof BeanNameAware) {
			((BeanNameAware) bean).setBeanName(beanName);
		}
		if (bean instanceof BeanClassLoaderAware) {
			((BeanClassLoaderAware) bean).setBeanClassLoader(getBeanClassLoader());
		}
		if (bean instanceof BeanFactoryAware) {
			((BeanFactoryAware) bean).setBeanFactory(AbstractAutowireCapableBeanFactory.this);
		}
	}
}
 
Example #10
Source File: AbstractAutowireCapableBeanFactory.java    From java-technology-stack with MIT License 5 votes vote down vote up
/**
 * Create a new AbstractAutowireCapableBeanFactory.
 */
public AbstractAutowireCapableBeanFactory() {
	super();
	ignoreDependencyInterface(BeanNameAware.class);
	ignoreDependencyInterface(BeanFactoryAware.class);
	ignoreDependencyInterface(BeanClassLoaderAware.class);
}
 
Example #11
Source File: AbstractAutowireCapableBeanFactory.java    From spring-analysis-note with MIT License 5 votes vote down vote up
/**
 * Create a new AbstractAutowireCapableBeanFactory.
 */
public AbstractAutowireCapableBeanFactory() {
	super();
	ignoreDependencyInterface(BeanNameAware.class);
	ignoreDependencyInterface(BeanFactoryAware.class);
	ignoreDependencyInterface(BeanClassLoaderAware.class);
}
 
Example #12
Source File: DeclarationOrderIndependenceTests.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Test
public void testTargetIsBeanNameAware() {
	assertTrue("target bean is bean name aware",this.target instanceof BeanNameAware);
}
 
Example #13
Source File: SessionScopeTests.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Override
public void postProcessBeforeDestruction(Object bean, String beanName) throws BeansException {
	if (bean instanceof BeanNameAware) {
		((BeanNameAware) bean).setBeanName(null);
	}
}
 
Example #14
Source File: DeclarationOrderIndependenceTests.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Test
public void testTargetIsBeanNameAware() {
	assertTrue("target bean is bean name aware",this.target instanceof BeanNameAware);
}
 
Example #15
Source File: SessionScopeTests.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Override
public void postProcessBeforeDestruction(Object bean, String beanName) throws BeansException {
	if (bean instanceof BeanNameAware) {
		((BeanNameAware) bean).setBeanName(null);
	}
}
 
Example #16
Source File: DeclarationOrderIndependenceTests.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Test
public void testTargetIsBeanNameAware() {
	assertTrue("target bean is bean name aware",this.target instanceof BeanNameAware);
}
 
Example #17
Source File: SessionScopeTests.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Override
public void postProcessBeforeDestruction(Object bean, String beanName) throws BeansException {
	if (bean instanceof BeanNameAware) {
		((BeanNameAware) bean).setBeanName(null);
	}
}