Search in sources :

Example 1 with Binder

use of org.osgl.mvc.util.Binder in project actframework by actframework.

the class ParamValueLoaderService method binder.

protected final ParamValueLoader binder(BeanSpec spec, String bindName) {
    Class rawType = spec.rawType();
    ParamValueLoader loader = null;
    {
        Bind bind = spec.getAnnotation(Bind.class);
        if (null != bind) {
            for (Class<? extends Binder> binderClass : bind.value()) {
                Binder binder = injector.get(binderClass);
                if (rawType.isAssignableFrom(binder.targetType())) {
                    loader = new BoundedValueLoader(binder, bindName);
                    break;
                }
            }
        }
    }
    if (null == loader) {
        Annotation[] aa = spec.taggedAnnotations(Bind.class);
        if (aa.length > 0) {
            for (Annotation a : aa) {
                Bind bind = AnnotationUtil.tagAnnotation(a, Bind.class);
                for (Class<? extends Binder> binderClass : bind.value()) {
                    Binder binder = injector.get(binderClass);
                    binder.attributes($.evaluate(a));
                    if (rawType.isAssignableFrom(binder.targetType())) {
                        loader = new BoundedValueLoader(binder, bindName);
                        break;
                    }
                }
            }
        }
    }
    if (null == loader) {
        Binder binder = binderManager.binder(rawType);
        if (null != binder) {
            loader = new BoundedValueLoader(binder, bindName);
        }
    }
    return loader;
}
Also used : Binder(org.osgl.mvc.util.Binder) DbBind(act.db.DbBind) Bind(org.osgl.mvc.annotation.Bind) Annotation(java.lang.annotation.Annotation)

Aggregations

DbBind (act.db.DbBind)1 Annotation (java.lang.annotation.Annotation)1 Bind (org.osgl.mvc.annotation.Bind)1 Binder (org.osgl.mvc.util.Binder)1