Java Code Examples for org.springframework.beans.factory.FactoryBeanNotInitializedException

The following examples show how to use org.springframework.beans.factory.FactoryBeanNotInitializedException. These examples are extracted from open source projects. 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 Project: spring-analysis-note   Source File: ProxyFactoryBean.java    License: MIT License 6 votes vote down vote up
/**
 * Return the singleton instance of this class's proxy object,
 * lazily creating it if it hasn't been created already.
 * @return the shared singleton proxy
 */
private synchronized Object getSingletonInstance() {
	if (this.singletonInstance == null) {
		this.targetSource = freshTargetSource();
		if (this.autodetectInterfaces && getProxiedInterfaces().length == 0 && !isProxyTargetClass()) {
			// Rely on AOP infrastructure to tell us what interfaces to proxy.
			Class<?> targetClass = getTargetClass();
			if (targetClass == null) {
				throw new FactoryBeanNotInitializedException("Cannot determine target class for proxy");
			}
			setInterfaces(ClassUtils.getAllInterfacesForClass(targetClass, this.proxyClassLoader));
		}
		// Initialize the shared singleton instance.
		super.setFrozen(this.freezeProxy);
		this.singletonInstance = getProxy(createAopProxy());
	}
	return this.singletonInstance;
}
 
Example 2
Source Project: spring-analysis-note   Source File: FieldRetrievingFactoryBean.java    License: MIT License 6 votes vote down vote up
@Override
@Nullable
public Object getObject() throws IllegalAccessException {
	if (this.fieldObject == null) {
		throw new FactoryBeanNotInitializedException();
	}
	ReflectionUtils.makeAccessible(this.fieldObject);
	if (this.targetObject != null) {
		// instance field
		return this.fieldObject.get(this.targetObject);
	}
	else {
		// class field
		return this.fieldObject.get(null);
	}
}
 
Example 3
Source Project: spring-analysis-note   Source File: MethodInvokingFactoryBean.java    License: MIT License 6 votes vote down vote up
/**
 * Returns the same value each time if the singleton property is set
 * to "true", otherwise returns the value returned from invoking the
 * specified method on the fly.
 */
@Override
@Nullable
public Object getObject() throws Exception {
	if (this.singleton) {
		if (!this.initialized) {
			throw new FactoryBeanNotInitializedException();
		}
		// Singleton: return shared object.
		return this.singletonObject;
	}
	else {
		// Prototype: new object on each call.
		return invokeWithTargetException();
	}
}
 
Example 4
Source Project: java-technology-stack   Source File: ProxyFactoryBean.java    License: MIT License 6 votes vote down vote up
/**
 * Return the singleton instance of this class's proxy object,
 * lazily creating it if it hasn't been created already.
 * @return the shared singleton proxy
 */
private synchronized Object getSingletonInstance() {
	if (this.singletonInstance == null) {
		this.targetSource = freshTargetSource();
		if (this.autodetectInterfaces && getProxiedInterfaces().length == 0 && !isProxyTargetClass()) {
			// Rely on AOP infrastructure to tell us what interfaces to proxy.
			Class<?> targetClass = getTargetClass();
			if (targetClass == null) {
				throw new FactoryBeanNotInitializedException("Cannot determine target class for proxy");
			}
			setInterfaces(ClassUtils.getAllInterfacesForClass(targetClass, this.proxyClassLoader));
		}
		// Initialize the shared singleton instance.
		super.setFrozen(this.freezeProxy);
		this.singletonInstance = getProxy(createAopProxy());
	}
	return this.singletonInstance;
}
 
Example 5
Source Project: java-technology-stack   Source File: FieldRetrievingFactoryBean.java    License: MIT License 6 votes vote down vote up
@Override
@Nullable
public Object getObject() throws IllegalAccessException {
	if (this.fieldObject == null) {
		throw new FactoryBeanNotInitializedException();
	}
	ReflectionUtils.makeAccessible(this.fieldObject);
	if (this.targetObject != null) {
		// instance field
		return this.fieldObject.get(this.targetObject);
	}
	else {
		// class field
		return this.fieldObject.get(null);
	}
}
 
