1
我試圖實現spring AOP @Before。 這裏是方法如何在驗證失敗之前從AOP返回
@Before("execution(* com.dummy.pkg..*.*(..))")
public Response<Object> beforeServiceAspect(JoinPoint joinPoint) throws Exception {
Object[] signatureArgs = joinPoint.getArgs();
String sessionId=(String) signatureArgs[0];
if(null==sessionId||sessionId.isEmpty()||!loginService.getUserInfo(sessionId))
{
Response.setStatusCode("401");
Response.setC
Response.setResultString("Unauthorized User");
return Response;
//this is where i want to return in case of program enter here
//**point 1**
}
//**point 2** where execution reaches then resume normal flow
return "";
}
下面是兩招我wanat實現
- 如果流量達到1點,然後從那個時候itself.It不應該走得更遠,調用應該返回後返回。
- 如果流量達到點2,它將恢復正常流量並調用內部方法。 現在發生的事情是在這兩種情況下,它流動正常流量並不斷調用內部方法。