use of org.osgl.mvc.annotation.Param in project actframework by actframework.
the class ActionContextParamLoader method findContextSpecificLoader.
@Override
protected ParamValueLoader findContextSpecificLoader(String bindName, BeanSpec spec) {
HeaderVariable headerVariable = spec.getAnnotation(HeaderVariable.class);
if (null != headerVariable) {
return new HeaderValueLoader(headerVariable.value(), spec);
}
SessionVariable sessionVariable = spec.getAnnotation(SessionVariable.class);
if (null != sessionVariable) {
return new SessionValueLoader(sessionVariable.value(), spec);
}
if (spec.hasAnnotation(PartialPath.class)) {
return new PartialPathLoader(bindName);
}
DefaultValue def = spec.getAnnotation(DefaultValue.class);
Class<?> rawType = spec.rawType();
ParamValueLoader loader = binder(spec, bindName);
if (null == loader) {
Resolve resolve = spec.getAnnotation(Resolve.class);
if (null != resolve) {
Class<? extends StringValueResolver>[] resolvers = resolve.value();
for (Class<? extends StringValueResolver> resolverClass : resolvers) {
StringValueResolver resolver = injector.get(resolverClass);
if (rawType.isAssignableFrom(resolver.targetType())) {
loader = new StringValueResolverValueLoader(ParamKey.of(bindName), resolver, null, def, rawType);
}
}
}
}
if (null == loader) {
Annotation[] aa = spec.allAnnotations();
for (Annotation a : aa) {
Resolve resolve = AnnotationUtil.tagAnnotation(a, Resolve.class);
if (null != resolve) {
Class<? extends StringValueResolver>[] resolvers = resolve.value();
for (Class<? extends StringValueResolver> resolverClass : resolvers) {
StringValueResolver resolver = injector.get(resolverClass);
resolver.attributes($.evaluate(a));
if (rawType.isAssignableFrom(resolver.targetType())) {
loader = new StringValueResolverValueLoader(ParamKey.of(bindName), resolver, null, def, rawType);
break;
}
}
}
}
}
if (null == loader) {
StringValueResolver resolver = null;
Param param = spec.getAnnotation(Param.class);
if (null != param) {
Class<? extends StringValueResolver> resolverClass = param.resolverClass();
if (Param.DEFAULT_RESOLVER.class != resolverClass) {
resolver = injector.get(resolverClass);
}
}
if (null == resolver) {
resolver = resolverManager.resolver(rawType, spec);
}
loader = (null != resolver) ? new StringValueResolverValueLoader(ParamKey.of(bindName), resolver, param, def, rawType) : buildLoader(ParamKey.of(bindName), spec);
}
return loader;
}
use of org.osgl.mvc.annotation.Param 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;
}
Aggregations