Questions tagged [pointcut]
The pointcut tag has no usage guidance.
242
questions
0
votes
0answers
9 views
Creating A pointcut using args designator with no types results in BeanCurrentlyInCreationException
Using Spring AOP, when attempting to create a Pointcut using the desginator args while not providing any types results in a series of exceptions starting with BeanCurrentlyInCreationException
The ...
0
votes
1answer
34 views
2 advices colliding on the same fucntion
Hei,
I started learning Aspectj and I have built 2 aspects. Both aspects have a pointcut that match the same function, and both aspects have an around advice that will do something on that pointcut.
...
0
votes
1answer
40 views
AOP AspectJ Pointcut if() throwing ArrayIndexOutOfBoundsException:
I am trying to write an Aspect, trying to implement Pointcut's if() condition but receiving ArrayIndexOutOfBoundsException. here is the code snippet.
@Pointcut("call(* com.aop.Service.activate(..)...
0
votes
1answer
25 views
A spring aop pointcut can filter for the combination of an annotation and a return type?
@Pointcut(Execution(@com.annotions.MyAnnotation void *(..))
Would this be a valid pointcut, if I want only methods to be advised with the @MyAnnotation and have the return type void?
1
vote
1answer
78 views
Why does Spring-AOP pointcut work for save(..) but not saveAll(..)
I have a Spring-Data repository like this:
package com.example.demo;
@RepositoryRestResource
public interface FooRepository extends JpaRepository<Foo, Long> {
@Override
<S extends ...
0
votes
0answers
49 views
AspectJ pointcut method signature in Java code
I have defined an Aspect with the following pointcut
pointcut transactedMethod() : TransactionBoundary.transactedMethod();
This is an alias created for all transactional methods with some error raised ...
0
votes
1answer
69 views
@Aspect - getSignature() is null
I created simple aspect to count how many times specific method is executed. I have to tell that I'm doing it first time so probably it's not really pretty.
First, I created something like that:
@...
1
vote
1answer
62 views
How does this execution pointcut expression work?
I came across an answer from @kriegaex , which I am unable to comprehend.
The pointcut expression I am trying to understand is the following
@Around("execution(* (@MyAnnotation *).*(..)) || ...
0
votes
1answer
28 views
@target pointcut throws IllegalStateException
In Spring boot AOP application I have a pointcut @target(MyAnnotation) || @annotation(MyAnnotation).
Advice should be executed if MyAnnotation is put either on executing object annotated with this ...
0
votes
1answer
155 views
How to create pointcut to feign client that supports interface inheritance?
In a Spring Boot project I have a simple feign client
@MyAnnotation
@FeignClient(name="some-name", url="http://test.url")
public interface MyClient {
@RequestMapping(method = RequestMethod.GET, ...
0
votes
1answer
81 views
Spring AOP pointcut for all public methods of an annotatted class (including parent class methods)
I have two classes
public class ParentTestClass {
public void publicMethodOfParent() {
}
}
@Component
@MyAnnotation
public class ChildTestClass extends ParentTestClass {
public void ...
0
votes
1answer
181 views
How to pass base package as a variable inside pointcut expression in Spring AOP?
I am creating a java library for logging purpose so that if any application uses my library then spring AOP's advices are applied to each method of the application. But in my library, I don't know the ...
0
votes
1answer
27 views
Pointcut matching an annotation's parameter value
Suppose I have an annotation as following:
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface DBOperation
{
boolean isReadOperation() default true;
}
Then in the ...
0
votes
1answer
56 views
Exception: java.lang.IllegalArgumentException: Pointcut is not well-formed Error?
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.stereotype.Component;
@Aspect
@Component
public class MyDemoLogginAspect {
@...
0
votes
1answer
42 views
Spring Aop Applying advice for a specific lines of code of a method
I need to know if we can apply advice(spring AOP) in middle of a method.I read some where that AOP is applicable only for bean method calls.But still i got this question. Please advise.
I got an idea ...
0
votes
1answer
56 views
Pointcut for Inherited methods with super method calls
I have the following classes
class A {
public void someone() {
helpMe();
}
private void helpMe() {
// do something here
}
}
class B extends A {
public void help() {...
0
votes
0answers
45 views
How to use AspectJ annotations: Pointcut params into my android project
Good day, I want to implement AOP into my current android project to track screens and user events using firebase.
But, unfortunately I don't know how to implement it in a proper way as I am using ...
0
votes
1answer
45 views
Avoid overlaping pointcuts and aspects in AOP
In package
com.repository I have :
Standalone interfaces extending spring data Repository
Interfaces extending spring data Repository with my own implementation in the same package
Repository ...
2
votes
1answer
66 views
Create custom method level annotation only available to specific return types [AOP]
I want to create an annotation which is only available to a specific type of return values.
For example this is my annotation.
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD})
...
0
votes
0answers
82 views
How to use a external value in @Pointcut
I am writing a common component for team members.So I write an aspect with Spring-aop.Ideally,what others only need to do is defining an point-cut expression in .properties or others.But I find it is ...
0
votes
1answer
605 views
aspectj pointcut for inherited interface methods
I want to intercept all java.sql.DataSource.getConnection methods with aspectj,
I used this pointcut:
"execution(public java.sql.Connection javax.sql.DataSource+.getConnection(..))"
it works fine.
...
1
vote
1answer
361 views
Spring AOP: @annotation() pointcut does not match type annotation
I'm writing an aspect to log Request and Response of each API call in a controller.
I want to be able to use this annotation on a class, hence used @Target(ElementType.TYPE)
Previously I had added @...
0
votes
1answer
367 views
Conditional on Aspect pointcut execution
I've been thinking of situation like pointcut'ing the pointcut. Let's say I have a situation as follows:
@Around("@annotation(org.springframework.scheduling.annotation.Scheduled)")
public void ...
0
votes
1answer
38 views
Junit test a class with a bunch of @Pointcut
Is there an elegant way to unit test the following class?
public class PointCuts {
@Pointcut(value = "execution(* com.eg.app..*.*(..))")
public void all() {
}
@Pointcut(value = "...
0
votes
2answers
1k views
How to advice static method of java class using Spring AOP?
Some logging needs to be done before and after execution of static method of a class. I tried to achieve this using Spring AOP but it is not working and for normal methods it is working.
Please help ...
0
votes
1answer
132 views
How to combine 2 different annotated methods into a pointcut?
I want to annotated 2 different methods and related them together in order to match the global variable and method which uses it
@FirstAnn(funcName = "foo")
def foo = {
val value = boo()
...
0
votes
1answer
53 views
How to write pointcut with customized annotation to print the global variable value that used in a function?
I'm trying to log all the variables that method used to calculate something but I don't know how can I access to the specific global variables that method used:
@BuAnnotation(funcName = "foo", ...
0
votes
1answer
50 views
Aspect to find all the pointcuts executed at runtime
I need to write an aspect (let's call it A) that shows all the executed pointcuts at runtime. Is there a way to write a pointcut like call(...) that points directly to another pointcut without using ...
0
votes
1answer
66 views
AspectJ - How to log overriden method name instead of superclass method name
I have built a logger class for all my repositories, services and controllers. I am making it log every method call with the following method :
@Before("execution(* com.mdenis.tno..controller..*(..))...
3
votes
1answer
3k views
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()")
...
0
votes
1answer
131 views
AspectJ formal unbound in cutpoint
I have the following classes:
public class Population {
private int population;
public Population()
{
population = 0;
}
public void newYear()
{
population += ...
2
votes
1answer
89 views
Why this syntax error in SpringAOP @pointcut not popping any Error?
I am learning SpringAOP, while I am running basic programs I observed strange behaviour from eclipse(of course compiler).
while I am practising on @Pointcut annotation I mistakenly added another ...
0
votes
1answer
587 views
Pointcut for classes inside different package or sub-packages marked Deprecated and at the time whenever they used or instantiated?
I want to write a point cut for class instantiation in various packages,like classes inside the subpackages inside com.kepler.xenon (eg.com.kepler.xenon.modules.ticklers.pojo.Tickler,
com.kepler.xenon....
1
vote
2answers
597 views
Pointcut or Aspect Around All Service Methods with Annotation @Transactional(readOnly = false)
Is it possible to use Spring AOP or AspectJ to intercept all Service methods (contained in classes in the com.app.service.* package) having the annotation
@Transactional(readOnly = false)
(other ...
0
votes
1answer
219 views
ReentrantReadWriteLock with AspectJ pointcut for every initialized type of MyStructure
I am struggling to create a ReentrantReadWriteLock with AspectJ for every single object that is constructed and is a type of Mystructure. Here is my source code.
The aspect class
import org.aspectj....
0
votes
1answer
240 views
Aspectj (ajc) compiler gives error for method parameter pointcut
I'm using aspectj compile time weaving and I'm trying to apply advice for methods who has annotation applied on any of the parameter.
Method for who I want to apply advice
public void link(String ...
3
votes
2answers
178 views
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 ...
1
vote
2answers
87 views
AspectJ - pointcut advice based on annotated function
I have 2 custom annotations:
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD})
public @interface FlowPoint {
public enum PointInFlow {
START, END
}
PointInFlow ...
0
votes
1answer
899 views
AspectJ with Gradle Pointcut or Advice not working - NOT using spring or android
Hi I am building a library for messaging between AWS components and so I want a lightweight solution. One part of the solution requires me to listen in on when an annotated method is invoked, so I ...
0
votes
0answers
153 views
AspectJ Pointcut Dynamic String Value based on a File content
I want to define a pointcut based on a file content. To be specific, the file would contain the package(s) to be included in the pointcut definition. I intend to read the contents of the file and ...
-1
votes
2answers
279 views
No ServerProperties registered in AspectJ
I am trying to create an advice that will be executed around all the public methods. This is my aspect, point cut expression is being referred from Spring Docs
@Aspect
@Component
public class ...
0
votes
1answer
1k views
AspectJ: Intercept return result of method inside another method
I need help to write some Aspectj advice on this particular case:
Suppose we have this class:
package org.group;
public class Person {
public void method1(String id, String number) {
//...
2
votes
1answer
2k views
pointcut for method in parent abstract class
I have a scenario where my method to be intercepted is in the parent class and is not overridden in the pointcut class.
Here is the sample classes:
public abstract class A{
@RequestMapping(value = "/...
0
votes
1answer
445 views
Pointcut for overloaded methods
If we have overloaded methods with nested calls as below
public void sample(int a) {
sample(a, 5);
}
public void sample(int a, int offset) {
System.out.println(a + offset);
}
There is a ...
0
votes
1answer
69 views
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();
...
0
votes
1answer
581 views
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 ...
1
vote
1answer
3k views
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, ...
1
vote
1answer
450 views
pointcut expression to parse @ModelAttribute as method parameter
I have a @ModelAttribute(key) defined in the @controllerAdvice and i am uisng the same model attribute in multiple controller methods as method parameter because the (key) will be available throughout ...
0
votes
1answer
69 views
My Aspect has two Pointcuts,But there's not work?
All right, I have a problem ,This is my logs Aspect. It's true that he has two Pointcuts .But every time I request the interface, I repeat 4 times.
spring boot version 1.5.10.RELEASE
github:https://...