aspectj

Injected bean reset to NULL in the Aspect

杀马特。学长 韩版系。学妹 提交于 2019-12-11 18:39:48
问题 I am new Spring AOP and Aspectj . I have seen various posts related to injected bean in an aspect being null and I have run into a similar problem. I am still not clear how I should proceed to get past the problem I am currently encountering. Issue: Currently we are using Spring 3.2.3 and all injection is through Annotation. In my case, the dependent bean is injected properly by Spring but at the point of execution the injected bean is NULL. BTW, this doesn't happen all the time but what I

Can I use an annotation to modify a annotated property?

半世苍凉 提交于 2019-12-11 18:32:35
问题 Given class MyPOJO { @XssSanitized() String name } @Retention(RetentionPolicy.RUNTIME) @interface XssSanitized { } import org.aspectj.lang.annotation.Aspect @Aspect @Slf4j @Component class XssSanitizedAspect { @Around("@within(com.es.phoenix.services.security.XssSanitized))") void sanitize(){ //capture the value of the annotated String //make an arbritary change to the string //return modified string or otherwise overwrite the property log.info("XssSanitizedAspect is working!!!!") } } Is it

How to configure aspectj ignore getters and setters

北战南征 提交于 2019-12-11 16:59:28
问题 I have an aspect that currently works to capture all public method executions within my package. I would like to modify that to exclude both setters and getters, so I tried that and these are the variants I tried: This one works, but does obviously does not do anything for setters or getters. @Around("execution(public * *(..)) && !within(com.walterjwhite.logging..*)") This does not compile: @Around("execution(public * *(..)) && !within(* set*(..))") This compiles, but doesn't prevent

Pointcut expression 'if()' contains unsupported pointcut primitive 'if'

可紊 提交于 2019-12-11 15:27:49
问题 I am using AspectJ in my Spring boot project for AOP. I have declared a if() point cut: public class myPointCuts { // a global boolean variable, value can be updated at runtime. public static boolean IS_RESULT_FINE; @Pointcut("if()") public static boolean isResultFine() { return IS_RESULT_FINE; } } At compile time, I get error: Initialization of bean failed; nested exception is org.aspectj.weaver.tools.UnsupportedPointcutPrimitiveException: Pointcut expression 'if()' contains unsupported

Issue with AOP and JMX without Spring

爱⌒轻易说出口 提交于 2019-12-11 12:46:18
问题 I wrote an program to trace the performance of an application using AspectJ with a requirement that the tracing can be enabled or disabled at runtime using JMX so that i can change the value using jconsole/HtmlAdaptorServer. Now again i have to keep the Pointcut in AOP.xml file so that we can change the poincut when need. As soon as I am kepping the pointcut in aop .xml file nothing happens.Below is the code please let me know what to do or what am I missing. Since I am using JMX here I am

Spring AOP Advice for Hibernate managed POJO

爷,独闯天下 提交于 2019-12-11 12:14:30
问题 I have a parent-child relationship, such as Order to Order Item, which I have represented in the domain model like this: public class Order { private int id; private Set<OrderItem> orderItems = new HashSet<OrderItem>(); public int getId() { return id; } public void add(OrderItem orderItem) { orderItems.add(orderItem); } } public class OrderItem { private int id; public int getId() { return id; } } I am persisting these entities with Hibernate, using a mapping like this: <class name="Order"

Pointcut expression 'abc(inString)' contains unsupported pointcut primitive 'call'

独自空忆成欢 提交于 2019-12-11 12:14:24
问题 I am new to spring-aop concepts. I am getting this error during compilation. org.aspectj.weaver.tools.UnsupportedPointcutPrimitiveException: Pointcut expression 'abc(inString)' contains unsupported pointcut primitive 'call' My aspect is, @Aspect @Component public class BeforeAdvice { @Pointcut(value="call(@com.app.test.EncryptDemo * *(String)) && args(inString) && !within(com.app.test.BeforeAdvice)",argNames="inString") public void abc(String inString) {}; @Around(value = "abc(inString)"

Play 2.1 / taking in account a javaagent while running tests

人走茶凉 提交于 2019-12-11 12:08:40
问题 My goal is to launch my integration tests contained within my Play app. To do so, I used to launch them through Intellij. Those tests needs Spring aspectJ weaving, thus I precised in my Intellij test conf this VM argument: -javaagent:/Users/myName/.ivy2/cache/org.springframework/spring-instrument/jars/spring-instrument-3.2.2.RELEASE.jar The whole works. Now I want to be able to launch them through command-line using the simple play command following by test-only command. First I read this

Spring factory-method=“aspectOf” is not working when we deploy the application from RAD

偶尔善良 提交于 2019-12-11 12:08:39
问题 We are using AspectJ with Spring support. I have declared my aspect in my ApplicationContext.xml as below. <context:annotation-config /> <context:spring-configured /> <context:component-scan base-package="com,com.util"> <context:exclude-filter type="regex" expression="com.xyz*.*" /> </context:component-scan> <bean id="xyz" class="com.util.XyzAspect" factory-method="aspectOf"/> Aspect Class: @Configurable @Aspect public class XyzAspect { @Autowired private XyzUtil xyzUtil; @After("showPoint()

Can cflow in aspectJ detect cross-thread execution?

余生长醉 提交于 2019-12-11 11:49:48
问题 Problem I want to print out the request url and response before running all calls to method public class UpdateRequester { private void throwMessage(String requestUrl, String page) { //Some code inside } } the method will be called is in the Test class: public class Test { public void testUpdate() { Executors.scheduleWithFixedDelay(new Runnable() { public void run() { //It will call throwMessage sometimes in the future } }, ...); } } so I designed an aspect: public aspect TestUpdate { static