我有下面的類作爲我的觀點切Spring AOP的切入點爲無
public class GenricExceptionMapper implements ExceptionMapper<Exception> {
Logger logger = Logger.getLogger(GenricExceptionMapper.class);
public Response toResponse(Exception exception) {
logger.error(exception.getStackTrace());
logger.info("Exception Thrown");
String res="500 - Internal Server Error";
exception.printStackTrace();
logger.debug("Sending Http Response :"+res);
return Response.status(500).entity(res).build();
}
}
,併爲它定義如下建議模板類...
@Aspect
public class ExceptionMapperAspect {
Logger logger = Logger.getLogger(ExceptionMapperAspect.class);
//@Context HttpServletRequest servletRequest;
@AfterReturning(pointcut="execution(* toResponse(..))")
public void logExceptionAspect()
{
//logger.info("statsKey in request object "+servletRequest.getAttribute("statsKey"));
}
,當我嘗試運行這一點,我得到下面的異常錯誤消息..
**
無法找到接口的類型參數 javax.ws.rs.ext.ExceptionMapper
** 該錯誤是由這個類的的RESTEasy代碼 http://grepcode.com/file/repo1.maven.org/maven2/org.jboss.resteasy/resteasy-jaxrs/2.2.2.GA/org/jboss/resteasy/util/Types.java#Types.getActualTypeArgumentsOfAnInterface%28java.lang.Class%2Cjava.lang.Class%29
部分拋出。
這是因爲'Spring AOP不能建議實現模板接口的切入點類'? 任何想法? Spring AOP如何爲實現參數化接口的類創建代理對象?......它使用CGLIB還是JDK代理?
我知道這個是舊的,但仍列爲未答覆。如果看起來合適,請您接受並提出我的答案嗎?謝謝。 – kriegaex