public void afterPropertiesSet() throws Exception { prepare(); if (this.singleton) { this.initialized = true; this.singletonObject = doInvoke(); } }
/** * 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. */ 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(); } }
/** * Returns the same value each time if the singleton property is set * to true, otherwise returns the value returned from invoking the * specified method. However, returns {@link MethodInvoker#VOID} if the * method returns null or has a void return type, since factory beans * must return a result. */ public Object getObject() throws Exception { if (this.singleton) { // Singleton: return shared object. return this.singletonObject; } else { // Prototype: new object on each call. Object retVal = doInvoke(); return (retVal != null ? retVal : MethodInvoker.VOID); } }
public void afterPropertiesSet() throws Exception { prepare(); if (this.singleton) { Object obj = doInvoke(); this.singletonObject = (obj != null ? obj : MethodInvoker.VOID); } }