Search in sources :

Example 1 with IocBean

use of org.nutz.ioc.loader.annotation.IocBean in project nutz by nutzam.

the class Loadings method evalModule.

public static void evalModule(ActionInfo ai, Class<?> type) {
    ai.setModuleType(type);
    String beanName = null;
    // 按照5.10.3章节的说明,优先使用IocBean.name的注解声明bean的名字 Modify By QinerG@gmai.com
    InjectName innm = Mirror.getAnnotationDeep(type, InjectName.class);
    IocBean iocBean = Mirror.getAnnotationDeep(type, IocBean.class);
    if (// TODO 再考虑考虑
    innm == null && iocBean == null)
        return;
    if (iocBean != null) {
        beanName = iocBean.name();
    }
    if (Strings.isBlank(beanName)) {
        if (innm != null && !Strings.isBlank(innm.value())) {
            beanName = innm.value();
        } else {
            beanName = Strings.lowerFirst(type.getSimpleName());
        }
    }
    ai.setInjectName(beanName);
}
Also used : InjectName(org.nutz.ioc.annotation.InjectName) IocBean(org.nutz.ioc.loader.annotation.IocBean)

Example 2 with IocBean

use of org.nutz.ioc.loader.annotation.IocBean in project nutz by nutzam.

the class NutIoc method get.

public <T> T get(Class<T> type) throws IocException {
    InjectName inm = type.getAnnotation(InjectName.class);
    if (null != inm && (!Strings.isBlank(inm.value())))
        return get(type, inm.value());
    IocBean iocBean = type.getAnnotation(IocBean.class);
    if (iocBean != null && (!Strings.isBlank(iocBean.name())))
        return get(type, iocBean.name());
    return get(type, Strings.lowerFirst(type.getSimpleName()));
}
Also used : InjectName(org.nutz.ioc.annotation.InjectName) IocBean(org.nutz.ioc.loader.annotation.IocBean)

Aggregations

InjectName (org.nutz.ioc.annotation.InjectName)2 IocBean (org.nutz.ioc.loader.annotation.IocBean)2