package com.xiaoju.manhattan.themis.rpc.command;
import cn.hutool.core.util.TypeUtil; import com.xiaoju.manhattan.financing.base.metric.util.ValidateUtil; import com.xiaoju.manhattan.themis.rpc.annotation.ThemisRpcCommandMark; import com.xiaoju.manhattan.themis.rpc.enums.RpcCommandEnum; import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; import lombok.extern.slf4j.Slf4j; import org.springframework.core.annotation.AnnotationUtils;
@Slf4j public abstract class AbstractRpcCommand<REQUEST, RESPONSE> implements RpcCommand<REQUEST, RESPONSE> {
/**
- 泛型抽取 REQUEST
*/ public final Class REQUEST_CLASS;
/**
- 泛型抽取 RESPONSE
*/ public final Class RESPONSE_CLASS;
/**
- 泛型抽取 REQUEST
*/ protected final Type REQUEST_TYPE;
/**
- 泛型抽取 RESPONSE
*/ protected final Type RESPONSE_TYPE;
{ // 请求和响应类型赋值 REQUEST_TYPE = ((ParameterizedType) getClass() .getGenericSuperclass()).getActualTypeArguments()[0]; RESPONSE_TYPE = ((ParameterizedType) getClass() .getGenericSuperclass()).getActualTypeArguments()[1]; REQUEST_CLASS = (Class) TypeUtil.getClass(REQUEST_TYPE); RESPONSE_CLASS = (Class) TypeUtil.getClass(RESPONSE_TYPE); }
}
|