Questions tagged [pointcut]

221 questions
3
votes
1 answer

Add aspect to implementation class not interface

We have a class which implements several interfaces. We would like to add some pointcut for the entire class - not for a particular interface of it. How it can be done with Spring AOP? Is it possible to apply an aspect to non-interface class?
jdevelop
  • 12,176
  • 10
  • 56
  • 112
3
votes
2 answers

Various pointcut expression scopes trigger multiple advice calls unexpectedly

Background Logging a project using aspects such that all methods, classes, and constructors that are marked with the @Log annotation have information written to a log file. Problem Methods appear to be called recursively one-level deep, but the code…
Dave Jarvis
  • 30,436
  • 41
  • 178
  • 315
3
votes
1 answer

Wildcard support on package name in Spring AOP pointcut expression

I'm trying to implement a logger aspect that can be applied across multiple packages in my application. It is a big spring web application having many modules. Each module has it's own controllers, services and DAOs. The pointcuts I define targets…
Master Po
  • 1,497
  • 1
  • 23
  • 42
3
votes
1 answer

AspectJ pointcut on method in Spring CrudRepository

I'm using Spring's CrudRepository in combination with the annotation @RepositoryRestResource to implement a simple CRUD-app that can be used throught a RESTful API. I now want to add an AspectJ pointcut on my repository, so that some functionalities…
3
votes
1 answer

Aspectj default constructor pointcut

Im working with some AspectJ code and i want to catch all the executions for none private pointcuts. @Pointcut("execution(public * *(..))")//Public public void publicMethod(){}; @Pointcut("execution(protected * *(..))"//Protected public void…
Nosfert
  • 382
  • 1
  • 3
  • 11
3
votes
2 answers

Spring AOP - get old field value before calling the setter

Dear all I am curently using Spring AOP (v4) and AspectJ with load-time-weaver. I am looking currently for a way to add a dirty flag mechanism into my beans. Therefore I I though of using AOP to call a method before a setter of my beans get called.…
megloff
  • 1,400
  • 4
  • 27
  • 44
3
votes
1 answer

Spring AOP Pointcut expression for custom annotation in subclass

I am working on a logging aspect which need to intercept all the classes and methods annotated with a custom annotation. Below is custom annotation class which can be annotated on class and…
user1300877
  • 169
  • 1
  • 3
  • 11
3
votes
1 answer

Reading and understanding AspectJ pointcuts?

/* 0 */ pointcut services(Server s): target(s) && call(public * *(..)) This pointcut, named services, picks out those points in the execution of the program when Server objects have their public methods called. It also allows anyone using the…
Christian
  • 6,070
  • 11
  • 53
  • 103
3
votes
2 answers

Define pointcut to capture an interface but not parent or sub interfaces

I was wondering how to define a pointcut in aspecJ that captures any method of an interface but not the methods of any parent or sub-interface. public interface A { void methodA(); } public interface B extends A { void methodB(); } public…
mR_fr0g
  • 8,462
  • 7
  • 39
  • 54
3
votes
1 answer

Spring pointcut involving ignoring a class

I have a point cut for all classes in Spring AOP like @Pointcut("execution(* com.company.app..*(..))") Now I need to exclude a class say com.company.app.IgnoreClass. Can someone please help me write the pointcut?
JD7
  • 45
  • 1
  • 5
3
votes
2 answers

spring AoP, pointcut expression for overloaded methods with same parameter types

I've defined a class for CRUD operations on comments. The read method is overloaded. class Comment{ // method 1: returns all the comments by a user findAll(long userId, long subjectId, String param); // method 2: returns all the…
Tushar Mishra
  • 1,370
  • 1
  • 12
  • 20
3
votes
3 answers

advice defined has not been applied : Aspectj Pointcut

I'm trying to create an annotation to log all methods in annotated class, but I have a problem with my pointcut, it's not applied (AspectJ version 1.7.4, aspectj-maven-plugin version 1.7). (advice defined in com.test.util.log.Logger has not been…
Anas Lachheb
  • 441
  • 4
  • 17
3
votes
2 answers

AspectJ - Multiple @annotation Pointcut

I can't make a pointcut with "||" operator and multiple annotations. I'm trying to create a Pointcut for some JBehave annotations (@Given, @Then, @When). This works fine: @Pointcut("@annotation(given)") public void jBehaveGivenPointcut(Given…
user3723501
  • 41
  • 1
  • 3
3
votes
1 answer

AspectJ pointcut on all methods of a list of classes

I want to log entry to all methods from a list of classes (which could belong from different packages). Note that the methods should belong to the specified classes only. I've tried the following but these do not work (1) Using if() pointcut Here I…
user3613747
  • 105
  • 2
  • 8
3
votes
1 answer

Binding annotation objects to advice body

I was able to get the @annotation pointcut work for my basic needs. @Pointcut ("@annotation(path.to.my.CustomAnnotation)") public void actionAnnotatedPointCut() {} But when I try to bind it to the advice body like below, I get the…
mystarrocks
  • 4,040
  • 2
  • 36
  • 61
1 2
3
14 15