use of com.github.df.restypass.spring.wrapper.SpringAnnotationWrapper in project RestyPass by darren-fu.
the class RestyCommandContext method initContextForService.
/**
* 为service创建Resty配置
*
* @param serviceClz the service clz
*/
public void initContextForService(Class serviceClz) {
RestyService restyService = (RestyService) serviceClz.getDeclaredAnnotation(RestyService.class);
if (restyService == null) {
return;
}
String serviceName = restyService.serviceName();
// class->@RestyService
this.storeRestyService(serviceClz, restyService);
AsyncHttpClientConfig httpClientConfig = AsyncHttpConfigFactory.createConfig(restyService.connectTimeout(), restyService.requestTimeout());
HttpClientWrapper clientHolder = new HttpClientWrapper(httpClientConfig);
httpClientPool.putIfAbsent(serviceName, clientHolder);
SpringAnnotationWrapper wrapper = new SpringAnnotationWrapper();
RestyCommandConfig commandProperties = new RestyCommandConfig.DefaultRestyCommandConfig();
processRestyServiceAnnotation(restyService, commandProperties);
for (Method method : serviceClz.getMethods()) {
// 存储 httpMethod 和 restyCommandConfig
RestyMethod restyMethod = method.getDeclaredAnnotation(RestyMethod.class);
if (restyMethod != null) {
storeRestyMethod(method, restyMethod);
processRestyMethodAnnotation(restyMethod, commandProperties);
}
commandPropertiesMap.putIfAbsent(method, commandProperties);
// 存储 httpMethod 和 requestTemplate
RestyRequestTemplate restyRequestTemplate = wrapper.processAnnotation(serviceClz, method);
requestTemplateMap.putIfAbsent(method, restyRequestTemplate);
serviceMethodTable.put(serviceName, restyRequestTemplate.getPath(), method);
}
log.info("RestyCommandContext初始化成功!");
}
Aggregations