Questions tagged [pointcut]

221 questions
0
votes
1 answer

AOP not invoked by annotation

I am trying to invoke a AOP method for every method that is annotated with @Timed. My AOP MyTracer.java @Aspect public class MyTracer { private static final Tracer tracer = Tracing.getTracer(); private static final Logger log =…
Neil
  • 5,919
  • 15
  • 58
  • 85
0
votes
2 answers

AOP advice called twice apart from first pointcut

I am using annotation based AOP in my Java Spring Application. There is no XML configuration at all (apart from log4j2.xml). My first pointcut gets executed once as expected but every pointcut after that will get executed twice and I can't figure…
Naz Haque
  • 49
  • 4
0
votes
1 answer

Spring AOP pointcut expression for Subclass only method

I have a scenario in which i need to intercept some subclass methods, but i couldn't find a proper pointcut expression to do so. I have a client facing interface InfoService which has a method getClientDetails. package sample; public interface…
Syam S
  • 8,421
  • 1
  • 26
  • 36
0
votes
1 answer

Aspectj "after throwing" - monitor a specific exception

I'm trying to catch all MySpecificException exceptions thrown from an application code via aspectj. There are lots of places where this exception can be thrown. Once the exception is thrown I want to log it or do some operation (regardless if it…
Lin
  • 2,445
  • 5
  • 27
  • 37
0
votes
2 answers

Call aspect based on return value

I am using Spring AOP. This is the sample method: public String method(List ids) { if(ids == null) return "ERROR"; else return "OK"; } My aspect looks like this: @AfterReturning(pointcut = "execution( *…
Sviatlana
  • 1,728
  • 6
  • 27
  • 55
0
votes
2 answers

Spring AOP - Pointcut Not working

I had created a pointcut. But it is not working. Please assist me on the below code. http://www.springframework.org/schema/beans/spring-beans-3.0.xsd …
0
votes
1 answer

spring-boot-starter-aop around annotated interface's method won't advice my aspect

I have the following implementation: public interface BusinessResource { @RequiresAuthorization public ResponseEnvelope getResource(ParamObj param); } and @Component public class BusinessResourceImpl implements BusinessResource { …
romerorsp
  • 123
  • 2
  • 9
0
votes
1 answer

Pointcut expression to get the argument and annotation value

I have a pointcut expression that invokes all methods in a package. Some methods may have annotations and a parameter that needs to get in advice. I tried with something like this @Around("execution(* com.man.test..jmx..*(..)) && args(name,..) &&…
Cork Kochi
  • 1,783
  • 6
  • 29
  • 45
0
votes
1 answer

AspectJ - How to catch constructor call also for subclasses?

I have an abstract class Foo. I want to have a compile error if I create a new instance of a concrete class that extends Foo outside an Aspect named Bar. I tried this: public pointcut errorcall(): call(Foo.new(..)) && !within(Bar); declare error:…
EstevaoLuis
  • 2,422
  • 7
  • 33
  • 40
0
votes
2 answers

Using join points call(* *.*(..)), can I expose the arguments to the advice if available?

With my aspect, I track the changes on certain collections by advising certain method calls on instances of java.util.Set, notably add(Object) and remove(Object). Since the changes are not reflected in the collection itself, invocations of…
Yang Meyer
  • 5,409
  • 5
  • 39
  • 51
0
votes
1 answer

AspectJ - can't override pointcut - parameter types don't match

I have an abstract aspect like this: public abstract aspect GenericAspect { public abstract T createT(Object[] args); abstract pointcut callMethod(Object[] args); T around(Object[] args) : callMethod(args) { return…
EstevaoLuis
  • 2,422
  • 7
  • 33
  • 40
0
votes
1 answer

Pointcut get expression not working in XML

I have a pointcut expression which is working fine when written in java but when written in xml gives error. Since my aspect is written in one project and it's jar is available in other project I have to provide it's mapping in the XML in other…
0
votes
1 answer

aspectj pointcuts on object variable assignment

I would like to create a pointcut on the following sample class whenever a variable gets assigned. So for instance, in method1(int number), this.x gets set to int. I realize in this case I could just make a pointcut on method1 and then find out what…
dinamix
  • 651
  • 8
  • 22
0
votes
1 answer

Aspectj pointcut on spring bean destruction

Is it possible to execute an AspectJ advice in Java that executes when the target object goes out of scope or gets destroyed ? Suppose we have a class which have various methods that are being matched by a pointcut expression and a caching aspect…
roger
  • 269
  • 1
  • 5
  • 20
0
votes
1 answer

Pointcut for a method that can take int/Integer

I am trying to cache an external service. To achieve that I am defining a pointcut. public interface ExternalService { public int getData(int); } Due do some concerns of cache manager not being able to figure out the difference among the…