aspectj

How to make Lombok and AspectJ work together?

不打扰是莪最后的温柔 提交于 2019-11-26 06:39:50
问题 I just finished posting this issue on SO about Lombok not generating my getters/setters. It turns out that it is conflicting with AspectJ. If I disable AspectJ, then the getters/setters are appropriately generated. My guess is that the ajc compiler is not able to recognize lombok. Are Lombok and AspectJ mutually exclusive? Do both technologies work together? 回答1: The current answer according to AspectJ maintainer Andy Clement is that there are problems due to ECJ (Eclipse Compiler for Java)

Emulate annotation inheritance for interfaces and methods with AspectJ

不问归期 提交于 2019-11-26 04:54:23
问题 Often people ask AspectJ questions like this one, so I want to answer it in a place I can easily link to later. I have this marker annotation: package de.scrum_master.app; import java.lang.annotation.Inherited; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @Inherited @Retention(RetentionPolicy.RUNTIME) public @interface Marker {} Now I annotate an interface and/or methods like this: package de.scrum_master.app; @Marker public interface MyInterface { void

@AspectJ pointcut for all methods of a class with specific annotation

ε祈祈猫儿з 提交于 2019-11-26 04:06:38
问题 I want to monitor all public methods of all Classes with specified annotation (say @Monitor) (note: Annotation is at class level). What could be a possible pointcut for this? Note: I am using @AspectJ style Spring AOP. 回答1: You should combine a type pointcut with a method pointcut. These pointcuts will do the work to find all public methods inside a class marked with an @Monitor annotation: @Pointcut("within(@org.rejeev.Monitor *)") public void beanAnnotatedWithMonitor() {} @Pointcut(

Spring autowiring using @Configurable

为君一笑 提交于 2019-11-26 03:56:12
问题 I\'m playing with the idea of using Spring @Configurable and @Autowire to inject DAOs into domain objects so that they do not need direct knowledge of the persistence layer. I\'m trying to follow http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/aop.html#aop-atconfigurable, but my code seems to have no effect. Basically, I have: @Configurable public class Artist { @Autowired private ArtistDAO artistDao; public void setArtistDao(ArtistDAO artistDao) { this

Spring AOP vs AspectJ

邮差的信 提交于 2019-11-26 02:39:33
问题 I am under the impression that Spring AOP is best used for application specific tasks such as security, logging, transactions, etc. as it uses custom Java5 annotations as a framework. However, AspectJ seems to be more friendly design-patterns wise. Can anyone highlight the various pros and cons of using Spring AOP vs AspectJ in a Spring application? 回答1: Spring-AOP Pros It is simpler to use than AspectJ, since you don't have to use LTW (load-time weaving) or the AspectJ compiler. It uses the

Spring @Transaction method call by the method within the same class, does not work?

房东的猫 提交于 2019-11-26 00:09:52
问题 I am new to Spring Transaction. Some thing that I found really odd, probably I did understand this properly. I wanted to have a transactional around method level and I have a caller method within the same class and it seems like it does not like that, it has to be called from the separate class. I don\'t understand how is that possible. If anyone has an idea how to resolve this issue, I would greatly appreciate. I would like to use the same class to call the annotated transactional method.