1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
|
protected <T> T doGetBean(String name, Class<T> requiredType, final Object[] args, boolean typeCheckOnly) throws BeansException { final String beanName = this.transformedBeanName(name); Object sharedInstance = this.getSingleton(beanName); Object bean; if(sharedInstance != null && args == null) { if(this.logger.isDebugEnabled()) { if(this.isSingletonCurrentlyInCreation(beanName)) { this.logger.debug("Returning eagerly cached instance of singleton bean \'" + beanName + "\' that is not fully initialized yet - a consequence of a circular reference"); } else { this.logger.debug("Returning cached instance of singleton bean \'" + beanName + "\'"); } }
bean = this.getObjectForBeanInstance(sharedInstance, name, beanName, (RootBeanDefinition)null); } else { if(this.isPrototypeCurrentlyInCreation(beanName)) { throw new BeanCurrentlyInCreationException(beanName); } BeanFactory ex = this.getParentBeanFactory(); if(ex != null && !this.containsBeanDefinition(beanName)) { String var24 = this.originalBeanName(name); if(args != null) { return ex.getBean(var24, args); }
return ex.getBean(var24, requiredType); }
if(!typeCheckOnly) { this.markBeanAsCreated(beanName); }
try { final RootBeanDefinition ex1 = this.getMergedLocalBeanDefinition(beanName); this.checkMergedBeanDefinition(ex1, beanName, args); String[] dependsOn = ex1.getDependsOn(); String[] scopeName; if(dependsOn != null) { scopeName = dependsOn; int scope = dependsOn.length; for(int ex2 = 0; ex2 < scope; ++ex2) { String dependsOnBean = scopeName[ex2]; if(this.isDependent(beanName, dependsOnBean)) { throw new BeanCreationException(ex1.getResourceDescription(), beanName, "Circular depends-on relationship between \'" + beanName + "\' and \'" + dependsOnBean + "\'"); }
this.registerDependentBean(dependsOnBean, beanName); this.getBean(dependsOnBean); } } if(ex1.isSingleton()) { sharedInstance = this.getSingleton(beanName, new ObjectFactory() { public Object getObject() throws BeansException { try { return AbstractBeanFactory.this.createBean(beanName, ex1, args); } catch (BeansException var2) { AbstractBeanFactory.this.destroySingleton(beanName); throw var2; } } }); bean = this.getObjectForBeanInstance(sharedInstance, name, beanName, ex1); } else if(ex1.isPrototype()) { scopeName = null;
Object var25; try { this.beforePrototypeCreation(beanName); var25 = this.createBean(beanName, ex1, args); } finally { this.afterPrototypeCreation(beanName); }
bean = this.getObjectForBeanInstance(var25, name, beanName, ex1); } else { String var26 = ex1.getScope(); Scope var27 = (Scope)this.scopes.get(var26); if(var27 == null) { throw new IllegalStateException("No Scope registered for scope \'" + var26 + "\'"); }
try { Object var28 = var27.get(beanName, new ObjectFactory() { public Object getObject() throws BeansException { AbstractBeanFactory.this.beforePrototypeCreation(beanName);
Object var1; try { var1 = AbstractBeanFactory.this.createBean(beanName, ex1, args); } finally { AbstractBeanFactory.this.afterPrototypeCreation(beanName); }
return var1; } }); bean = this.getObjectForBeanInstance(var28, name, beanName, ex1); } catch (IllegalStateException var21) { throw new BeanCreationException(beanName, "Scope \'" + var26 + "\' is not active for the current thread; " + "consider defining a scoped proxy for this bean if you intend to refer to it from a singleton", var21); } } } catch (BeansException var23) { this.cleanupAfterBeanCreationFailure(beanName); throw var23; } }
return bean;
}
|