aspectj

Wormhole pattern w. AspectJ: How to get caller method name?

不羁岁月 提交于 2019-12-19 05:00:10
问题 Using the wormhole pattern with AspectJ, is there a way that the executing method name can be seen in the wormhole advice? I have an example where a service class (ClientService) calls getters on a domain class (Client). What I want, is to know in the advice to know the name of service method that called the getter. I have no problem seeing the service object itself, but I need the name of the service method. Here's my aspect: public aspect MyAspect { pointcut serviceExecution(ClientService

Compile/load time weaving with spring

[亡魂溺海] 提交于 2019-12-19 03:39:09
问题 The docs explain that, the LTW has to enabled either through the use of <context:load-time-weaver/> xml instruction or the use of @EnableLoadTimeWeaving annotation. However, I have done neither, but I still see that aspects are woven correctly in my projects! In this case, I don't think they are woven at compile-time (but are they?), so it's surely got to be load-time-weaving? Even if that's the case, how does it automatically choose to weave aspects in during load-time? Shouldn't the aspects

Gradle 1.0 +Spring + AspectJ build problems

ぃ、小莉子 提交于 2019-12-19 03:36:32
问题 I am migrating a Maven build into Gradle for a project relying on @Configurable Spring annotations, however when my (web) application is running none of the @Configurable classes are getting injected under the Gradle build (they were working fine built my Maven). In Maven I used the following plugin: <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>aspectj-maven-plugin</artifactId> <version>1.4</version> <executions> <execution> <goals> <goal>compile</goal> <goal>test-compile</goal>

Aspectj: Pointcut on lambda expression

送分小仙女□ 提交于 2019-12-19 02:57:10
问题 I have a Java6 project that is being migrated to Java8. We used aspectj to log some of users actions, like button clicking. So there are listeners like this: button.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { doSth(); } }); And poincut: @Pointcut("execution(public void Button.ClickListener.buttonClick(Button.ClickEvent))") public void buttonClick() {}; But since we will use Java8, listeners will be like this: button

WEB-INF/classes/ vs WEB-INF/lib/*.jar in classpath priority?

时间秒杀一切 提交于 2019-12-18 20:15:29
问题 a war packaged for a tomcat webapp contains WEB-INF/classes and WEB-INF/lib/*.jar which of them has higher priority in the CLASSPATH? the reason I'm asking is, that my application uses A.jar, which contains aspects generated from an aspectj project; and B.jar, which are to be woven with the aspects from A.jar. when the project myapp is compiled, it generates many Classes which override those same classes from B.jar, these are packaged into the WEB-INF/classes dir. so if tomcat load WEB-INF

Spring Boot, @Autowire into an unmanaged class using @Configurable and load time weaving

断了今生、忘了曾经 提交于 2019-12-18 16:47:47
问题 I have a collection of unmanaged classes that I are instantiated outside of Spring. I've been attempting to use Spring AOP with load time weaving to @Autowire a bean into these classes but have so far not had any luck. I've been testing using Tomcat 8 and Spring Boot 1.2.0. My @Configuration where I attempt to set up class looks like this: @Configuration @PropertySource("classpath:application.properties") @EnableSpringConfigured @EnableLoadTimeWeaving public class Config Inside Config I

access class variable in aspect class

给你一囗甜甜゛ 提交于 2019-12-18 16:47:25
问题 i am creating an aspect class with spring aspectj as follow @Aspect public class AspectDemo { @Pointcut("execution(* abc.execute(..))") public void executeMethods() { } @Around("executeMethods()") public Object profile(ProceedingJoinPoint pjp) throws Throwable { System.out.println("Going to call the method."); Object output = pjp.proceed(); System.out.println("Method execution completed."); return output; } } now i want to access the property name of class abc then how to acccess it in aspect

How can I combine @Aspect with @Controller in Spring 3?

时光毁灭记忆、已成空白 提交于 2019-12-18 13:33:26
问题 I'm trying to setup a Spring 3 Web MVC project, using the @Controller, annotation-based approach. package my.package @Controller @RequestMapping("/admin/*") public class AdminMultiActionController { @RequestMapping(value = "admin.htm", method = RequestMethod.GET) public String showAdminSection() { return "admin"; } My dispatcher-servlet has the following Controller handlers: <context:component-scan base-package="my.package" /> <bean class="org.springframework.web.servlet.mvc.annotation

AspectJ + Junit + Maven - pointcut recognized in tests but NoSuchMethodError: aspectOf() exception thrown

房东的猫 提交于 2019-12-18 13:14:28
问题 I have followed almost all JUnit + Maven + AspectJ questions here and even I am pretty sure I have everything set properly, I am unable to test it. I have a Maven module with just one aspect: @Aspect public class AssertionAspect { @Pointcut("execution(@org.junit.Test * *())") public void testMethodEntryPoint() {} @Before("testMethodEntryPoint()") public void executeBeforeEnteringTestMethod() { System.out.println("EXECUTE ACTION BEFORE ENTERING TEST METHOD"); } @After("testMethodEntryPoint()")

How to crosscut annotated methods and constructors?

↘锁芯ラ 提交于 2019-12-18 05:56:29
问题 This is what I'm doing: @Aspect public class MethodLogger { @Around("(execution(* *(..)) || initialization(*.new(..))) && @annotation(Foo)") public Object wrap(ProceedingJoinPoint point) throws Throwable { // works fine, but only for methods } } The snippet works fine, but only for method calls. This is what AspectJ maven plugin is saying after applying the aspect (not during its compilation, which works just fine): around on initialization not supported (compiler limitation) Any workaround?