public static Object instantiateBean ( BeanMetaDataConfig beanConfig , BeanInfo beanInfo , DeploymentReflectionIndex index , Module module ) throws Throwable { Joinpoint instantiateJoinpoint = null ; ValueConfig [ ] parameters = new ValueConfig [ 0 ] ; String [ ] types = Configurator . NO_PARAMS_TYPES ; ConstructorConfig ctorConfig = beanConfig . getConstructor ( ) ; if ( ctorConfig != null ) { parameters = ctorConfig . getParameters ( ) ; types = Configurator . getTypes ( parameters ) ; String factoryClass = ctorConfig . getFactoryClass ( ) ; FactoryConfig factory = ctorConfig . getFactory ( ) ; if ( factoryClass != null || factory != null ) { String factoryMethod = ctorConfig . getFactoryMethod ( ) ; if ( factoryMethod == null ) throw PojoLogger . ROOT_LOGGER . missingFactoryMethod ( beanConfig ) ; if ( factoryClass != null ) { // static factory Class < ? > factoryClazz = Class . forName ( factoryClass , false , module . getClassLoader ( ) ) ; Method method = Configurator . findMethod ( index , factoryClazz , factoryMethod , types , true , true , true ) ; MethodJoinpoint mj = new MethodJoinpoint ( method ) ; mj . setTarget ( new ImmediateValue < Object > ( null ) ) ; // null, since this is static call mj . setParameters ( parameters ) ; instantiateJoinpoint = mj ; } else if ( factory != null ) { ReflectionJoinpoint rj = new ReflectionJoinpoint ( factory . getBeanInfo ( ) , factoryMethod , types ) ; // null type is ok, as this should be plain injection rj . setTarget ( new ImmediateValue < Object > ( factory . getValue ( null ) ) ) ; rj . setParameters ( parameters ) ; instantiateJoinpoint = rj ; } } } // plain bean's ctor if ( instantiateJoinpoint == null ) { if ( beanInfo == null ) throw new StartException ( PojoLogger . ROOT_LOGGER . missingBeanInfo ( beanConfig ) ) ; Constructor ctor = ( types . length == 0 ) ? beanInfo . getConstructor ( ) : beanInfo . findConstructor ( types ) ; ConstructorJoinpoint constructorJoinpoint = new ConstructorJoinpoint ( ctor ) ; constructorJoinpoint . setParameters ( parameters ) ; instantiateJoinpoint = constructorJoinpoint ; } return instantiateJoinpoint . dispatch ( ) ; }
Instantiate bean .