aspectj

NoSuchMethodError aspectOf() at runtime from building with iajc

我与影子孤独终老i 提交于 2020-01-03 08:08:07
问题 We used aspectJ to get some metric on an existing application. When building and weaving with AJDT in eclipse, everything works great. But in the integration env. we use an ant script to build and deploy the application. The problem occur on an ExceptionHandler i did to be sure our aspect would not throw exception and break the application @Aspect public class ExceptionHandlerAspect { /** * Pointcut */ @Pointcut("within(com.xxx.yyy.aop.aspect.*..*)") public void allMethodInAspectPackage() {}

NoSuchMethodError aspectOf() at runtime from building with iajc

半腔热情 提交于 2020-01-03 08:08:06
问题 We used aspectJ to get some metric on an existing application. When building and weaving with AJDT in eclipse, everything works great. But in the integration env. we use an ant script to build and deploy the application. The problem occur on an ExceptionHandler i did to be sure our aspect would not throw exception and break the application @Aspect public class ExceptionHandlerAspect { /** * Pointcut */ @Pointcut("within(com.xxx.yyy.aop.aspect.*..*)") public void allMethodInAspectPackage() {}

AspectJ - Compile Java source with precompiled aspects

与世无争的帅哥 提交于 2020-01-03 01:54:06
问题 Let's say I have few aspects, which I have already compiled, and now I just want to compile single source file, but without recompiling the aspects, since it takes a lot of time. Is there any way to do so? For example, I have the following: Trace.aj Log.aj Test.java All of them were compiled during my "build-all", and now I've changed Test.java and wants to recompile it using the (already compiled) aspects. 回答1: Use load-time weaving. http://www.aspectprogrammer.org/blogs/adrian/2004/05

ajc wont compile lambda as an vararg argument

一世执手 提交于 2020-01-02 10:18:22
问题 I'm using ajc 1.8, java 8 and experiencing compiler issue. Here's the sample code. public class ExecutorTests { List<Runnable> tasks = Arrays.asList( () -> { System.out.println("task1 start"); try { Thread.sleep(1000); } catch (Exception ignored) {} System.out.println("task1 end"); }, () -> { System.out.println("task2 start"); try { Thread.sleep(1000); } catch (Exception ignored) {} System.out.println("task2 end"); }, () -> { System.out.println("task3 start"); try { Thread.sleep(1000); }

ajc wont compile lambda as an vararg argument

╄→гoц情女王★ 提交于 2020-01-02 10:18:09
问题 I'm using ajc 1.8, java 8 and experiencing compiler issue. Here's the sample code. public class ExecutorTests { List<Runnable> tasks = Arrays.asList( () -> { System.out.println("task1 start"); try { Thread.sleep(1000); } catch (Exception ignored) {} System.out.println("task1 end"); }, () -> { System.out.println("task2 start"); try { Thread.sleep(1000); } catch (Exception ignored) {} System.out.println("task2 end"); }, () -> { System.out.println("task3 start"); try { Thread.sleep(1000); }

AspectJ advice does not fire in Maven multi-module setup

﹥>﹥吖頭↗ 提交于 2020-01-02 07:17:09
问题 I'm trying to do AOP with Aspectj, but I don't know why is not executing my aspect, it just runs the main class. Is the first time I do this, so I might be doing something wrong. This is my code: The Aspect: @Aspect public class YourAspect { @Pointcut("@annotation(yourAnnotationVariableName)") public void annotationPointCutDefinition(YourAnnotation yourAnnotationVariableName){ } @Pointcut("execution(* *(..))") public void atExecution(){} @Around("annotationPointCutDefinition

Is it possible to exclude interface classes from AspectJ weaving

拈花ヽ惹草 提交于 2020-01-02 04:38:07
问题 Scenario: I have a mix of source files for classes, interfaces, and enums all together in one package like so: package com.mycompany.data; class Dog { // implementation } package com.mycompany.data; class Cat { // implementation } package com.mycompany.data; enum Gender { // gender options } package com.mycompany.data; interface Animal { // methods } // ... plus a lot more concrete classes and a few more interfaces ... The Goal : To have all of the classes implement a new interface and a new

Spring AOP 整理笔记

会有一股神秘感。 提交于 2020-01-02 02:17:13
一、AOP概念 AOP为Aspect Oriented Programming的缩写,意为:面向切面编程,通过预编译方式和运行期动态代理实现程序功能的统一维护的一种技术。 利用AOP可以对业务逻辑的各个部分进行隔离,从而使得业务逻辑各部分之间的耦合度降低,AOP采取横向抽取机制,取代了传统纵向继承体系重复性代码. Spring AOP使用纯Java实现,不需要专门的编译过程和类加载器,在运行期通过代理方式向目标类织入增强代码。 二、AOP中常用的术语 连接点(Joinpoint): 所谓连接点是指那些被拦截到的点。在spring中,这些点指的是方法,因为spring只支持方法类型的连接点,也可以理解连接点为:目标类上哪些有可能被增强的方法。 切点(Pointcut):可以理解为查询条件。一个target(目标类)的所有方法都是连接点,切点可以通过查询条件定位特定的连接点。 增强(Advice):织入目标类连接点上的一段程序代码。既包含连接点上的执行逻辑(横切逻辑、增强逻辑)又包含定位连接点的方位信息,before、after、around等。增强默认织入目标类的所有方法中。 目标对象(Target):增强逻辑织入的目标类。 代理(Proxy):一个类被AOP植入增强后,被产生一个结果代理类。 织入(Weaving):将通知(增强)应用到连接点上,生成代理的过程。 切面(Aspect

Aspectj aspect for specifying multiple packages

落爺英雄遲暮 提交于 2020-01-01 05:42:09
问题 I wanted to specify a pattern for aspectj @Around aspect that includes multiple packages. Example : package 1 : aaa.bbb.ccc.ddd package 2 : aaa.bbb.ccc.eee package 3 : aaa.bbb.ccc.eee.fff Pattern which i used : @Around("execution(* aaa.bbb.ccc.ddd.*.*(..)) && execution(* aaa.bbb.ccc.eee..*.*(..))") i.e Intercept packages aaa.bbb.ccc.ddd, aaa.bbb.ccc.eee and any sub-package of aaa.bbb.ccc.eee But this pattern doesnt seem to work. Though specifying a single pattern without && condition works.

How can I make external methods interruptable?

隐身守侯 提交于 2019-12-31 17:49:31
问题 The Problem I'm running multiple invocations of some external method via an ExecutorService. I would like to be able to interrupt these methods, but unfortunately they do not check the interrupt flag by themselves. Is there any way I can force an exception to be raised from these methods? I am aware that throwing an exception from an arbitrary location is potentially dangerous, in my specific case I am willing to take this chance and prepared to deal with the consequences. Details By