Example 6
Source Project: java-technology-stack   Source File: MethodInvokingFactoryBean.java    License: MIT License 6 votes vote down vote up
/**
 * Returns the same value each time if the singleton property is set
 * to "true", otherwise returns the value returned from invoking the
 * specified method on the fly.
 */
@Override
@Nullable
public Object getObject() throws Exception {
	if (this.singleton) {
		if (!this.initialized) {
			throw new FactoryBeanNotInitializedException();
		}
		// Singleton: return shared object.
		return this.singletonObject;
	}
	else {
		// Prototype: new object on each call.
		return invokeWithTargetException();
	}
}
 
Example 7
Source Project: lams   Source File: ProxyFactoryBean.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Return the singleton instance of this class's proxy object,
 * lazily creating it if it hasn't been created already.
 * @return the shared singleton proxy
 */
private synchronized Object getSingletonInstance() {
	if (this.singletonInstance == null) {
		this.targetSource = freshTargetSource();
		if (this.autodetectInterfaces && getProxiedInterfaces().length == 0 && !isProxyTargetClass()) {
			// Rely on AOP infrastructure to tell us what interfaces to proxy.
			Class<?> targetClass = getTargetClass();
			if (targetClass == null) {
				throw new FactoryBeanNotInitializedException("Cannot determine target class for proxy");
			}
			setInterfaces(ClassUtils.getAllInterfacesForClass(targetClass, this.proxyClassLoader));
		}
		// Initialize the shared singleton instance.
		super.setFrozen(this.freezeProxy);
		this.singletonInstance = getProxy(createAopProxy());
	}
	return this.singletonInstance;
}
 
Example 8
Source Project: spring4-understanding   Source File: ProxyFactoryBean.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Return the singleton instance of this class's proxy object,
 * lazily creating it if it hasn't been created already.
 * @return the shared singleton proxy
 */
private synchronized Object getSingletonInstance() {
	if (this.singletonInstance == null) {
		this.targetSource = freshTargetSource();
		if (this.autodetectInterfaces && getProxiedInterfaces().length == 0 && !isProxyTargetClass()) {
			// Rely on AOP infrastructure to tell us what interfaces to proxy.
			Class<?> targetClass = getTargetClass();
			if (targetClass == null) {
				throw new FactoryBeanNotInitializedException("Cannot determine target class for proxy");
			}
			setInterfaces(ClassUtils.getAllInterfacesForClass(targetClass, this.proxyClassLoader));
		}
		// Initialize the shared singleton instance.
		super.setFrozen(this.freezeProxy);
		this.singletonInstance = getProxy(createAopProxy());
	}
	return this.singletonInstance;
}
 
Example 9
Source Project: spring-analysis-note   Source File: ScopedProxyFactoryBean.java    License: MIT License 5 votes vote down vote up
@Override
public Object getObject() {
	if (this.proxy == null) {
		throw new FactoryBeanNotInitializedException();
	}
	return this.proxy;
}
 
Example 10
@Override
public Object getObject() {
	if (this.proxy == null) {
		throw new FactoryBeanNotInitializedException();
	}
	return this.proxy;
}
 
Example 11
Source Project: spring-analysis-note   Source File: AbstractFactoryBean.java    License: MIT License 5 votes vote down vote up
/**
 * Determine an 'early singleton' instance, exposed in case of a
 * circular reference. Not called in a non-circular scenario.
 */
@SuppressWarnings("unchecked")
private T getEarlySingletonInstance() throws Exception {
	Class<?>[] ifcs = getEarlySingletonInterfaces();
	if (ifcs == null) {
		throw new FactoryBeanNotInitializedException(
				getClass().getName() + " does not support circular references");
	}
	if (this.earlySingletonInstance == null) {
		this.earlySingletonInstance = (T) Proxy.newProxyInstance(
				this.beanClassLoader, ifcs, new EarlySingletonInvocationHandler());
	}
	return this.earlySingletonInstance;
}
 
