aspectj

How do you configure aspectj maven plugin to use Java 7?

大兔子大兔子 提交于 2019-11-30 13:30:39
What are the appropriate configuration/versions/plugin versions for the aspectj plugin to use Java 7? I am trying to upgrade from Java 6 to Java 7, and the aspectj compiler seems to not be compiling Java 7. I'm specifying the java source and target version as 1.7 in the plugin configuration for aspectj plugin and for the maven compiler plugin. I introduced Java7-specific syntax to my code, adding several language features such as string in switch and the diamond operator. During the build, I get errors from aspectj about the Java7 syntax. The first sign that things are going wrong is: [INFO] -

Running AspectJ causes NoSuchMethodError: Aspect.aspectOf

和自甴很熟 提交于 2019-11-30 13:22:39
问题 I have a very simple AspectJ aspect (using @AspectJ) which just prints out a log message. My goal is to advice code in my android application. Now this aspects works perfectly fine as long as I have the aspect class itself in my applications source-code. Once I move the aspect into a different module (either java -> .jar or android lib -> .aar) I get the following runtime exception when running the adviced code in my application: java.lang.NoSuchMethodError: com.xxx.xxx.TraceAspect.aspectOf

spring 知识点

北城以北 提交于 2019-11-30 12:13:21
1.什么是IOC? IOC是一种设计思想,将原本在代码中,手动创建对象的控制权,交给spring框架来管理。 IOC容器实际上就是个map,存放各种对象,这样就可以很大程度上简化应用的开发,把应用从复杂的依赖关系中,解放出来。 IOC容器就像个工厂,当需要创建一个对象时,只需要配置好配置文件,添加注释即可,不需要考虑对象是如何被创建出来的,大大增加了项目的可维护性且降低了开发难度。 2.什么是AOP? AOP面向切面编程,将那些与业务无关,却被业务模块共同调用的逻辑封装起来,减少重复代码,降低模块间的耦合。 使用aop之后,将一些通用功能抽取出来,在需要用到的地方直接使用,这样就可以简化代码,提高拓展性。 3.Spring AOP / AspectJ AOP 的区别? Spring AOP属于运行时增强,而AspectJ是编译时增强。 Spring AOP基于代理,而AspectJ基于字节码操作。 AspectJ相比于Spring AOP功能更加强大,但是Spring AOP相对来说更简单。如果切面比较少,那么两者性能差异不大。但是,当切面太多的话,最好选择AspectJ,它比SpringAOP快很多 来源: https://www.cnblogs.com/fuyublog/p/11584069.html

aspectj pointcut with annotation parameters

青春壹個敷衍的年華 提交于 2019-11-30 12:04:23
问题 I am using aspectj to intercept methods that are annotated with @Profile(description="something") @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) public @interface Profile { public String description() default ""; } @Around("com.merc.aop.ctw.aspect.PointcutDefinitions.logAnnotatedMethods(profile)") public Object profile(ProceedingJoinPoint pjp, Profile profile) throws Throwable { .... } @Pointcut("@annotation(com.merc.annotations.Profile)") protected void logAnnotatedMethods

Pointcut matching methods with annotated parameters

為{幸葍}努か 提交于 2019-11-30 11:48:07
问题 I need to create an aspect with a pointcut matching a method if: Is public Its class is annotated with @Controller (Finally does not) One of its parameters (can have many) is annotated with @MyParamAnnotation. I think the first two conditions are easy, but I don't know if its possible to accomplish the third with Spring. If it is not, maybe I can change it into: One of its parameters is an instance of type com.me.MyType (or implements some interface) Do you think it's possible to achieve this

spring mvc中的AOP和interceptors

不羁岁月 提交于 2019-11-30 10:18:17
项目中采用Interceptor来过滤URL来决定哪些可以在不登录的情况下访问,哪些必须要登录才可以访问; public class SessionTimeoutInterceptor implements HandlerInterceptor { 此时需要在servlet.xml中配置<mvc:interceptor> 同时亦采用AOP来记录日志,使用注解方式 @Component @Aspect 同时在servlet.xml中配置 <aop:aspectj-autoproxy></aop:aspectj-autoproxy> 经测试发现,interceptor先于AOP执行。 来源: oschina 链接: https://my.oschina.net/u/118507/blog/403344

Exception handling through spring AOP + Aspectj

◇◆丶佛笑我妖孽 提交于 2019-11-30 09:56:53
In my project I have a domain layer which is basically POJO and a Spring controller / service layer that is sitting on top of the domain layer. I also have an AOP layer which is sitting between the service and domain. My domain layer is throwing business exceptions which are now being handled in the service layer. However I want to change it so that exception thrown from domain layer will be handled in the AOP layer. AOP layer will some kind of error response and send it back to spring controller/ web service layer. I can create a IBizResponse and make two subclasses/interfaces of it perhaps a

AspectJ LTW in eclipse - Pointcut does not work with static method

徘徊边缘 提交于 2019-11-30 09:53:51
问题 I have an Aspect class, which defines one point-cut expression as below @Pointcut("execution(* com.vg.pw.tasks.shared.*.executeTasks(..))") public void myTraceCall() {} where the executeTasks() method is static. If the method is made to non-static, the method body is executed on every call of executeTasks() . Why is my pointcut not effective on static methods? I'm using LTW and not spring. 回答1: I just tried out your pointcut expression and it works on both static and non-static methods just

How to write an Aspect pointcut based on an annotated parameter

倖福魔咒の 提交于 2019-11-30 09:36:47
I'm having a bit of trouble working out how to create a pointcut that will operate on beans that have a specific annotated parameter. My eventual aim is to validate the value of the parameter before it's processed, but for the moment I just need to create the pointcut. Consider the following annotation @Retention(RetentionPolicy.RUNTIME) @Target({ ElementType.PARAMETER }) public @interface MyAnnotation {} I'd then like to apply this to a number of methods like: public void method1(@MyAnnotation long i) {} public void method2(String someThing, @MyAnnotation long i) {} public void method3(String

Is there an aspect already written and tested well for TRACE logging

南楼画角 提交于 2019-11-30 09:32:44
问题 I am refactoring a legacy application where the actual application is scattered in between lot of logging statements. I could immediately benefit by removing TRACE level logging (method entered/exited). However this has proven to be useful many times while debugging an app while integration testing etc. So I am wondering if there is already a working and proven (being used for a while) aspect written for this? I've gone though some online posts but they seem to simple enough (and not sure if