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

Applying a hibernate filter using Spring AOP

I am trying to apply a filter on a database table using Spring AOP. I want this filter to apply only for this table. I have configured an Aspect to apply the filter but I must have configured something incorrectly. The joinpoint functionality never…
Jack Kerry
  • 11
  • 2
1
vote
1 answer

AspectJ Plugin Aspect Config with Maven using external Jar for Aspect

I am using Perf4j to do performance logging. It specifies that you use aop.xml to define which Aspect you want to be called at compile time depending on which logging system you are using. I cannot get it to pick up the aop.xml file which is in…
DeliveryNinja
  • 827
  • 2
  • 12
  • 28
1
vote
0 answers

How to get the environment variable in SessionCustomizer using eclipselink?

I am trying to dynamically set the schema for my JPA entity objects using SessionCustomizer. I have the schema name defined in the properties file. I am trying to read from the environment object but the environment object is not available inside my…
DarkCrow
  • 785
  • 2
  • 8
  • 29
1
vote
0 answers

Springboot Load-Time Weaving doesn't allow to inject a spring bean into an aspect for embedded Tomcat when devtools is used

I'm using pretty recent springboot v1.5.2 with aspectj's (v1.8.10) load time weaving. I was able to inject a spring bean into my aspectj aspect while running my application on an external tomcat and now I wonder why just the same failed for the…
1
vote
2 answers

Convert aspect to native AspectJ notation

I have this aspect: public privileged aspect Teste { private ISupermarket supermarket; @AfterReturning(pointcut = "execution(* ca1.business.SupermarketFactory.createSupermarket(..))", returning = "result") public void…
undisp
  • 711
  • 3
  • 11
  • 34
1
vote
1 answer

Spring AOP: differences between && and 'and'

I have this interface: public interface Performance { public void perform(); } Implemented by this class: @Component public class PerformanceImplementation implements Performance { public void perform() { …
acejazz
  • 789
  • 1
  • 7
  • 27
1
vote
1 answer

Spring AOP not working

I am trying to create some annotations which check permissions from the securitycontext before accessing some protected resources. I wrote a sample code very similar to what I would want to implement, however when I invoke SomethingProtected(), it…
user3408657
  • 179
  • 1
  • 3
  • 13
1
vote
0 answers

unable to use @AspectJ with Spring-Apache CXF services

I am new to spring and am working on a rest service written using Spring and Apache CXF with Java Configurations. I have the following rest service. @Path("/release/") @Component @RestService @Consumes({ MediaType.APPLICATION_JSON }) @Produces({…
vamsi
  • 325
  • 5
  • 15
1
vote
1 answer

Intercept method declaration

I have the following method: @OnEvent public void onEvent(Event event) { } Now, I am puzzled whether AspectJ can intercept the method "declaration", i.e. neither its call nor its execution, in order to provide functionality somewhere else. The…
erdal.karaca
  • 693
  • 1
  • 4
  • 20
1
vote
2 answers

Spring AOP - How to get annotation of parent(caller) method

@Before(value="@annotation(com.aspect.Loggable)",argNames="taskId") public void logEmail(JoinPoint joinPoint) { System.out.println("@Before is running!"); System.out.println("hijacked : " + joinPoint.getSignature().getName()); …
Mohan Lal
  • 41
  • 1
  • 6
1
vote
3 answers

How to ignore parameters with javax annotation when calling joinPoint.getArgs using Aspectj?

I have functions that include different javax Query annotations like : @QueryParam , @Context , @PathParam etc.. is there a way to exclude these parameters when calling joinPoint.getArgs()? Example: @POST …
user1386966
  • 3,302
  • 13
  • 43
  • 72
1
vote
2 answers

Custom Java annotation to skip the method execution

I want to create a custom annotation to skip method execution This is my annotation code, with the validator class @Target({ METHOD , FIELD , PARAMETER } ) @Retention(RetentionPolicy.RUNTIME) @Constraint(validatedBy={MyValidator .class}) public…
Ashish Shetkar
  • 1,414
  • 2
  • 18
  • 35
1
vote
1 answer

Spring AOP - ProceedingJoinpoint - MethodSignature Downcast

Is there a way to get the MethodSignature from a ProceedingJoinPoint without downcasting? private String toEventString(ProceedingJoinPoint pjp) { MethodSignature methodSignature = ((MethodSignature)pjp.getSignature()); StringBuilder…
aglassman
  • 2,643
  • 1
  • 17
  • 30
1
vote
1 answer

AspectJ- combining method annotation and set field

I have a requirement where in I need to time various method calls into a time series db. For the same, I have created 2 annotations one for the method call: @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) public @interface Auditable…
Sagar
  • 229
  • 4
  • 14
1
vote
2 answers

Full AspectJ support in Spring

I'd like to weave an advice on a method that is NOT part of a Spring bean (Spring Boot 1.4.4.RELEASE) : @Component @Aspect ... @Around("execution(public * com.netflix.appinfo.InstanceInfo.getId())") I added aspectjrt and spring-instrument (??)…
Thomas Escolan
  • 985
  • 1
  • 8
  • 17