This is a simple class which is an aspect:
package aspectTest;
import java.awt.Color;
import javax.swing.JLabel;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
@Aspect
public class aspect {
@Pointcut("execution(static String createMultiLabel(..))")
public void multilabelCreation() {}
@Around("multilabelCreation()")
public String changeLabelColours(ProceedingJoinPoint thisJoinPoint) throws Throwable {
String st = (String) thisJoinPoint.proceed();
System.out.println("fdfs");
st = "st"+st;
return st;
}
}
and it's my main class:
package aspectTest;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
public class messagemethod {
public static String createMultiLabel(final String msg) {
return msg;
}
public static void main(String[] args) {
String st1 = createMultiLabel("hello");
System.out.println(st1);
}
}
this is my the folder lib:
this is my aop.xml:
<aspectj>
<aspects>
<aspect name="aspectTest.aspect"/>
</aspects>
</aspectj>
and this is my Run Configuration:
my problem is that when I run my main class, it just writes hello but not hello hello, which should be because of aspect. Anyone knows why my aspect doesn't make any affect?