aspectj

problems with Native AspectJ with Spring

折月煮酒 提交于 2019-12-20 07:32:08
问题 I am testing AspectJ compile time weaving with Spring 4 (once I get it to work, I want to use it in my projects). I have the following service class: @Service public class HelloService { public String sayHello(){ return sayHello2(); } public String sayHello2(){ return "Hello from AOP2!"; } } And here's my AspectJ advice: @Component @Aspect public class ExecutionTimeAdvice { @Around("execution(* com.senyume.aop.service..*(..))") public Object doBasicProfiling(ProceedingJoinPoint pjp) throws

Applying custom annotation advice to spring data jpa repository

女生的网名这么多〃 提交于 2019-12-20 05:25:30
问题 I am working on a mysql master slave replication. I am using spring data jpa(spring boot). What I needed is all write operations to go to master server and read-only operations to be equally distributed among multiple read-only slaves. For that I need to: Use special JDBC driver: com.mysql.jdbc.ReplicationDriver Set replication: in the URL: spring: datasource: driverClassName: com.mysql.jdbc.ReplicationDriver url: jdbc:mysql:replication://127.0.0.1:3306,127.0.0.1:3307/MyForum?user=root

aop.xml name and location?

点点圈 提交于 2019-12-20 04:52:44
问题 Is there a way to specify the name of the aop.xml file with LTW? or define another name and location? I have several software modules that I use and that all use META-INF/aop.xml with different settings. I include these modules in a web application and then it all dependens how it's deployed/unpacked, which aop.xml file is used .. So I discovered after long time of searching that not all LTW weaving toke place correcting as it depends with aop.xml was used ... Basically I need to use both aop

Spring AOP point cut for 'nested' annotation

丶灬走出姿态 提交于 2019-12-20 03:30:22
问题 I need to define a point cut which triggers the execution on all methods of a spring service annotated with a custom annotation. The annotation I would like to define the point cut on will be on an other annotation. @Y public @interface X { } and then the service would be annotated as following @X public Service1 { } I tried with the following point cut definition but it only works when @Y is on the service itself, meaning that it doesn't see that the annotation is on @X @Around("@within(com

How to force compile error with aspectJ pointcut mismatch

こ雲淡風輕ζ 提交于 2019-12-19 11:36:34
问题 I have the following aspectJ pointcut: @Around(value="execution(* *(*,Map<String, Object>)) && @annotation(com.xxx.annotations.MyCustomAnnotation)") As you can see, this pointcut only matches methods, annotated with com.xxx.annotations.MyCustomAnnotation, which have 2 arguments - the first one is arbitrary and the second one must be of type Map<String, Object> . Is there a way to configure the aspectj-maven-plugin to force compilation errors if it find methods that are annotated with com.xxx

How to get the caller method information from Around advise

六月ゝ 毕业季﹏ 提交于 2019-12-19 11:05:19
问题 ThisJoinPoint can only get the current method information, anyway to get the caller method information? 回答1: You can try the special variable thisEnclosingJoinPointStaticPart which holds the static part of the enclosing JoinPoint. Mentioned here (example) and here (docs) Or if using annotation-based AspectJ, pass following to the advice method's parameters, e.g.: @Before("call( /* your pointcut definition */ )") public void myCall(JoinPoint.EnclosingStaticPart thisEnclosingJoinPointStaticPart

How to make Spring @Cacheable work on top of AspectJ aspect?

限于喜欢 提交于 2019-12-19 09:26:11
问题 I created an AspectJ aspect which runs fine within a spring application. Now I want to add caching, using springs Cacheable annotation. To check that @Cacheable gets picked up, I'm using the name of a non-existing cache manager. The regular run-time behavior is that an exception is thrown. But in this case, no exception is being thrown, which suggests that the @Cacheable annotation isn't being applied to the intercepting object. /* { package, some more imports... } */ import org.aspectj.lang

How to exclude methods from aspectj

风流意气都作罢 提交于 2019-12-19 07:24:49
问题 I'm trying to exclude several methods from log files using aspectj (Im usong spring and Load-time weaving). Is there a way to list the excluded methods in the aop.xml? I know i can do this for full classes but I'm looking for specific methods. or can i make a list in the aspect class? Thanks 回答1: I don't know how to do it in an XML, but it's easy enough to do it in the aspects themselves, as pointcuts can be combined using boolean operators. Traditional aspectj syntax: pointcut

How to exclude methods from aspectj

安稳与你 提交于 2019-12-19 07:24:13
问题 I'm trying to exclude several methods from log files using aspectj (Im usong spring and Load-time weaving). Is there a way to list the excluded methods in the aop.xml? I know i can do this for full classes but I'm looking for specific methods. or can i make a list in the aspect class? Thanks 回答1: I don't know how to do it in an XML, but it's easy enough to do it in the aspects themselves, as pointcuts can be combined using boolean operators. Traditional aspectj syntax: pointcut

How can I use AOP to intercept the constructor of File, FileReader, FileWriter, FileInputStream and FileOutputStream?

泄露秘密 提交于 2019-12-19 06:53:14
问题 I want to intercept the constructor of File, FileReader, FileWriter, FileInputStream and FileOutputStream and prevent any filenames from containing ".." (to prevent path traversal attacks) or "\0" (to prevent filename null character attacks). I have another open question about how to do this same thing using SecurityManager, but no one has answered it yet, so I was hoping this alternate method would work. This is for a spring webapp on tomcat. I know that I could manually do this by making my