Questions tagged [aspectj]

AspectJ is an aspect-oriented extension to the Java programming language that enables clean modularization of crosscutting concerns such as logging, error handling, standards enforcement and feature variations. Use this tag for questions about the programmatic use of this extension. For downloads, support, IDE integration, & documentation, see the "learn more" for this tag.

AspectJ is an Aspect-Oriented Programming (AOP) extension to Java, created by Xerox, that has as main components aspects (consisting of pointcuts and advices) and join points.

For AspectJ Eclipse integration, also see AspectJ Development Tools (AJDT); for NetBeans integration, see AspectJ in NetBeans; for IntelliJ IDEA integration, see IDEA Web Help.

Books:

Documentation:

3304 questions
1
vote
1 answer

AOP - @Pointcut syntax: how define the method with a superclass argument/parameter

I am working with Spring Framework and AspectJ version 1.8.9 I have many Service classes, lets consider for example CustomerServiceImpl InvoiceServiceImpl CarServiceImpl The point is, each one has a saveOne method. Therefore saveOne(Customer…
Manuel Jordan
  • 15,253
  • 21
  • 95
  • 158
1
vote
2 answers

How to use AspectJ to log different data, conditionally?

I am pretty new to AspectJ and AOP in general. I do know that AspectJ has many Annotations (After, AfterReturning, etc) to execute code before a method is called, after it is called, after it returns, when an exception is thrown, etc. I would like…
Robert Bowen
  • 487
  • 2
  • 13
  • 24
1
vote
1 answer

Reading class property name and value in Aspectj advice

Is it possible to read the class property name and value in Aspectj advice while having the properties as the pointcuts. Below is the code snippet . JAVA code: package com.test; public class Test { static List list; static…
ashishakp
  • 111
  • 1
  • 8
1
vote
0 answers

How to declare variable only for the invoked method via AspectJ?

I know AspectJ can declare inter-type, but I want to declare a variable inner TestMain.test method, thus only that method can get it but all of other methods can't get the variable. public aspect GetParams { public int TestMain.anInt = 2; // I…
Cuero
  • 1,169
  • 4
  • 21
  • 42
1
vote
1 answer

Use spring security expressions in custom annotation

Hi I have a project with Spring boot + Spring Security. I am building a custom annotation which I have defined like this: @Retention(RUNTIME) @Target(METHOD) public @interface CustomAnnotation { String condition(); String[] fields() default…
Deibys
  • 619
  • 3
  • 9
  • 18
1
vote
3 answers

Overwrite method argument in AspectJ

I have an aspect intercepting the logging method. That logging method is a simple method taking one object as an argument: logMessage(Object message) How can I modify that object in my aspect and log a new one? Following does not work: void…
CorrieSparrow
  • 521
  • 1
  • 6
  • 23
1
vote
1 answer

Aspectj functions through external library

I have an external library which is not an spring application. It defines few Aspectj functions/PointCuts but it is not getting called when i am using this library in an spring boot application. When i define the pointcuts in spring boot…
Rakesh Yadav
  • 369
  • 3
  • 5
  • 19
1
vote
0 answers

How to advise EJB authorization calls with AspectJ?

I'm trying to log all EJB method authorization calls, but am having some difficulty configuring my aspect to be called. I've created my pointcut as generically as possible to advise my EJBs directly, but I'm not having success. Primarily, I need…
Eric B.
  • 23,425
  • 50
  • 169
  • 316
1
vote
2 answers

iajc weave particular aspects using aspect path

I have a library(say lib1) which comprises of a couple of aspect classes(say aspect1.java and aspect2.java). I want to weave only aspect1.java in my service code. Is this possible using ant iajc target in compile time weaving ? I know this is…
roger
  • 269
  • 1
  • 5
  • 20
1
vote
1 answer

Performance penalty for using AspectJ

I want to create an annotation for sending timer metrics for my methods. I thought about doing something like that: @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) public @interface Timer { } And then I want to use AspectJ for…
Avi
  • 21,182
  • 26
  • 82
  • 121
1
vote
1 answer

Can not build thisJoinPoint lazily for this advice since it has no suitable guard

What is a "suitable guard" and what does it look like? Linked this question because it refers to the same compiler message and the answer mentions a guard but not how to create one. Looked through the AspectJ docs but did not find and answer there.
cb4
  • 6,689
  • 7
  • 45
  • 57
1
vote
1 answer

aspectj timer for non blocking IO calls

I am trying to implement an aspect to time method execution for NIO. Basically, I need to get the time when a method is initially called and then when a callback is triggered (the callback is always either a failed() or succeeded() call - so I need…
zzztop
  • 23
  • 5
1
vote
1 answer

Expression for Parametrized annotation AspectJ

Trying to created a point cut which take parameter from annotation and then can use it further.So far I have reached: pointcut callDemoAspectPointCut(): call(Papa+.new()) && @within(MyAnnotation); //With param here after() returning(Object…
xyz
  • 2,160
  • 3
  • 20
  • 31
1
vote
1 answer

Get the name of a concrete class within aspectJ advice

I am attempting to use aspectJ to intercept calls to public methods on classes which implement my Loggable interface. Loggable is a marker interface and defines no methods. I have a before advice, in which I want to get the name of the Concrete…
DaveH
  • 7,187
  • 5
  • 32
  • 53
1
vote
1 answer

@AspectJ aspects not being weaved in application that uses Spring

I have added the line to my application-context.xml, and have created a META-INF\aop.xml file with the following:
jhwang
  • 43
  • 7