aspectj

Need help creating a specific pointcut that utilizes a value from a method annotation

核能气质少年 提交于 2019-12-13 05:09:24
问题 I have the following method @AutoHandling(slot = FunctionalArea.PRE_MAIN_MENU) @RequestMapping(method = RequestMethod.GET) public String navigation(ModelMap model) { logger.debug("navigation"); ... //First time to the Main Menu and ID-Level is ID-1 or greater if (!callSession.getCallFlowData().isMainMenuPlayed() && callSession.getCallFlowData().getIdLevel() >= 1) { // Call Auto Handling logger.info("Call AutoHandling"); autoHandlingComponent.processAutoHandling(); } ... return forward

AspectJ/Java instrumentation to intercept an annoted parameter call/usage

夙愿已清 提交于 2019-12-13 04:57:08
问题 I would like to know how the doMonitorization method can be called when the param1 is used (param defined and used on the methods of the TestClassGeneralMeasuraments Class) which has the correct annotation that has a interception AspectJ definition as the bellow code shows. package monitorization; import org.aspectj.lang.JoinPoint; import org.aspectj.lang.annotation.After; import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Pointcut; @Aspect public class

Get the value of the accessed field within a get pointcut

痞子三分冷 提交于 2019-12-13 04:49:10
问题 I have a pointcut which listens to access to an field in DBRow and all subclasses before(DBRow targ) throws DBException: get(@InDB * DBRow+.*) && target(targ) { targ.load(); } I now need to determine the value of the accesed field, that is specified by the get pointcut. Is this possible in AspectJ? 回答1: For set() pointcuts you can bind the value via args() , but not for get() pointcuts. So in order to get the value without any hacky reflection tricks, just use an around() advice instead of

AfterReturning annotation not working for specific method structure

风格不统一 提交于 2019-12-13 04:36:18
问题 I am trying to use @AfterReturning of AspectJ to get return value of a specific function call. Not sure why @AfterReturning not working for the following method call. Though I am trying to use @AfterReturning on 2 methods of same class, 1 works when another didn't. Only difference between two methods are number of arguments, where @AfterReturning working for method with one argument. Working @AfterReturning( pointcut = "execution(org.springframework.http.ResponseEntity com.service

Spring AOP with AspectJ - Load time weaving doubts

孤街醉人 提交于 2019-12-13 04:04:52
问题 Reading the Spring AOP documentation (link), I'm having a hard time (maybe also because english is not my native language) understanding these paragraphs. First, I read Further, in certain environments, this support enables load-time weaving without making any modifications to the application server’s launch script that is needed to add -javaagent:path/to/aspectjweaver.jar or (as we describe later in this section) -javaagent:path/to/org.springframework.instrument-{version}.jar (previously

ReentrantReadWriteLock with AspectJ pointcut for every initialized type of MyStructure

徘徊边缘 提交于 2019-12-13 03:41:46
问题 I am struggling to create a ReentrantReadWriteLock with AspectJ for every single object that is constructed and is a type of Mystructure. Here is my source code. The aspect class import org.aspectj.lang.JoinPoint; import org.aspectj.lang.annotation.After; import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Before; import org.aspectj.lang.annotation.Pointcut; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantReadWriteLock; @Aspect

Pointcut confusion with inheritance

房东的猫 提交于 2019-12-13 03:37:13
问题 I am confused by writing a pointcut that matches all executions of a method. I tried the pointcut that should match all method-executions of class Alpha : execution(* Alpha.*(..)) with the following class-hierachy public class Alpha { public void alphaMethod() {...} } public class Beta extends Alpha { public void betaMethod() { alphaMethod(); } } If the Main-program calls alphaMethod on an Beta -instance my advice is called like expected but the Main-program calls betaMethod that also calls

AspectJ 1.9.4 with OpenJDK 11 Without Spring Context not working as a dependent module

北慕城南 提交于 2019-12-13 03:14:42
问题 I am trying to create custom loadtime annotations with AspectJ, Open JDK11 without Spring Context. It works fine within a module and annotations are weaving at class load time and aspects are executing at runtime. No issues, But when aspectJ implemented module added as a dependency on another module. AspectJ and annotations are not processing. Am I missing any configuration? module-a @Documented @Inherited @Target(METHOD) @Retention(RUNTIME) public @interface Counter { String name() default "

Aspect on super interface method implemented in abstract super class

冷暖自知 提交于 2019-12-13 02:59:44
问题 I have a problem quite similar to: How to create an aspect on an Interface Method that extends from A "Super" Interface, but my save method is in an abstract super class. The structure is as follows - Interfaces: public interface SuperServiceInterface { ReturnObj save(ParamObj); } public interface ServiceInterface extends SuperServiceInterface { ... } Implementations: public abstract class SuperServiceImpl implements SuperServiceInterface { public ReturnObj save(ParamObj) { ... } } public

Hibernate | Why is the transaction “half-committed”

我与影子孤独终老i 提交于 2019-12-13 02:57:55
问题 I'm working with Hibernate in a Spring Boot project. I have the following piece of code: public class SomeService { private Dependency dependency; @Transactional(readOnly=false) public void doSomething() { //some BL code... dependency.doSomeDbManipualation(); someOperation(); } public void someOperation() { //some code that eventually fails } } public class Dependency { public void doSomeDbManipulation() { Entity entity = ...; //get the entity from current session by its key if (entity !=