io.jboot.service.JbootServiceBase Java Examples

The following examples show how to use io.jboot.service.JbootServiceBase. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JbootAopFactory.java    From jboot with Apache License 2.0 4 votes vote down vote up
@Override
protected void doInject(Class<?> targetClass, Object targetObject) throws ReflectiveOperationException {
    targetClass = getUsefulClass(targetClass);
    Field[] fields = targetClass.getDeclaredFields();

    if (fields.length != 0) {

        for (Field field : fields) {

            Inject inject = field.getAnnotation(Inject.class);
            if (inject != null) {
                Bean bean = field.getAnnotation(Bean.class);
                String beanName = bean != null ? AnnotationUtil.get(bean.name()) : null;
                if (StrUtil.isNotBlank(beanName)) {
                    doInjectByName(targetObject, field, inject, beanName);
                } else {
                    doInjectJFinalOrginal(targetObject, field, inject);
                }
                continue;
            }

            ConfigValue configValue = field.getAnnotation(ConfigValue.class);
            if (configValue != null) {
                doInjectConfigValue(targetObject, field, configValue);
                continue;
            }

            RPCInject rpcInject = field.getAnnotation(RPCInject.class);
            if (rpcInject != null) {
                doInjectRPC(targetObject, field, rpcInject);
                continue;
            }
        }
    }


    // 是否对超类进行注入
    if (injectSuperClass) {
        Class<?> c = targetClass.getSuperclass();
        if (c != JbootController.class
                && c != Controller.class
                && c != JbootServiceBase.class
                && c != Object.class
                && c != JbootModel.class
                && c != Model.class
                && c != null
        ) {
            doInject(c, targetObject);
        }
    }
}