Java Code Examples for org.springframework.beans.factory.BeanFactory#getClass()

The following examples show how to use org.springframework.beans.factory.BeanFactory#getClass() . 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: ScriptFactoryPostProcessor.java    From spring-analysis-note with MIT License 6 votes vote down vote up
@Override
public void setBeanFactory(BeanFactory beanFactory) {
	if (!(beanFactory instanceof ConfigurableBeanFactory)) {
		throw new IllegalStateException("ScriptFactoryPostProcessor doesn't work with " +
				"non-ConfigurableBeanFactory: " + beanFactory.getClass());
	}
	this.beanFactory = (ConfigurableBeanFactory) beanFactory;

	// Required so that references (up container hierarchies) are correctly resolved.
	this.scriptBeanFactory.setParentBeanFactory(this.beanFactory);

	// Required so that all BeanPostProcessors, Scopes, etc become available.
	this.scriptBeanFactory.copyConfigurationFrom(this.beanFactory);

	// Filter out BeanPostProcessors that are part of the AOP infrastructure,
	// since those are only meant to apply to beans defined in the original factory.
	this.scriptBeanFactory.getBeanPostProcessors().removeIf(beanPostProcessor ->
			beanPostProcessor instanceof AopInfrastructureBean);
}
 
Example 2
Source File: ScriptFactoryPostProcessor.java    From java-technology-stack with MIT License 6 votes vote down vote up
@Override
public void setBeanFactory(BeanFactory beanFactory) {
	if (!(beanFactory instanceof ConfigurableBeanFactory)) {
		throw new IllegalStateException("ScriptFactoryPostProcessor doesn't work with " +
				"non-ConfigurableBeanFactory: " + beanFactory.getClass());
	}
	this.beanFactory = (ConfigurableBeanFactory) beanFactory;

	// Required so that references (up container hierarchies) are correctly resolved.
	this.scriptBeanFactory.setParentBeanFactory(this.beanFactory);

	// Required so that all BeanPostProcessors, Scopes, etc become available.
	this.scriptBeanFactory.copyConfigurationFrom(this.beanFactory);

	// Filter out BeanPostProcessors that are part of the AOP infrastructure,
	// since those are only meant to apply to beans defined in the original factory.
	this.scriptBeanFactory.getBeanPostProcessors().removeIf(beanPostProcessor ->
			beanPostProcessor instanceof AopInfrastructureBean);
}
 
Example 3
Source File: ScriptFactoryPostProcessor.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void setBeanFactory(BeanFactory beanFactory) {
	if (!(beanFactory instanceof ConfigurableBeanFactory)) {
		throw new IllegalStateException("ScriptFactoryPostProcessor doesn't work with " +
				"non-ConfigurableBeanFactory: " + beanFactory.getClass());
	}
	this.beanFactory = (ConfigurableBeanFactory) beanFactory;

	// Required so that references (up container hierarchies) are correctly resolved.
	this.scriptBeanFactory.setParentBeanFactory(this.beanFactory);

	// Required so that all BeanPostProcessors, Scopes, etc become available.
	this.scriptBeanFactory.copyConfigurationFrom(this.beanFactory);

	// Filter out BeanPostProcessors that are part of the AOP infrastructure,
	// since those are only meant to apply to beans defined in the original factory.
	for (Iterator<BeanPostProcessor> it = this.scriptBeanFactory.getBeanPostProcessors().iterator(); it.hasNext();) {
		if (it.next() instanceof AopInfrastructureBean) {
			it.remove();
		}
	}
}
 
Example 4
Source File: ScriptFactoryPostProcessor.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@Override
public void setBeanFactory(BeanFactory beanFactory) {
	if (!(beanFactory instanceof ConfigurableBeanFactory)) {
		throw new IllegalStateException("ScriptFactoryPostProcessor doesn't work with a BeanFactory "
				+ "which does not implement ConfigurableBeanFactory: " + beanFactory.getClass());
	}
	this.beanFactory = (ConfigurableBeanFactory) beanFactory;

	// Required so that references (up container hierarchies) are correctly resolved.
	this.scriptBeanFactory.setParentBeanFactory(this.beanFactory);

	// Required so that all BeanPostProcessors, Scopes, etc become available.
	this.scriptBeanFactory.copyConfigurationFrom(this.beanFactory);

	// Filter out BeanPostProcessors that are part of the AOP infrastructure,
	// since those are only meant to apply to beans defined in the original factory.
	for (Iterator<BeanPostProcessor> it = this.scriptBeanFactory.getBeanPostProcessors().iterator(); it.hasNext();) {
		if (it.next() instanceof AopInfrastructureBean) {
			it.remove();
		}
	}
}
 
Example 5
Source File: AbstractBeanFactoryBasedTargetSourceCreator.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Override
public final void setBeanFactory(BeanFactory beanFactory) {
	if (!(beanFactory instanceof ConfigurableBeanFactory)) {
		throw new IllegalStateException("Cannot do auto-TargetSource creation with a BeanFactory " +
				"that doesn't implement ConfigurableBeanFactory: " + beanFactory.getClass());
	}
	this.beanFactory = (ConfigurableBeanFactory) beanFactory;
}
 
Example 6
Source File: AbstractBeanFactoryBasedTargetSourceCreator.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public final void setBeanFactory(BeanFactory beanFactory) {
	if (!(beanFactory instanceof ConfigurableBeanFactory)) {
		throw new IllegalStateException("Cannot do auto-TargetSource creation with a BeanFactory " +
				"that doesn't implement ConfigurableBeanFactory: " + beanFactory.getClass());
	}
	this.beanFactory = (ConfigurableBeanFactory) beanFactory;
}