我正在使用 Spring MVC + AspectJ
@控制器
@RequestMapping(method = RequestMethod.GET, value = "/testLogger")
@TrxLogger
public String testLogger (
@RequestParam(value = "optimumid", required = false) String optimumid,
@RequestParam(value = "system", required = false) String system,
@RequestParam(value = "accountnumber", required = false) String accountnumber,
@RequestParam(value = "csrid", required = false) String csrid,
@RequestParam(value = "paymentAccountNumber", required = false) String paymentAccountNumber,
@RequestParam(value = "dummyData", required = false) String dummyData,
@UserSession Optional<Session> session,
HttpServletRequest request) throws Exception {
long nStartRequest = (new java.util.Date()).getTime();
String response = null;
GlobalStatus status = new GlobalStatus();
try {
response = billPayService.testLogger(optimumid, system, accountnumber, csrid, paymentAccountNumber, dummyData);
status.setStatusCode("OK");
status.setStatusDesc("SUCCESS");
}catch (Exception e) {
response = "BillPayController.testLogger() FAILED!";
status.setStatusCode("ERROR");
status.setStatusDesc("FAILURE");
}
long nEndRequest = (new java.util.Date()).getTime();
return response ;
}
@方面
@Around("pcTrxLogger()")
public Object logMethodCall(ProceedingJoinPoint joinPoint) throws Throwable {
...
...
return null;
}
return response;
我可以使用ProceedingJoinPoint轻松获得所有参数和 response( ),但我无法获得以下变量和对象。
- long nStartRequest = (new java.util.Date()).getTime();
- GlobalStatus 状态 = 新的 GlobalStatus();
- long nEndRequest = (new java.util.Date()).getTime();
我们如何在 aspect( logMethodCall()
) 中获取这些变量和对象?