1
我想用Aspect
使用Around建議將時間戳添加到javax.ws.rs.core.Response
。將數據添加到澤西島的響應對象
我是新來的Java和澤西島,我努力做到這一點。我最接近的是這樣的:
Object output = proceed();
Method method = ((MethodSignature) thisJoinPoint.getSignature()).getMethod();
Type type = method.getGenericReturnType();
if (type == Response.class)
{
System.out.println("We have a response!");
Response original = (Response) output;
output = (Object)Response.ok(original.getEntity(String.class).toString()+ " " + Double.toString(duration)).build();
}
return output;
那種產生響應的始終是一個application/JSON
。基本上我想向JSON添加另一個字段,字段爲time:<val of duration>
。