Search in sources :

Example 1 with Bind

use of org.osgl.mvc.annotation.Bind in project actframework by actframework.

the class ParamValueLoaderService method tryFindBindName.

static String tryFindBindName(Annotation[] annotations, String defVal) {
    Param param = filter(annotations, Param.class);
    if (null != param && S.notBlank(param.value())) {
        return param.value();
    }
    Bind bind = filter(annotations, Bind.class);
    if (null != bind && S.notBlank(bind.model())) {
        return bind.model();
    }
    Named named = filter(annotations, Named.class);
    if (null != named && S.notBlank(named.value())) {
        return named.value();
    }
    if (S.notBlank(defVal)) {
        return defVal;
    }
    return null;
}
Also used : Named(javax.inject.Named) DbBind(act.db.DbBind) Bind(org.osgl.mvc.annotation.Bind) Param(org.osgl.mvc.annotation.Param)

Example 2 with Bind

use of org.osgl.mvc.annotation.Bind 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)2 Bind (org.osgl.mvc.annotation.Bind)2 Annotation (java.lang.annotation.Annotation)1 Named (javax.inject.Named)1 Param (org.osgl.mvc.annotation.Param)1 Binder (org.osgl.mvc.util.Binder)1