processNewBean(pri, beanname, newbean);  if (rbi.initmethod != null) { reflectivecache.invokeMethod(newbean, rbi.initmethod); } if (newbean instanceof InitializingBean) { try { ((InitializingBean) newbean).afterPropertiesSet(); } catch (Exception e) { throw UniversalRuntimeException.accumulate(e); } } if (rbi.destroymethod != null) { pri.todestroy.add(beanname); } if (newbean instanceof FactoryBean) { FactoryBean factorybean = (FactoryBean) newbean; try { newbean = factorybean.getObject(); } catch (Exception e) { throw UniversalRuntimeException.accumulate(e); } }  pri.beans.set(beanname, newbean);
  private Object createBean(final PerRequestInfo pri, final String beanname) {    CreationMarker marker = (CreationMarker) pri.beans.locateBean(beanname);    if (marker == null) {      marker = BEAN_IN_CREATION_OBJECT;      pri.beans.set(beanname, marker);    }    RSACBeanInfo rbi = (RSACBeanInfo) rbimap.get(beanname);    if (rbi == null) {      throw new NoSuchBeanDefinitionException(beanname,          "Bean definition not found");    }    // implement fetch wrappers in such a way that doesn't slow normal creation.    if (rbi.fetchwrappers != null        && marker.wrapperindex < rbi.fetchwrappers.length) {      if (marker.wrapperindex == 0) {        pri.beans.set(beanname, new CreationMarker(1));      }      else {        ++marker.wrapperindex;      }      Object wrappero = rbi.fetchwrappers[marker.wrapperindex];      RunnableWrapper wrapper = (RunnableWrapper) (wrappero instanceof RunnableWrapper ? wrappero          : getBean(pri, (String) wrappero, true));      final Object[] togo = new Object[1];      wrapper.wrapRunnable(new Runnable() {        public void run() {          togo[0] = createBean(pri, beanname);        }      }).run();      return togo[0];    }    ++pri.cbeans;    Object newbean;    // NB - isn't this odd, and in fact generally undocumented - properties    // defined for factory-method beans are set on the PRODUCT, whereas those    // set on FactoryBeans are set on the FACTORY!!    if (rbi.factorybean != null) {      Object factorybean = getBean(pri, rbi.factorybean, false);      newbean = reflectivecache.invokeMethod(factorybean, rbi.factorymethod);      if (newbean == null) {        throw new IllegalArgumentException(            "Error: null returned from factory method " + rbi.factorymethod                + " of bean " + rbi.factorybean);      }      // rbi.beanclass = newbean.getClass();    }    else {      // Locate the "dead" bean from the genuine Spring context, and clone it      // as quick as we can - bytecodes might do faster but in the meantime      // observe that a clone typically costs 1.6 reflective calls so in general      // this method will win over a reflective solution.      // NB - all Copiables simply copy dependencies manually for now, no cost.      // Copiable deadbean = (Copiable) livecontext.getBean(rbi.isfactorybean?      // "&" +beanname : beanname);      // All the same, the following line will cost us close to 1us - unless it      // invokes manual code!      newbean = reflectivecache.construct(rbi.beanclass);    }    if (rbi.hasDependencies()) {      // guard this block since if it is a factory-method bean it may be      // something      // extremely undesirable (like an inner class) that we should not even      // dream of reflecting over. If on the other hand the user has specified      // some dependencies they doubtless know what they are doing.      MethodAnalyser ma = smc.getAnalyser(newbean.getClass());      // Object clonebean = deadbean.copy();      // iterate over each LOCAL dependency of the bean with given name.      for (Iterator depit = rbi.dependencies(); depit.hasNext();) {        String propertyname = (String) depit.next();        try {          AccessMethod setter = ma.getAccessMethod(propertyname);          Object depbean = null;          Object beanref = rbi.beannames(propertyname);          if (beanref instanceof String) {            depbean = getBean(pri, (String) beanref, false);          }          else if (beanref instanceof ValueHolder) {            Class accezzz = setter.getAccessedType();            String value = ((ValueHolder) beanref).value;            if (smc.saxleafparser.isLeafType(accezzz)) {              depbean = smc.saxleafparser.parse(accezzz, value);            }            else {              // exception def copied from the beast BeanWrapperImpl!              throw new TypeMismatchException(new PropertyChangeEvent(newbean,                  propertyname, null, value), accezzz, null);            }          }          else {            // Really need generalised conversion of vector values here.            // The code to do this is actually WITHIN the grotty BeanWrapperImpl            // itself in a protected method with 5 arguments!!            // This is a sort of 50% solution. It will deal with all 1-d array            // types and collections, and values of parseable types.            depbean = assembleVectorProperty(pri, (StringList) beanref, setter                .getDeclaredType());          }          // Lose another 500ns here, until we bring on FastClass.          setter.setChildObject(newbean, depbean);        }        catch (Exception e) {          throw UniversalRuntimeException.accumulate(e,              "Error setting dependency " + propertyname + " of bean "                  + beanname);        }      }    }    if (rbi.dependson != null) {      for (int i = 0; i < rbi.dependson.length; ++i) {        getBean(pri, rbi.dependson[i], false);      }    }    // process it FIRST since it will be the factory that is expecting the    // dependencies set!    processNewBean(pri, beanname, newbean);    // now the bean is initialised, attempt to call any init-method or InitBean.    if (rbi.initmethod != null) {      reflectivecache.invokeMethod(newbean, rbi.initmethod);    }    if (newbean instanceof InitializingBean) {      try {        ((InitializingBean) newbean).afterPropertiesSet();      }      catch (Exception e) { // Evil Rod! Bad Juergen!        throw UniversalRuntimeException.accumulate(e);      }    }    if (rbi.destroymethod != null) {      pri.todestroy.add(beanname);    }    if (newbean instanceof FactoryBean) {      FactoryBean factorybean = (FactoryBean) newbean;      try {        newbean = factorybean.getObject();      }      catch (Exception e) {        throw UniversalRuntimeException.accumulate(e);      }    }    // enter the bean into the req-specific map.    pri.beans.set(beanname, newbean);    return newbean;  }