我正在开发一个简单的Jersey Restful网络服务;此Web服务需要使用Messagepack请求并生成MessagePack响应。
现在我正在使用" application / octet-stream"在byte []中读取MessagePack消息并转换为Entity bean&反之亦然。但是我正在寻找类似MediaType.APPLICATION_MSGPK的东西,它可以在引擎盖下进行这种转换并节省处理时间。
@POST
@Path("/msgpk")
@Consumes("application/octet-stream")
@Produces("application/octet-stream")
public byte[] predictFlightAvailabilityForMsgPack(byte[] predictionRequestBiteStream) {
PredictionRequest request = null;
PredictionResponse response = null;
byte[] responsebytes = null;
MessagePack msgpack = new MessagePack();
try {
// here I am manually converting the byte[] steam to Entity bean
request = msgpack.read(predictionRequestBiteStream, PredictionRequest.class);
if (request != null) {
response = dispatchRequest(request);
// here manually converting the Entity bean to byte[]
responsebytes = msgpack.write(response);
}
} catch (IOException e) {
e.printStackTrace();
}
return responsebytes;
}
我一直在寻找解决方案;但找不到任何商品。