用新的切入点编织外部方面 [英] Weave external aspect with new pointcut

查看:112
本文介绍了用新的切入点编织外部方面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一般来说,我对AOP还是很陌生,但是存在以下问题.

I'm pretty new to AOP in general, but I have the following problem.

我有2个项目.一个包含进行某些性能测试的方面,另一个包含与上一个相关的项目.

I have 2 projects. One containing an aspect that does some performance testing and another project which has a dependency to the previous one.

我想要实现的是将项目1的方面编织到项目2的另一个方面.这样就对项目2进行了一些性能测试.

What I'd like to achieve is weave the aspect from project 1, into another aspect of project 2. As such doing some performance testing on the aspect of project 2.

我发现Spring-AOP是不可能的,但是AspectJ的编织应该是可行的.但是,我不知道如何.

I found out it's not possible with Spring-AOP, but it should be possible with AspectJ's weaving. However, I did not figure out how.

我很确定我需要使用 aspectj-maven-plugin ,使用 AspectJ文档.但是似乎什么也没捡到?关于如何为外部方面编写额外切入点的任何指针?

Im pretty sure I need to make use of the aspectj-maven-plugin, using configuration as listed in the AspectJ documentation. But nothing seems to be picked up? Any pointers on how to write an extra pointcut for an external aspect?

推荐答案

发布相关的maven pom.xml片段是一个好主意,否则,我只能猜测您的问题:您是否指定了您的pom.xml的Aspectj-Maven-plugin配置中作为方面库 project 1 依赖项?示例取自 aspectj-maven-plugin文档,并进行了修改:

It would have been a good idea to post your relevant maven pom.xml fragments, without that, I can only have a guess at your problem: did you specify your project 1 dependency as an aspect library in your aspectj-maven-plugin configuration in your pom.xml? Example taken from the aspectj-maven-plugin documentation and modified:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>aspectj-maven-plugin</artifactId>
    <version>1.8</version>
    <configuration>
        <aspectLibraries>
            <aspectLibrary>
                <groupId>group.id.of.project.1</groupId>
                <artifactId>artifact.id.of.project.1</artifactId>
            </aspectLibrary>
        </aspectLibraries>
    </configuration>
    <executions>
        <execution>
            <goals>
                <goal>compile</goal>
            </goals>
        </execution>
    </executions>
</plugin>

您还需要对类路径的依赖,但是我想您已经拥有了.

You'll also need the dependency on your classpath too, but I guess you have that already.

这篇关于用新的切入点编织外部方面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