Search in sources :

Example 1 with DefaultViewMaker

use of org.nutz.mvc.view.DefaultViewMaker in project nutz by nutzam.

the class NutLoading method createViewMakers.

protected ViewMaker[] createViewMakers(Class<?> mainModule, Ioc ioc) throws Exception {
    Views vms = mainModule.getAnnotation(Views.class);
    List<ViewMaker> makers = new ArrayList<ViewMaker>();
    if (null != vms) {
        for (int i = 0; i < vms.value().length; i++) {
            if (vms.value()[i].getAnnotation(IocBean.class) != null && ioc != null) {
                makers.add(ioc.get(vms.value()[i]));
            } else {
                makers.add(Mirror.me(vms.value()[i]).born());
            }
        }
    } else {
        if (ioc != null) {
            String[] names = ioc.getNames();
            Arrays.sort(names);
            for (String name : ioc.getNames()) {
                if (name != null && name.startsWith(ViewMaker.IOCNAME)) {
                    log.debug("add ViewMaker from Ioc by name=" + name);
                    makers.add(ioc.get(ViewMaker.class, name));
                }
            }
        }
    }
    // 优先使用用户自定义
    makers.add(new DefaultViewMaker());
    if (log.isDebugEnabled()) {
        StringBuilder sb = new StringBuilder();
        for (ViewMaker maker : makers) {
            sb.append(maker.getClass().getSimpleName()).append(".class,");
        }
        sb.setLength(sb.length() - 1);
        log.debugf("@Views(%s)", sb);
    }
    return makers.toArray(new ViewMaker[makers.size()]);
}
Also used : Views(org.nutz.mvc.annotation.Views) DefaultViewMaker(org.nutz.mvc.view.DefaultViewMaker) ViewMaker(org.nutz.mvc.ViewMaker) ArrayList(java.util.ArrayList) DefaultViewMaker(org.nutz.mvc.view.DefaultViewMaker)

Aggregations

ArrayList (java.util.ArrayList)1 ViewMaker (org.nutz.mvc.ViewMaker)1 Views (org.nutz.mvc.annotation.Views)1 DefaultViewMaker (org.nutz.mvc.view.DefaultViewMaker)1