use of org.osgl.mvc.annotation.Resolve 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.Resolve in project actframework by actframework.
the class CliContextParamLoader method findIndirectAnnotatedResolver.
private StringValueResolver findIndirectAnnotatedResolver(BeanSpec spec) {
Annotation[] aa = spec.allAnnotations();
Class<?> rawType = spec.rawType();
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())) {
return resolver;
}
}
}
}
return null;
}
use of org.osgl.mvc.annotation.Resolve in project actframework by actframework.
the class CliContextParamLoader method findDirectAnnotatedResolver.
private StringValueResolver findDirectAnnotatedResolver(BeanSpec spec) {
Resolve resolve = spec.getAnnotation(Resolve.class);
Class<?> rawType = spec.rawType();
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())) {
return resolver;
}
}
}
return null;
}
Aggregations