aspectj

AspectJ - parse definitions failed - NullPointerException

房东的猫 提交于 2019-12-25 12:20:08
问题 Here's MVCE https://github.com/yami12376/AspectJ Add VM arguments to Run/Debug configuration of Junit test , in my case: -javaagent:C:\aspectjWeaver\spring-instrument-3.0.4.jar -javaagent:C:\aspectjWeaver\aspectjweaver-1.6.11.jar In my case i added this in JAVA build path : \target\classes\META-INF from src/main/resources Run Junit test If you delete aop.xml it's still weaving type org.* but on the other hand aop.xml should not weave it beacuse it has: <include within="com.*"/> Why does it

How to keep M2_REPO variable dynamic in Aspect Path of an Eclipse Java/AspectJ run configuration?

纵饮孤独 提交于 2019-12-25 11:55:17
问题 I'm trying to create a "Java/AspectJ application" run configuration for my Maven built project. Because i'm using Spring aspects i have to include the spring-aspects artifact in the run configuration's Aspect Path list. I'm adding it via the "Advanced.." button selecting "Add Classpath variable" and extending from the M2_REPO variable. So in the end i have a classpath variable entry in the list like this with a blue dot icon next to it: M2_REPO/org/springframework/spring-aspects/3.1.3.RELEASE

Spring Boot Aspect @Around

旧巷老猫 提交于 2019-12-25 09:39:13
问题 I am using Spring Boot & try to log response time of every request. For that purpose, I am trying to @Around Aspect. Code : @Aspect @Component public class XYZ { @Around("execution(* org.springframework.web.servlet.DispatcherServlet.service(..))") public void doBasicProfiling(ProceedingJoinPoint pjp) throws Throwable { // start stopwatch long startTime = System.currentTimeMillis(); System.out.println("Before"); pjp.proceed(); long endTime = System.currentTimeMillis(); // stop stopwatch System

Aspectj functions through external library

房东的猫 提交于 2019-12-25 09:11:36
问题 I have an external library which is not an spring application. It defines few Aspectj functions/PointCuts but it is not getting called when i am using this library in an spring boot application. When i define the pointcuts in spring boot application itself it is working fine. I guess something is wrong with my configuration like @EnableAspectJAutoProxy not working or something. Code of service-: @EnableAspectJAutoProxy @Service public class LtRequest { RestTemplate restTemplate; public

Combining two pointcuts but with parameters (if is possible)

徘徊边缘 提交于 2019-12-25 09:08:44
问题 For a Spring application project, before to delete or update something (an entity) I want before check if that object exists. I have the following: @Pointcut("execution(* com.manuel.jordan.service.impl.PersonaServiceImpl.deleteOne(String)) && args(id)") public void deleteOnePointcut(String id){} @Pointcut("execution(* com.manuel.jordan.service.impl.PersonaServiceImpl.updateOne(com.manuel.jordan.domain.Persona)) && args(persona)") public void updateOnePointcut(Persona persona){} If I use:

@aspect - @around annotations used - custom annotated method not getting executed

大兔子大兔子 提交于 2019-12-25 08:40:20
问题 I created a custom annotation using AspectJ , and tried to create annotation that will help in skipping method if annotation is not valid. But my method body is not getting executed any case here it is my code it is the constraint package com.test; public @interface SwitchLiteConstraint { Class<SwitchLiteValidator>[] validatedBy(); } below is constraint validator package com.test; import java.lang.annotation.Annotation; public interface SwitchLiteConstraintValidator<T1 extends Annotation, T2>

aspectj pointcuts on object variable assignment

风流意气都作罢 提交于 2019-12-25 07:59:13
问题 I would like to create a pointcut on the following sample class whenever a variable gets assigned. So for instance, in method1(int number), this.x gets set to int. I realize in this case I could just make a pointcut on method1 and then find out what the new x value is using reflection. However, I was wondering if there is a way to make a pointcut on the line this.x = number, so that my pointcut gets triggered, for example, before the function ends? public class Sample { private int x; public

CDI Weld and AspectJ - org.jboss.weld.exceptions.UnproxyableResolutionException

空扰寡人 提交于 2019-12-25 06:32:10
问题 I get this error when using AspectJ and CDI. org.jboss.weld.exceptions.UnproxyableResolutionException: WELD-001437 Normal scoped bean class myPackageName.myClassName is not proxyable because the type is final or it contains a final method static final java.lang.String myPackageName.myClassName.myMethodName_aroundBody0(myPackageName.myClassName.,org.aspectj.lang.JoinPoint). If I remove AspectJ it works, but I don't want that. Please Help. 回答1: I got an answer from AspectJ's mailing list, they

Call a setter to a field which is annotated with AspectJ

♀尐吖头ヾ 提交于 2019-12-25 05:02:07
问题 I want to intercept all assignments to a field which is annotated with MyAnnotation in this case. If it works when the value is assigned with reflction is much better. This is what I tried, but it does not run, and I think that something else might be wrong: public privileged aspect MyAnnotationAspect { pointcut hasAnnotation(MyAnnotation annotation) : @annotation(annotation); pointcut methodExecution() : execution(* *(..)); Object around(MyAnnotation annotation) : set(String word) &&

Why gradle-aspectj doesn't pick up IntegrationTest sourceSet

旧街凉风 提交于 2019-12-25 04:48:17
问题 Like many others I am trying to convert a Maven project to gradle and am having problems with aspects. I have tried using gradle-aspectj - https://github.com/eveoh/gradle-aspectj - and right out of the box it weaves main and test sources. But I am trying to run IntegrationTests as a separate SourceSet. The code for gradle-aspectj at https://github.com/eveoh/gradle-aspectj/blob/master/src/main/groovy/aspectj/AspectJPlugin.groovy loops over the project.sourceSets so why doesn't it pick up the