标签:jackson 文件 ext util new ntc turn gem ica
public class ExportVehMileageClients extends RestfulWSClient<ServiceResponse>{ private static final Logger LOG=Logger.getLogger(ExportVehMileagesClient.class); private static final String WSURL=GET_EXPORTVEHMILEAGES_URL; private static final String TYPE=APPLICATION_JSON; private static final String ACCEPT=APPLICATION_JSON; private static final JacksonJsonProvider PROVIDER=new JacksonJsonProvider(); public ExportVehMileageClient(){ super(WSURL,TYPE,ACCEPT,PROVIDER); } public List<VehicleModel> export(ExportVehMileageModel EVMModel) throws WSException{ try{ LOG.info("ExportVehMileages Institution"); ServiceResponse resp=this.excutePost(EVMModel,ServiceResponse.class); if(resp.getHead().getStatus==SERVICE_SUCCESS){ String body=resp.getBody(); if(!StringUtils.isEmpty(body)){ return tolist(body); }else{return null;} }else{ throw new WSException("ExportVehMileages Failure"); } }catch(WSException e){throw new WSException("ExportVehMileages Failure",e);} } private List<VehicleModel> tolist(String str) throws WSException{ ObjectMapper om=new ObjectMapper(); try{ JavaType javaType=getCollectionType(om,ArrayList.class,VehicleModel.class); return om.readValue(str,javaType); }catch(Exception e){ LOG.error("Failed to ExportVehMileages object from json response:"+str,e); throw new WSException("Failed to ExportVehMileage",e); } } private JavaType getCollectionType(ObjectMapper mapper,Class<?> collectionClass ,Class<?>... elementClasses){ return mapper.getTypeFactory().constructParametricType(collectionClass,elementClasses); } }
标签:jackson 文件 ext util new ntc turn gem ica
原文地址:http://www.cnblogs.com/shen199103/p/7096677.html