pointcut

How to make my JLabels red with use of aspectJ?

人走茶凉 提交于 2020-01-05 15:26:21
问题 my Project has a MessageUtil class, which has methods to show messages, I'm trying to make the texts of my Jlabels red using aspectJ, without use of aspectJ it is enough to add 'for loop' to one of the methods wich makes multiLabel text message: public static JLabel[] createMultiLabel(String msg) { JLabel[] messages = null; if (msg.contains("\n")) { messages = createMultiLabelBySlashN(msg); } else { messages = createMultiLabelByPixel(msg); } //this for loop makes the text red for (int i = 0;

Spring AOP - pointcut for every method with an annotation

三世轮回 提交于 2019-12-31 08:29:15
问题 I am trying to define a pointcut, that would catch every method that is annotated with (i.e.) @CatchThis . This is my own annotation. Moreover, I'd like to have access to the first argument of the method, which will be of Long type. There may be other arguments too, but I don't care about them. EDIT This is what I have right now. What I don't know is how to pass the first parameter of the method annotated with @CatchThis . @Aspect public class MyAspect { @Pointcut(value = "execution(public *

How to define an aspectj pointcut that picks out all constructors of a class that has a specific annotation?

老子叫甜甜 提交于 2019-12-31 02:14:06
问题 Here is the annotation: @Target(value = ElementType.TYPE) @Retention(value = RetentionPolicy.RUNTIME) @Inherited public @interface MyAnnotation { String name(); } Here is one annotated class: @MyAnnotation(name="foo") public class ClassA { public ClassA() { // Do something } } Here is a second annotated class: @MyAnnotation(name="bar") public class ClassB { public ClassB(String aString) { // Do something } } I am looking for an aspectj pointcut that correctly matches the constructors for

Spring AOP - get old field value before calling the setter

烈酒焚心 提交于 2019-12-29 04:56:07
问题 Dear all I am curently using Spring AOP (v4) and AspectJ with load-time-weaver. I am looking currently for a way to add a dirty flag mechanism into my beans. Therefore I I though of using AOP to call a method before a setter of my beans get called. This I achieved already, but how can I access the old field value beforeit get modified? Or is there a way to get the field name so I can call the getter before the setter get called? Can anybody provide me here some example how the pointcut/advice

Pointcuts are not triggered

元气小坏坏 提交于 2019-12-25 16:58:12
问题 I have a Spring 3.2.4 MVC application and I want to use Spring AOP. Hence, I have created a config file with an <aop:aspectj-autoproxy /> . I also have written an Aspect (adopted to code found in the web): @Component @Aspect public class PerformanceMonitoring { private static final Logger logger = Logger.getLogger(PerformanceMonitoring.class); public PerformanceMonitoring() { System.out.println("++++++++++++++++++++++++++++++++++++++++++++++++"); } // @Around("execution(* com.silabs.moka.*(..

Pointcuts are not triggered

大兔子大兔子 提交于 2019-12-25 16:57:12
问题 I have a Spring 3.2.4 MVC application and I want to use Spring AOP. Hence, I have created a config file with an <aop:aspectj-autoproxy /> . I also have written an Aspect (adopted to code found in the web): @Component @Aspect public class PerformanceMonitoring { private static final Logger logger = Logger.getLogger(PerformanceMonitoring.class); public PerformanceMonitoring() { System.out.println("++++++++++++++++++++++++++++++++++++++++++++++++"); } // @Around("execution(* com.silabs.moka.*(..

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

Pointcut get expression not working in XML

给你一囗甜甜゛ 提交于 2019-12-25 04:08:35
问题 I have a pointcut expression which is working fine when written in java but when written in xml gives error. Since my aspect is written in one project and it's jar is available in other project I have to provide it's mapping in the XML in other projects using the same aspect in JAR. In Java: @Pointcut("get(java.lang.String com.air.ghl..*) and @annotation(value)") public void isDynamicValue(DynamicValue dynamicValue) {} @Around("isDynamicValue(dynamicValue)") public Object getDynamicString

I need a Spring AOP pointcut explanation

南笙酒味 提交于 2019-12-25 03:40:39
问题 I have seen two variations of pointcut patterns: This execution(* some.package.*.*(..)) and this execution(* some.package.* *(..)) What is the meaning of the dot (or of it absence) between the last two *'s? 回答1: This appendix defines grammar of the pointcut expression langauge. For the execution expression the rule is the following: execution(MethodPattern) where MethodPattern = [ModifiersPattern] TypePattern [TypePattern . ] IdPattern (TypePattern | ".." , ... ) [ throws ThrowsPattern ] That

aspectj cross-thread pointcut

牧云@^-^@ 提交于 2019-12-24 07:46:55
问题 I am new with AspectJ annotation for Java, and I am wondering if it is possible to put pointcut on a cross thread invocation. Here is the code: public class App { public static void main( String[] args ) { new Connector().getStart("testtest"); } } public class Connector { public void getStart(String s1) { Handler h = new Handler(s1); h.start(); } } public class Handler extends Thread { String s1; public Handler(String s1) { this.s1 = s1; } public void run() { new Plain().getValue(s1); } }