Search in sources :

Example 1 with FastJsonPropertyPreFilter

use of act.util.FastJsonPropertyPreFilter in project actframework by actframework.

the class Endpoint method explore.

private void explore(RequestHandler handler) {
    RequestHandlerProxy proxy = $.cast(handler);
    ReflectedHandlerInvoker invoker = $.cast(proxy.actionHandler().invoker());
    Class<?> controllerClass = invoker.controllerClass();
    Method method = invoker.method();
    returnType = method.getReturnType();
    PropertySpec pspec = method.getAnnotation(PropertySpec.class);
    if (null != pspec) {
        PropertySpec.MetaInfo propSpec = new PropertySpec.MetaInfo();
        for (String v : pspec.value()) {
            propSpec.onValue(v);
        }
        for (String v : pspec.http()) {
            propSpec.onValue(v);
        }
        List<String> outputs = propSpec.outputFieldsForHttp();
        Set<String> excluded = propSpec.excludeFieldsForHttp();
        if (!(outputs.isEmpty() && excluded.isEmpty())) {
            fastJsonPropertyPreFilter = new FastJsonPropertyPreFilter(returnType, outputs, excluded, Act.app().service(DataPropertyRepository.class));
        }
    // just ignore cli value here
    }
    this.id = id(method);
    returnSample = generateSampleJson(BeanSpec.of(method.getGenericReturnType(), null, Act.injector()));
    Description descAnno = method.getAnnotation(Description.class);
    this.description = null == descAnno ? methodDescription(method) : descAnno.value();
    exploreParamInfo(method);
    if (!Modifier.isStatic(method.getModifiers())) {
        exploreParamInfo(controllerClass);
    }
    this.controllerClass = controllerClass;
}
Also used : ReflectedHandlerInvoker(act.handler.builtin.controller.impl.ReflectedHandlerInvoker) PropertySpec(act.util.PropertySpec) RequestHandlerProxy(act.handler.builtin.controller.RequestHandlerProxy) FastJsonPropertyPreFilter(act.util.FastJsonPropertyPreFilter)

Aggregations

RequestHandlerProxy (act.handler.builtin.controller.RequestHandlerProxy)1 ReflectedHandlerInvoker (act.handler.builtin.controller.impl.ReflectedHandlerInvoker)1 FastJsonPropertyPreFilter (act.util.FastJsonPropertyPreFilter)1 PropertySpec (act.util.PropertySpec)1