Example 12
Source Project: java-technology-stack   Source File: ScopedProxyFactoryBean.java    License: MIT License 5 votes vote down vote up
@Override
public Object getObject() {
	if (this.proxy == null) {
		throw new FactoryBeanNotInitializedException();
	}
	return this.proxy;
}
 
Example 13
@Override
public Object getObject() {
	if (this.proxy == null) {
		throw new FactoryBeanNotInitializedException();
	}
	return this.proxy;
}
 
Example 14
Source Project: java-technology-stack   Source File: AbstractFactoryBean.java    License: MIT License 5 votes vote down vote up
/**
 * Determine an 'early singleton' instance, exposed in case of a
 * circular reference. Not called in a non-circular scenario.
 */
@SuppressWarnings("unchecked")
private T getEarlySingletonInstance() throws Exception {
	Class<?>[] ifcs = getEarlySingletonInterfaces();
	if (ifcs == null) {
		throw new FactoryBeanNotInitializedException(
				getClass().getName() + " does not support circular references");
	}
	if (this.earlySingletonInstance == null) {
		this.earlySingletonInstance = (T) Proxy.newProxyInstance(
				this.beanClassLoader, ifcs, new EarlySingletonInvocationHandler());
	}
	return this.earlySingletonInstance;
}
 
Example 15
Source Project: lams   Source File: AbstractFactoryBean.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Determine an 'eager singleton' instance, exposed in case of a
 * circular reference. Not called in a non-circular scenario.
 */
@SuppressWarnings("unchecked")
private T getEarlySingletonInstance() throws Exception {
	Class<?>[] ifcs = getEarlySingletonInterfaces();
	if (ifcs == null) {
		throw new FactoryBeanNotInitializedException(
				getClass().getName() + " does not support circular references");
	}
	if (this.earlySingletonInstance == null) {
		this.earlySingletonInstance = (T) Proxy.newProxyInstance(
				this.beanClassLoader, ifcs, new EarlySingletonInvocationHandler());
	}
	return this.earlySingletonInstance;
}
 
Example 16
@Override
public Object getObject() throws IllegalAccessException {
	if (this.fieldObject == null) {
		throw new FactoryBeanNotInitializedException();
	}
	ReflectionUtils.makeAccessible(this.fieldObject);
	if (this.targetObject != null) {
		// instance field
		return this.fieldObject.get(this.targetObject);
	}
	else {
		// class field
		return this.fieldObject.get(null);
	}
}
 
Example 17
/**
 * Returns the same value each time if the singleton property is set
 * to "true", otherwise returns the value returned from invoking the
 * specified method on the fly.
 */
@Override
public Object getObject() throws Exception {
	if (this.singleton) {
		if (!this.initialized) {
			throw new FactoryBeanNotInitializedException();
		}
		// Singleton: return shared object.
		return this.singletonObject;
	}
	else {
		// Prototype: new object on each call.
		return invokeWithTargetException();
	}
}
 
Example 18
Source Project: lams   Source File: ScopedProxyFactoryBean.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public Object getObject() {
	if (this.proxy == null) {
		throw new FactoryBeanNotInitializedException();
	}
	return this.proxy;
}
 
Example 19
@Override
public Object getObject() {
	if (this.proxy == null) {
		throw new FactoryBeanNotInitializedException();
	}
	return this.proxy;
}
 
Example 20
Source Project: blog_demos   Source File: BeanReferenceFactoryBean.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Object getObject() throws BeansException {
	if (this.beanFactory == null) {
		throw new FactoryBeanNotInitializedException();
	}
	return this.beanFactory.getBean(this.targetBeanName);
}
 
Example 21
Source Project: blog_demos   Source File: BeanReferenceFactoryBean.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public boolean isSingleton() {
	if (this.beanFactory == null) {
		throw new FactoryBeanNotInitializedException();
	}
	return this.beanFactory.isSingleton(this.targetBeanName);
}
 
