- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在寻找围绕 Mule Flow 的一个方面,IE 我想定义一个 @Around
当某些东西进入 Mule 流时就会触发它,这样我就可以执行自己的统计数据收集。我还没有找到一个简单的“Flow”类来包装,但我已经看到了 MessageReceiver
是一个好类,或者至少是这个类的实现。
但是我不是 AspectJ 方面的专家,我无法让它发挥作用。我有我的@Aspect
具有如下所示方法的类。
@Around("execution(public * org.mule.api.transport.MessageReceiver+.*(..))")
public Object addMonitor(ProceedingJoinPoint pjp) throws Throwable {
System.out.println("Before");
Object object = pjp.proceed();
System.out.println("After");
return object;
}
但是当 HttpMessageReceiver
中的方法时,我无法打印出之前/之后的字符串叫做。我在流程中设置了一个调试点,可以看到 org.mule.transport.AbstractMessageReceiver.routeMessage(MuleMessage message)
正在被调用,这是 MessageReceiver
的实现但我从来没有看到对我的守护者的调用。
是否可以在 Mule 中执行此类 Aspect?
//编辑:如前所述,我是 AspectJ 和 AOP 的新手,所以我会说我在 Mule 中使用 spring 来处理我的 @Aspect
类(class)。我有关于 Spring 处理的 bean 的示例,但不适用于不由 spring 管理的常规 POJO。我的 Spring 配置如下:
<spring:beans>
<context:component-scan base-package="com.example" />
<context:annotation-config />
<aop:aspectj-autoproxy />
</spring:beans>
最佳答案
我需要加载时编织,所以我必须为aspectjweaver和spring-instrument添加-javaagent
,并添加一个META-INF/aop.xml
链接到我的 @Aspect
类,但是一旦我这样做了,我就可以做 @Around("call(* org.mule.api.transport.MessageReceiver.routeMessage(org .mule.api.MuleMessage))")
获取 Mule 的调用。
关于Mule MessageReceiver 周围的 AspectJ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15910422/
我的问题与 Spring 的 AspectJ 模式有关,特别是如何启用它: 交易管理 缓存 1)我注意到,为了启用 AspectJ 模式进行事务管理,我只需执行以下操作: @Configuration
当我尝试使用 Java 17 运行 AspectJ 检测时,我总是会遇到如下错误: java.lang.reflect.InvocationTargetException at jav
我有一个应该记录的跟踪方面: 进入 退出(返回类型为 void) 返回[返回对象] 抛出[异常消息] 我对第二个有问题。我如何在不重复记录所有退出的情况下为这种情况创建建议,就像现在我有一个 @Aft
我已经使用 @Aspect 注释声明了我的切面,但建议似乎没有得到应用。该方面适用于我拥有的其他一些项目,主要区别似乎是其他项目完全使用注释连接,并且这个特定项目是 xml 连接的。唯一连接注释的 b
我正在尝试使用加载时编织将 perf4j 绑定(bind)到程序中,但它似乎在我的类路径中找不到 aop.xml。要么是这样,要么它没有编织这个方面,因为它没有找到它。我已启用 aop.xml 的详细
我是 spring 框架的新手,正在尝试一些示例来理解 AOP,这是我到目前为止所做的,但它不起作用。 问题是我一添加 对于 spring.xml,我的构建失败说无法创建具有空指针异常的 bean。但
我尝试使用 AspectJ 围绕 Kotlin 函数编织方面,但没有成功。也许我只是配置不正确,或者 AspectJ 不支持这个。 有谁知道这是否可以使用例如 maven 和 Eclipse(或 In
我正在使用 Eclipse 4 和 AspectJ 的最新版本进行开发。我正在用修改后的库(二进制编织)替换 Java 6 库。问题是当前正在编织的代码是 Java 7 代码,而我需要它是 Java
我正在将我的项目从 java 7 迁移到 java 8,我遇到的问题与使用 aspectj-maven-plugin 的 aspectj 编织有关。 我可以根据 Haus documentation
嘿,我想将 AOP 添加到我的 Web 项目中。我下载了 eclipse 3.4.1 的 ajdt2.0.1。但是当我将此项目转换为 AspectJ 项目时,出现了很多不应该发生的编译错误。比如“XX
我最近在我的 Windows 7 机器上从 eclipse Juno 升级到 Luna,我的 aspectj 编译出现问题。我收到此错误: [ERROR] Failed to execute goal
我想创建一个注释,它使用环绕方面来使用该注释清理参数。 例如,一个方法可能如下所示: public void setName(@Scrubbed String name) { ... } 也许 pub
我无法理解aspectJ的编译时和加载时编织,也无法弄清楚使用什么(以及如何使用ajc)来编译和构建我的项目。 这是我的项目结构:- TestProject:一个java服务库。这正被其他一些人使
我想拦截给定类的任何子类的非注释方法的执行。 例如,假设我有类 Base: public class Base { public void baseMethod() { //shouldn't
我正在尝试使用 AspectJ 和运行时编织。我创建了一个方面 @Aspect(value = "TraceAspect") public class TraceAspect { @Arou
我只是像下面描述的那样实现了AspectJ:https://stackoverflow.com/a/10998044/2182503 此解决方案工作正常,直到我注意到@Autowired中的@Init
我正在使用 AspectJ 来建议所有具有所选类参数的公共(public)方法。我尝试了以下方法: pointcut permissionCheckMethods(Session sess) :
我正在尝试创建一个 AspectJ Aspect 来拦截具有通用接口(interface)的返回方法。 这是我的 AspectJ @AspectJ public class MyAspect {
使用 Aspect annotation 创建方面时如所述 here ,是否可以将此注释与包含状态的类一起使用(例如,一旦命中切入点,成员变量就会发生变化)?或者换句话说:方面类是单例吗?注释的源代码
当我尝试使用 Roo 创建的 JPA 对象时出现此错误。 Entity manager has not been injected (is the Spring Aspects JAR configu
我是一名优秀的程序员,十分优秀!