class AsyncInitBeanFactoryPostProcessor implements BeanFactoryPostProcessor,
                                              EnvironmentAware {

    private static final Logger              LOGGER = SofaBootLoggerFactory
                                                        .getLogger(AsyncInitBeanFactoryPostProcessor.class);

    private AnnotationWrapper<SofaAsyncInit> annotationWrapper;

    @Override
    public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
        Arrays.stream(beanFactory.getBeanDefinitionNames())
                .collect(Collectors.toMap(Function.identity(), beanFactory::getBeanDefinition))
                .forEach(this::scanAsyncInitBeanDefinition);
    }

    /**
     * {@link ScannedGenericBeanDefinition}
     * {@link AnnotatedGenericBeanDefinition}
     * {@link GenericBeanDefinition}
     * {@link org.springframework.beans.factory.support.ChildBeanDefinition}
     * {@link org.springframework.beans.factory.support.RootBeanDefinition}
     */
    private void scanAsyncInitBeanDefinition(String beanId, BeanDefinition beanDefinition) {
        if (BeanDefinitionUtil.isFromConfigurationSource(beanDefinition)) {
            scanAsyncInitBeanDefinitionOnMethod(beanId, (AnnotatedBeanDefinition) beanDefinition);
        } else {
            Class<?> beanClassType = BeanDefinitionUtil.resolveBeanClassType(beanDefinition);
            if (beanClassType == null) {
                return;
            }
            scanAsyncInitBeanDefinitionOnClass(beanClassType, beanDefinition);
        }
    }

    private void scanAsyncInitBeanDefinitionOnMethod(String beanId,
                                                     AnnotatedBeanDefinition beanDefinition) {<FILL_FUNCTION_BODY>}

    private void scanAsyncInitBeanDefinitionOnClass(Class<?> beanClass,
                                                    BeanDefinition beanDefinition) {
        // See issue: https://github.com/sofastack/sofa-boot/issues/835
        SofaAsyncInit sofaAsyncInitAnnotation = AnnotationUtils.findAnnotation(beanClass,
            SofaAsyncInit.class);
        registerAsyncInitBean(sofaAsyncInitAnnotation, beanDefinition);
    }

    @SuppressWarnings("unchecked")
    private void registerAsyncInitBean(SofaAsyncInit sofaAsyncInitAnnotation,
                                       BeanDefinition beanDefinition) {
        if (sofaAsyncInitAnnotation == null) {
            return;
        }

        sofaAsyncInitAnnotation = annotationWrapper.wrap(sofaAsyncInitAnnotation);

        String initMethodName = beanDefinition.getInitMethodName();
        if (sofaAsyncInitAnnotation.value() && StringUtils.hasText(initMethodName)) {
            beanDefinition.setAttribute(ASYNC_INIT_METHOD_NAME, initMethodName);
        }
    }

    @Override
    public void setEnvironment(Environment environment) {
        this.annotationWrapper = AnnotationWrapper.create(SofaAsyncInit.class)
            .withEnvironment(environment).withBinder(DefaultPlaceHolderBinder.INSTANCE);
    }
}

        Class<?> returnType;
        Class<?> declaringClass;
        List<Method> candidateMethods = new ArrayList<>();

        MethodMetadata methodMetadata = beanDefinition.getFactoryMethodMetadata();
        try {
            returnType = ClassUtils.forName(methodMetadata.getReturnTypeName(), null);
            declaringClass = ClassUtils.forName(methodMetadata.getDeclaringClassName(), null);
        } catch (Throwable throwable) {
            // it's impossible to catch throwable here
            LOGGER.error(ErrorCode.convert("01-02001", beanId), throwable);
            return;
        }
        if (methodMetadata instanceof StandardMethodMetadata) {
            candidateMethods.add(((StandardMethodMetadata) methodMetadata).getIntrospectedMethod());
        } else {
            for (Method m : declaringClass.getDeclaredMethods()) {
                // check methodName and return type
                if (!m.getName().equals(methodMetadata.getMethodName())
                    || !m.getReturnType().getTypeName().equals(methodMetadata.getReturnTypeName())) {
                    continue;
                }

                // check bean method
                if (!AnnotatedElementUtils.hasAnnotation(m, Bean.class)) {
                    continue;
                }

                Bean bean = m.getAnnotation(Bean.class);
                Set<String> beanNames = new HashSet<>();
                beanNames.add(m.getName());
                if (bean != null) {
                    beanNames.addAll(Arrays.asList(bean.name()));
                    beanNames.addAll(Arrays.asList(bean.value()));
                }

                // check bean name
                if (!beanNames.contains(beanId)) {
                    continue;
                }

                candidateMethods.add(m);
            }
        }

        if (candidateMethods.size() == 1) {
            SofaAsyncInit sofaAsyncInitAnnotation = candidateMethods.get(0).getAnnotation(
                SofaAsyncInit.class);
            if (sofaAsyncInitAnnotation == null) {
                sofaAsyncInitAnnotation = returnType.getAnnotation(SofaAsyncInit.class);
            }
            registerAsyncInitBean(sofaAsyncInitAnnotation, beanDefinition);
        } else if (candidateMethods.size() > 1) {
            for (Method m : candidateMethods) {
                if (AnnotatedElementUtils.hasAnnotation(m, SofaAsyncInit.class)
                    || AnnotatedElementUtils.hasAnnotation(returnType, SofaAsyncInit.class)) {
                    throw new FatalBeanException(ErrorCode.convert("01-02002",
                        declaringClass.getCanonicalName()));
                }
            }
        }
    
<no_super_class>