aspectj

Spring MVC with AspectJ

匿名 (未验证) 提交于 2019-12-03 01:36:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a working spring mvc project. I want to log each request through my controllers with using AspectJ. The relevant code: The Controller: (in package hu.freetime.controller) @Controller @RequestMapping("/") public class BaseControllerImpl { @RequestMapping(method = RequestMethod.GET) public String index(Model model) { return "index"; } } The Aspect: @Aspect public class ControllerAspectImpl { Logger logger = LoggerFactory.getLogger(ControllerAspectImpl.class); @Pointcut("execution(public * hu.freetime.controller.BaseControllerImpl.*(..))

AspectJ pointcuts - get a reference to the joinpoint class and name

血红的双手。 提交于 2019-12-03 01:35:51
I am using the @AspectJ style for writing aspects, to handle logging in our application. Basically I have a pointcut set up like so: @Pointcut("call(public * com.example..*(..))") public void logging() {} and then a before and after advice like so: @Before("logging()") public void entering() {...} ... @After("logging()") public void exiting() {...} I want to create a log in these methods in the following format: logger.trace("ENTERING/EXITING [" className + "." + methodName "()]"); The problem is I don't know how to get a reference to the class and method names. I have tried: joinPoint.getThis

AspectJ in Android: pointcut call(* Activity.onCreate(..)) doesn't pick out Activity.onCreate() calls

匿名 (未验证) 提交于 2019-12-03 01:31:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am using AspectJ in my Android project and I'd like to write a pointcut that catches all the calls to onCreate() and onDestroy() of my activities. I am quite new to AspectJ, so probably I am missing something here but why this: pointcut createActivity(Activity a) : target(a) && execution(* Activity.onCreate(..)) && within(com.test.activities..*); works and this: target(a) && call(* Activity.onCreate(..)) && within(com.test.activities..*); doesn't work? 回答1: Nice to see other people adventuring into aspectJ and Android :-) When using

nullpointer exception in aspectJ example

匿名 (未验证) 提交于 2019-12-03 01:23:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am trying to implement one of the suggestion given by our stackoverflow member here Logging entry, exit and exceptions for methods in java using aspects . Since this is different question in itself, posting here again. I have tried to search but looks like different versions have different ways of doing it and unable to figure out an example online. I have tried the following simple example since I am new to aspect oriented programming and couldn't figure out how to implement. This example is throwing NPE. Please help me understand where I

Spring + AspectJ weaving for java 8 using aspectj-maven-plugin

匿名 (未验证) 提交于 2019-12-03 01:17:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I'm migrating my project from java 7 to java 8 and the problem I have is related to aspectj weaving using aspectj-maven-plugin . I could configure successfuly the weaving using this plugin running on Java 6 and 7 according to Haus documentation . But the problem is that I haven't found any way to use (and find) plugin version 7 that supports java 8. I saw here that plugin 7 adds java 8 support but couldn't find a way to use it. This is the configuration plugin I need: org.codehaus.mojo aspectj-maven-plugin 1.7 1.8 1.8 1.8 compile

Spring / @Transactional with AspectJ is totally ignored

匿名 (未验证) 提交于 2019-12-03 01:06:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I use Spring-Data Neo4j 2.2.0-RELEASE. (my following issue would be applicable to any other kind of entity mapping, why not JPA) In my project, I have a public method annotated with @Transactional Spring's annotation, since I want to update/save an entity inside it: public class MeetingServices { private UserRepository userRepository ; private MeetingRepository meetingRepository ; public void setUserRepository ( UserRepository userRepository ) { this . userRepository = userRepository ; } public void setMeetingRepository (

AspectJ and NoSuchBeanDefinitionException at least 1 bean which qualifies as autowire candidate for this dependency

匿名 (未验证) 提交于 2019-12-03 01:05:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm trying to use AspectJ, my project was working correctly. But when I try to use AspectJ the injection isn't working correctly. If I don't use AspectJ, it works again. I included on my pom.xml <dependency> <groupId>org.springframework</groupId> <artifactId>spring-aop</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.aspectj</groupId> <artifactId>aspectjrt</artifactId> <version>1.6.11</version> </dependency> <dependency> <groupId>org.aspectj</groupId> <artifactId>aspectjweaver</artifactId> <version>1

Dependency Error AspectJ Maven Plugin Installation For com:sun:tools:jar

匿名 (未验证) 提交于 2019-12-03 01:01:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I would like to run the Maven project that I have on https://github.com/ihsanhaikalz/testMaven in the Eclipse 4.5 (Mars) but it gave me an error in the pom.xml as follow: 1 problem was encountered while building the effective model for org.codehaus.mojo:aspectj-maven-plugin:1.8 [ERROR] 'dependencies.dependency.systemPath' for com.sun:tools:jar must specify an absolute path but is ${toolsjarSystemPath} @ I already installed AJDT for Eclipse 4.5 through http://download.eclipse.org/tools/ajdt/45/dev/update and when I pulled from my github the

AspectJ: @AfterReturning

匿名 (未验证) 提交于 2019-12-03 01:00:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I've created this pointcut: @Pointcut ( "execution(* com.living.commty.boot.resources.*.* (..))" ) public void resourcesCut () {} I'm trying to get the return value after having been returned: @AfterReturning ( pointcut = "resourcesCut()" , returning = "result" ) public void afterReturning ( JoinPoint joinPoint , Object result ) { //... } The problem is that it's cutting only 6 advises. However, if I not set returning : @AfterReturning ( pointcut = "resourcesCut()" ) public void afterReturning ( JoinPoint joinPoint ) { this .

IntelliJ IDEA + AspectJ

匿名 (未验证) 提交于 2019-12-03 00:51:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am trying to use AspectJ in sample project in IntelliJ IDEA. I have an experience with Spring AOP, but this is first time I am using AspectJ, and cannot make it work. I am trying to do as described here: https://www.jetbrains.com/help/idea/2017.1/aspectj.html My build.gradle: apply plugin: 'java' repositories { mavenCentral() } dependencies { compile "org.projectlombok:lombok:+" compile "org.aspectj:aspectjrt:+" compile "org.aspectj:aspectjweaver:+" compile "org.aspectj:aspectjtools:+" } buildscript { repositories { maven { url "https:/