Questions tagged [pointcut]

221 questions
7
votes
1 answer

Get specific header parameter using Spring AOP?

I have created Spring Boot REST API where all endpoint will have header parameter "sessionGuid". I would like to print that sessionGuid using AOP. @Before("PointcutDefinition.controllerLayer()") public void beforeAdvice(JoinPoint joinPoint) { …
Thiagarajan Ramanathan
  • 1,035
  • 5
  • 24
  • 32
7
votes
1 answer

java.lang.IllegalArgumentException: error Type referred to is not an annotation type

I got the following advice :- @Before(value="@annotation(loggable)", argNames="joinPoint, loggable") public void before(JoinPoint joinPoint, Loggable loggable) { Class clazz = joinPoint.getTarget().getClass(); …
Sanjeev
  • 215
  • 2
  • 4
  • 12
7
votes
1 answer

How to match methods which do not have a specific Annotation in AspectJ

I have a custom Annotation called @Invisible. Now I want to match all calls an a method which DOESN'T HAVE an @Invisible Annotation. How can i do this? (with annotation style development) My first try…
Moonlit
  • 5,171
  • 14
  • 57
  • 95
6
votes
1 answer

How to specify single pointcut for all classes that extend a specific class

I have multiple classes from different packages that extends a class Super. And i want to create an AOP pointcut around that match all the methods in all classes that extends Super. I have tried…
junior developper
  • 448
  • 2
  • 19
  • 40
6
votes
1 answer

Xlint:invalidAbsoluteTypeName

I see the below Spring framework exception while server start-up ** > Initialization of bean failed; nested exception is > java.lang.IllegalArgumentException: warning no match for this type > name: com.java.site.admi.controllers.HomeController >…
Shyam
  • 63
  • 1
  • 1
  • 3
6
votes
1 answer

How to avoid hitting pointcut twice when the cut is on a superclass, but a derived class overrides?

It's tough to make a concise title for this. Anyway, imagine I have a parent class: public class Shape { public Dimensions getDimensions() { // Does some generic stuff. } } I have a derived class from it that…
Depressio
  • 1,329
  • 2
  • 20
  • 39
5
votes
2 answers

AspectJ pointcut on method variable, is it possible?

I have been using AspectJ for a while and it works great on object scope fields containing annotations. I just ran into a situation where I want to annotate a variable of method scope that will work with my pointcut but I am having trouble with…
smuggledPancakes
  • 9,881
  • 20
  • 74
  • 113
5
votes
1 answer

nullpointer exception in aspectJ example

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…
Atom
  • 768
  • 1
  • 15
  • 35
5
votes
2 answers

AspectJ pointcut on constructor object

I need to inject few methods to every initialized object using AspectJ. I thought using this : pointcut vistaInjection(Object o) : initialization(java.lang.Object.new() ) && target(o) && !within(objectAspect); before(Object o):…
Marosh
  • 63
  • 1
  • 1
  • 3
5
votes
0 answers

Pointcut for all methods of a class including inherited ones

I am playing around with aop and aspectj and discovered an (for me) unexpected behavior. In the aspectj-docs I found the following example-pointcut: execution(public void Middle.*()) for the following class-definitions (I slightly changed the…
thomas
  • 5,637
  • 2
  • 24
  • 35
4
votes
1 answer

Spring AOP, pointcuts triggered according to path variable name

I would like to have one of my pointcut being triggered according to how I name a path variable in my URL. The fact is that it is a String and I don't want my pointcut to be triggered on every String.…
Rlarroque
  • 1,900
  • 1
  • 17
  • 27
4
votes
1 answer

Pointcut annotation vs Final String

So I'm studying tutorial on Spring AOP and when the concept of pointcut annotations was explained I thought "why not use final private String?". I've looked up but didn't find anything that might explain why use the overhead of pointcut? with…
Andrii Plotnikov
  • 3,022
  • 4
  • 17
  • 37
4
votes
2 answers

AspectJ Handling of Multiple Matching Advices

I am using AspectJ in Java to log the calls to some methods. I've looked online but couldn't manage to find an answer to this: What happens when two @Around advices match for a method? Specifically, I am using two @Around advices, like…
Vlad Schnakovszki
  • 8,434
  • 6
  • 80
  • 114
4
votes
1 answer

Aspectj declare error not working properly

I am trying to capture a method signature change and throw an error when it happens. But the declare error is not working as expected @DeclareError("call(* a.b.C.method(..)) && !call(* a.b.C.method(int))") public static final String errorMsg=…
3
votes
1 answer

Clarification around Spring-AOP pointcuts and inheritance

Given the following example classes in my.package... public class Foo { public void logicNotInBar() {/*code*/} public void logicBarOverrides() {/*code*/} } public class Bar extends Foo { public void logicBarOverrides()…
Andrew White
  • 52,720
  • 19
  • 113
  • 137
1
2
3
14 15