`
liyixing1
  • 浏览: 953166 次
  • 性别: Icon_minigender_1
  • 来自: 江西上饶
社区版块
存档分类
最新评论

Couldn't access current invocation

 
阅读更多
做了一个aop的日志记录器,但是在运行的时候出现了日志信息
服务器运行时间:577375 线程名:[http-8080-2]
日志位置:org.springframework.aop.aspectj.AspectJExpressionPointcut.matches(AspectJExpressionPointcut.java:292)
记录器logger名称:org.springframework.aop.aspectj.AspectJExpressionPointcut
日志等级:DEBUG
发生时间:2011-10-20 20:37:04
日志内容:Couldn't access current invocation - matching with limited context: java.lang.IllegalStateException: No MethodInvocation found: Check that an AOP invocation is in progress, and that the ExposeInvocationInterceptor is in the interceptor chain.
看起来还是调试级别的。不晓得具体原因。去查看源代码

public boolean matches(Method method, Class targetClass, Object[] args) {
checkReadyToMatch();
ShadowMatch shadowMatch = getShadowMatch(AopUtils.getMostSpecificMethod(method, targetClass), method);
ShadowMatch originalShadowMatch = getShadowMatch(method, method);

// Bind Spring AOP proxy to AspectJ "this" and Spring AOP target to AspectJ target,
// consistent with return of MethodInvocationProceedingJoinPoint
ProxyMethodInvocation pmi = null;
Object targetObject = null;
Object thisObject = null;
try {
//这里抛出的异常。ExposeInvocationInterceptor.currentInvocation();方法是从当前线程取出已经运行中的代理aop调用者。如果不存在,就抛出异常。这里不晓得spring为何设计为异常,而不是return null
MethodInvocation mi = ExposeInvocationInterceptor.currentInvocation();
targetObject = mi.getThis();
if (!(mi instanceof ProxyMethodInvocation)) {
throw new IllegalStateException("MethodInvocation is not a Spring ProxyMethodInvocation: " + mi);
}
pmi = (ProxyMethodInvocation) mi;
thisObject = pmi.getProxy();
}
catch (IllegalStateException ex) {
//从这里的解释大概能看出来如果不存在调用实例,可能就会去生成一个新的实例。
// No current invocation...
// TODO: Should we really proceed here?
logger.debug("Couldn't access current invocation - matching with limited context: " + ex);
}

JoinPointMatch joinPointMatch = shadowMatch.matchesJoinPoint(thisObject, targetObject, args);

/*
* Do a final check to see if any this(TYPE) kind of residue match. For
* this purpose, we use the original method's (proxy method's) shadow to
* ensure that 'this' is correctly checked against. Without this check,
* we get incorrect match on this(TYPE) where TYPE matches the target
* type but not 'this' (as would be the case of JDK dynamic proxies).
* <p>See SPR-2979 for the original bug.
*/
//存在实例就直接使用这个实例来验证。
if (pmi != null) {  // there is a current invocation
RuntimeTestWalker originalMethodResidueTest = new RuntimeTestWalker(originalShadowMatch);
if (!originalMethodResidueTest.testThisInstanceOfResidue(thisObject.getClass())) {
return false;
}
}


if (joinPointMatch.matches() && pmi != null) {
bindParameters(pmi, joinPointMatch);
}

//不存在就return joinPointMatch.matches();这个是aspect的实现。用来查找匹配的。如果有匹配的aop方法,就return true。当return true,spring就会调用组合后的处理方法,也就是通过org.aopalliance.intercept.MethodInterceptor来调用,这里的MethodInterceptor就是代理类中加入的新的代码。如果不存在就直接return proceed()了。
return joinPointMatch.matches();
}
分享到:
评论

相关推荐

    axis2 InvocationTargetException

    标题 "axis2 InvocationTargetException" 描述的是一个与Apache Axis2框架相关的编程问题,该问题通常在执行服务调用时出现,提示"InvocationTargetException"。这可能是由于多种原因引起的,包括但不限于错误的服务...

    解决axis2-CodegenWizardPluginBUG- java.lang.reflect.InvocationTargetException

    标题中的“解决axis2-CodegenWizardPluginBUG- java.lang.reflect.InvocationTargetException”指的是在使用Apache Axis2的CodegenWizardPlugin工具时遇到的一个错误。这个工具是Axis2框架的一部分,用于自动生成...

    rmijsbc和access数据引擎.zip

    在这个压缩包中,"rmijdbc-3.3.jar"就是这样一个关键组件,它提供了Java Remote Method Invocation (RMI) 和 JDBC(Java Database Connectivity)之间的桥梁。RMIJDBC是一个允许Java应用程序通过RMI调用远程JDBC服务...

    RMI代码 remote method invocation

    远程方法调用(Remote Method Invocation,RMI)是Java平台中一种用于分布式计算的技术,它允许Java对象在不同的 JVM(Java虚拟机)之间调用方法,仿佛这些对象都在同一个JVM中一样。RMI是Java EE(现在被称为...

    CL_Invocation.ps1

    CL_Invocation.ps1

    MyEclipse6.0下axis2插件的安装-java.lang.reflect.InvocationTargetException

    ### MyEclipse 6.0 下 Axis2 插件的安装及解决 java.lang.reflect.InvocationTargetException #### 一、概述 在使用 MyEclipse 6.0 进行 Web 服务开发时,可能会遇到需要安装 Axis2 插件的情况。Axis2 是 Apache ...

    MyEclipse axis2 wsdl java.lang.reflect.invocationtargetexception

    MyEclipse axis2 wsdl java.lang.reflect.invocationtargetexception code gen 大家要注意一定要仔细,这个问题基本上缺少包引起的,而且一定要clean 如果需要axis2插件 以及这个plugins中的包在我的其他资源里面有

    access数据库jdbc驱动文件

    RMI(Remote Method Invocation)是Java中的一种机制,用于在分布式环境中调用对象的方法。RmiJdbc可能是实现了RMI接口的JDBC驱动,使得远程的Java应用能够通过RMI调用方法来操作Access数据库。 在实际应用中,使用...

    webservice 调 odiodi-sdk-invocation.jar

    odi-sdk-invocation.jar

    解决Ajax方式上传文件报错"Uncaught TypeError: Illegal invocation"

    然而,开发者在实现这一功能时可能会遇到一些错误,如"Uncaught TypeError: Illegal invocation"。这个错误通常出现在尝试使用Ajax发送文件数据时,由于不正确的数据处理或内容类型设置导致的。 Ajax上传文件的核心...

    JQuery报错Uncaught TypeError: Illegal invocation的处理方法

    然而,在使用jQuery过程中,开发者有时会遇到JavaScript控制台抛出“Uncaught TypeError: Illegal invocation”错误。这个错误通常不是由jQuery自身引起的,而是与JavaScript作用域及上下文有关。 当我们进行Ajax...

    invocation-chain-monitor:RPC调用链监控

    "invocation-chain-monitor"项目可能就是这样一个专为Java环境设计的RPC调用链监控解决方案。 RPC调用链监控的核心功能包括: 1. **请求跟踪**:记录每个RPC调用的开始和结束时间,以及调用的具体方法、参数等信息...

    RMI 简单示例-Java Remote Methods Invocation

    Java Remote Method Invocation(RMI)是Java平台提供的一种用于在分布式环境中进行对象间通信的技术。RMI允许一个Java对象在某台计算机上执行其方法,而这个对象实际上存在于另一台计算机上。这种技术使得开发者...

    axis2(1.4.1) eclipse plugin 解决InvocationTargetException问题

    在apache上下载的axis2的eclipse插件,使用axis2-eclipse-codegen-wizard时,最后老是报InvocationTargetException异常。 现在上传的版本已经修正,和原版功能完全一样

    Remote Method Invocation-远程方法调用

    ### Remote Method Invocation (RMI) – 远程方法调用详解 #### 一、RMI 概述 **远程方法调用**(Remote Method Invocation, RMI)是Java平台中的一个核心概念和技术,它允许开发者创建分布式应用,在这些应用中,...

    jdk20-java-remote-method-invocation-api-guide.pdf

    jdk20-java-remote-method-invocation-api-guide Java Platform, Standard Edition 的 Java Remote Method Invocation API Guide 介绍了 Java Remote Method Invocation(Java RMI)的概念和应用。Java RMI 是一种...

    JDK10-JSE,Java Remote Method Invocation API Guide-2.pdf

    Java Remote Method Invocation API Guide Java Remote Method Invocation(Java RMI)是一种允许分布式应用程序在Java平台上运行的技术。它允许在不同的Java虚拟机(JVM)上运行的对象之间调用方法,从而实现...

Global site tag (gtag.js) - Google Analytics