Questions tagged [pointcut]

221 questions
107
votes
18 answers

Spring AOP: What's the difference between JoinPoint and PointCut?

I'm learning Aspect Oriented Programming concepts and Spring AOP. I'm failing to understand the difference between a Pointcut and a Joinpoint - both of them seem to be the same for me. A Pointcut is where you apply your advice and a Joinpoint is…
Saurabh Patil
  • 4,170
  • 4
  • 32
  • 33
31
votes
2 answers

Spring AOP pointcut that matches annotation on interface

I have a service class implemented in Java 6 / Spring 3 that needs an annotation to restrict access by role. I have defined an annotation called RequiredPermission that has as its value attribute one or more values from an enum called…
Sean Patrick Floyd
  • 292,901
  • 67
  • 465
  • 588
26
votes
10 answers

AspectJ expression gives formal unbound in pointcut error

I have within aspectJ the expression: @Pointcut("within(com.param.cpms.dao.impl.ProjectMetaDaoImpl)") public void daoExceptionHandle() { } At Spring 3.0 startup, I am getting the following error : nested exception is…
param
  • 261
  • 1
  • 3
  • 3
23
votes
4 answers

How to specify single pointcut for multiple packages

I am using Aspect for logging activities in my spring mvc based application. I am using @controller annotations to define any controller in my application. I have two different controller in two different package say com.package1 contains…
Ketan
  • 2,612
  • 5
  • 31
  • 44
22
votes
1 answer

Spring AOP - pointcut for every method with an annotation

I am trying to define a pointcut, that would catch every method that is annotated with (i.e.) @CatchThis. This is my own annotation. Moreover, I'd like to have access to the first argument of the method, which will be of Long type. There may be…
emesx
  • 12,555
  • 10
  • 58
  • 91
21
votes
5 answers

Spring AOP pointcut for annotated argument

Say I have a method like so: public void method(@CustomAnnotation("value") String argument) Is there a pointcut expression that could select all methods with arguments annotated with @CustomAnnotation? If so is there a way I could get access go…
mogronalol
  • 2,946
  • 8
  • 38
  • 56
20
votes
3 answers

@AspectJ pointcut for methods that override an interface method with an annotation

How can I write an aspectj pointcut that applies to method executions which override an interface method with an annotation? For example: interface A { @MyAnnotation void method(); } class B implements A { void method(); } The pointcut…
Dr. Hans-Peter Störr
  • 25,298
  • 30
  • 102
  • 139
17
votes
3 answers

Getting a return value or exception from AspectJ?

I am able to get the signature and arguments from advised method calls, but I cannot figure out how to get the return values or exceptions. I'm kind of assuming that it can be done in some way using around and proceed.
Smern
  • 18,746
  • 21
  • 72
  • 90
16
votes
3 answers

Spring pointcut designators differences (within vs execution)

Please... can anybody explain me what are the differences between using the following spring pointcut designators? Using "within pointcut designator": Using "execution…
glazaror
  • 171
  • 1
  • 1
  • 3
14
votes
3 answers

Spring AOP pointcut for all methods in a controller

I want to run some code before every method in a Spring (3.2.3) @Controller. I have the following defined but it won't run. I suspect the pointcut expression is incorrect. dispatcher-servlet.xml
Goose
  • 802
  • 1
  • 10
  • 22
12
votes
1 answer

This() vs Target() aspectj

Can anyone explain the difference between this() and target() pointcuts in aspectj. I tried finding this elsewhere but there doesnt seem to be a clear cut answer. Thank You
Sam
  • 293
  • 3
  • 19
12
votes
2 answers

Pointcuts on inherited methods (in a class design-agnostic context)

I am fiddling around with AspectJ and came up with an idea that I don't seem to be able to implement properly (story of my life). I have defined an aspect : package my.package; import org.aspectj.lang.annotation.*; import…
Ar3s
  • 2,237
  • 2
  • 25
  • 47
10
votes
3 answers

exposing previous value in AspectJ set-pointcut

I have to detect fields value changes. I want to compare the previous value with the new one. I don't know the field name or its type. (More background here.) For sample given class: package…
zacheusz
  • 8,750
  • 3
  • 36
  • 60
9
votes
1 answer

Aspects scanning too many classes and method cache fills memory

In our application we have several (actuall many, about 30) web services. Each web service resides in its own WAR file and has its own Spring context that is initialised when application starts. We also have a number of annotation-driven aspect…
Andrey Adamovich
  • 20,285
  • 14
  • 94
  • 132
8
votes
2 answers

Spring AOP pointcut is not well formed

Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.aop.aspectj.AspectJPointcutAdvisor#0': Instantiation of bean failed; nested exception is …
Aubergine
  • 5,862
  • 19
  • 66
  • 110
1
2 3
14 15