Example 22
Source Project: blog_demos   Source File: BeanReferenceFactoryBean.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public boolean isPrototype() {
	if (this.beanFactory == null) {
		throw new FactoryBeanNotInitializedException();
	}
	return this.beanFactory.isPrototype(this.targetBeanName);
}
 
Example 23
Source Project: blog_demos   Source File: AbstractFactoryBean.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Determine an 'eager singleton' instance, exposed in case of a
 * circular reference. Not called in a non-circular scenario.
 */
@SuppressWarnings("unchecked")
private T getEarlySingletonInstance() throws Exception {
	Class<?>[] ifcs = getEarlySingletonInterfaces();
	if (ifcs == null) {
		throw new FactoryBeanNotInitializedException(
				getClass().getName() + " does not support circular references");
	}
	if (this.earlySingletonInstance == null) {
		this.earlySingletonInstance = (T) Proxy.newProxyInstance(
				this.beanClassLoader, ifcs, new EarlySingletonInvocationHandler());
	}
	return this.earlySingletonInstance;
}
 
Example 24
Source Project: blog_demos   Source File: FieldRetrievingFactoryBean.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Object getObject() throws IllegalAccessException {
	if (this.fieldObject == null) {
		throw new FactoryBeanNotInitializedException();
	}
	ReflectionUtils.makeAccessible(this.fieldObject);
	if (this.targetObject != null) {
		// instance field
		return this.fieldObject.get(this.targetObject);
	}
	else{
		// class field
		return this.fieldObject.get(null);
	}
}
 
Example 25
Source Project: blog_demos   Source File: MethodInvokingFactoryBean.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Returns the same value each time if the singleton property is set
 * to "true", otherwise returns the value returned from invoking the
 * specified method on the fly.
 */
@Override
public Object getObject() throws Exception {
	if (this.singleton) {
		if (!this.initialized) {
			throw new FactoryBeanNotInitializedException();
		}
		// Singleton: return shared object.
		return this.singletonObject;
	}
	else {
		// Prototype: new object on each call.
		return doInvoke();
	}
}
 
Example 26
@Override
public Object getObject() {
	if (this.proxy == null) {
		throw new FactoryBeanNotInitializedException();
	}
	return this.proxy;
}
 
Example 27
@Override
public Object getObject() {
	if (this.proxy == null) {
		throw new FactoryBeanNotInitializedException();
	}
	return this.proxy;
}
 
Example 28
Source Project: spring4-understanding   Source File: AbstractFactoryBean.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Determine an 'eager singleton' instance, exposed in case of a
 * circular reference. Not called in a non-circular scenario.
 */
@SuppressWarnings("unchecked")
private T getEarlySingletonInstance() throws Exception {
	Class<?>[] ifcs = getEarlySingletonInterfaces();
	if (ifcs == null) {
		throw new FactoryBeanNotInitializedException(
				getClass().getName() + " does not support circular references");
	}
	if (this.earlySingletonInstance == null) {
		this.earlySingletonInstance = (T) Proxy.newProxyInstance(
				this.beanClassLoader, ifcs, new EarlySingletonInvocationHandler());
	}
	return this.earlySingletonInstance;
}
 
Example 29
@Override
public Object getObject() throws IllegalAccessException {
	if (this.fieldObject == null) {
		throw new FactoryBeanNotInitializedException();
	}
	ReflectionUtils.makeAccessible(this.fieldObject);
	if (this.targetObject != null) {
		// instance field
		return this.fieldObject.get(this.targetObject);
	}
	else{
		// class field
		return this.fieldObject.get(null);
	}
}
 
Example 30
/**
 * Returns the same value each time if the singleton property is set
 * to "true", otherwise returns the value returned from invoking the
 * specified method on the fly.
 */
@Override
public Object getObject() throws Exception {
	if (this.singleton) {
		if (!this.initialized) {
			throw new FactoryBeanNotInitializedException();
		}
		// Singleton: return shared object.
		return this.singletonObject;
	}
	else {
		// Prototype: new object on each call.
		return invokeWithTargetException();
	}
}