Questions tagged [aop]

AOP stands for Aspect-Oriented Programming. Use this tag if your question is about aspect-oriented concepts and techniques, or for programming problems using AOP extensions in any language. AOP increases modularity by allowing the separation of "cross-cutting concerns" into aspects. Click learn more... to find out what it's all about.

Filter by
Sorted by
Tagged with
2 votes
0 answers
26 views

Missing argument when using @AfterReturning spring aop

I have the following spring bean: @Component @Aspect public class AuditAspect { private static final Logger auditLogger = LoggerFactory.getLogger("auditLogger"); private List<...
chunkynuggy's user avatar
1 vote
0 answers
47 views

Aspect AOP not intercepting all methods within pointcut

I have created an aspect for the purpose of error logging and reporting within a microservices system but it is not intercepting all the methods that throw an exception within the pointcut. import ...
nova_rem's user avatar
1 vote
0 answers
31 views

Global transaction event handling in Micronaut 3

I want to register a global transaction before commit event handler on Application startup. What is the best way to do this? I tried @TransactionalEventListener annotation but this requires a call to ...
Harri Juus's user avatar
0 votes
0 answers
22 views

Spring AOP: How to invoke code before transactional method invocation, but after transaction begin?

We need to perform some operations just before any transactional method invocation (insert*, update*, ...), BUT - it's important - after the transaction begin. We used to do it for years in that way: ...
Wallie's user avatar
  • 11
0 votes
0 answers
13 views

Why using custom repeatable annotation as AOP pointcut in Springboot doesn't work? [duplicate]

I used the custom annotation @SendMessage as the pointcut for my aspect, and since a method may send multiple messages, I set the @SendMessage annotation to Repeatable, defined @AfterReturning in my ...
Iceberry's user avatar
0 votes
1 answer
45 views

Spring AOP @Afterreturning aspect blocks api call

I have an @Afterreturning aspect. @AfterReturning(value = "@annotation(****)",returning = "returnValue") public void auditableUponReturn(final JoinPoint joinPoint, Object ...
Bishal Thapa's user avatar
0 votes
0 answers
14 views

AOP Socket.io Java [duplicate]

`I use AOP for API controllers, services, or any classes, and it works for all of them. However, with socket.io, it doesn't work @Aspect @Component @Slf4j public class ExecutionTimeLoggerAspect { @...
Chau Du's user avatar
0 votes
1 answer
46 views

AspectJ in back-end Java thread with POM based weaving [duplicate]

I have a back-end thread, which I created inside start method of JBoss Mbeans: public interface HScannerServiceMBean { public void create(); public void start(); public void stop(); public ...
Imran Khurram's user avatar
0 votes
0 answers
13 views

Aspect library in project using jar dependency

Some library "X" is used by many clients. Clients are Spring Boot apps. I want to aspect this library "X" and use by condition in clients as jar dependency so each time when client ...
Serw's user avatar
  • 1
2 votes
1 answer
85 views

What's idiomatic way to decorate set of methods in Kotlin

Python programmer getting familiar with static compilation world of java/kotlin is here. Here is a problem I'm trying to solve. I have a web-service client which provides bunch of methods to interact ...
sunprophit's user avatar
  • 1,659
0 votes
1 answer
31 views

AspectJ AfterReturning Advice Not Displaying Output in Spring AOP

I'm trying to use Spring AOP with AspectJ to display an "After method" message using @AfterReturning advice. I've created an afterMethod aspect class, but the output isn't being displayed as ...
Kelvin Huynh's user avatar
0 votes
0 answers
42 views

How to intercept method calls in Unity (game engine)

I have many types with many methods with the same signature and the same body in my project. all of them pack (serialize) their arguments, send them to the server, wait for the result, and unpack the ...
Mokhabadi's user avatar
  • 304
0 votes
0 answers
70 views

for single HTTP request getting Different TraceId's in Micrometer

currently using spring 3.1.2 and getting different traceId for the single request I have added below dependencies in build gradle: implementation 'io.micrometer:micrometer-tracing-bridge-brave' ...
jcrshankar's user avatar
  • 1,165
0 votes
0 answers
38 views

problem with java 17, spring AOP when i call soap service

i got this error when i try to call my saop service. i am in java 17 and i use jakarta(xml.bind, activation...), com.sun.xml.ws rt , jaxvs-ri, jaxb-runtime jaxb-impl. java.lang.ClassCastException: ...
RIf's user avatar
  • 1
1 vote
1 answer
50 views

C# Type Conversion From Object to a Type which Keeps as Type and Determines at the Runtime

I would like to use an interceptor to intercept some methods on the service layer in my project. Be able to do that I am using Castle Dynamic Proxy and Autofac Aspect Interceptor selector. I am trying ...
Canberk's user avatar
  • 11
1 vote
1 answer
77 views

AspectJ weave external dependency code, repackage jar and force dependency users to use it

Let's say I have a common multi-module maven project which modules are used as dependencies across bunch of the projects, I want to weave my Aspects into Hikari dependency classes and make this logic ...
Tovarisch's user avatar
0 votes
1 answer
43 views

AspectJ in multithreading

Currently im working on a application that runs the same process(with different input parameters in this case TaskInformation) parallelly on 16 threads. I would like to create Aspect from which i ...
DengerZone's user avatar
0 votes
0 answers
30 views

How to use aspect oriented programming in a multi project java/scala repo built using Bazel

So I am fairly new to Bazel and I am migrating my code from gradle. My code is a Java project which has multiple modules in it. I am using AOP to intercept calls made to a particular function (not my ...
Ruchir Jain's user avatar
2 votes
0 answers
37 views

Custom Annotation with AOP is affecting GetMapping annotation

I implemented a custom annotation with AOP to add on additional behavior. The usage is something as follows: @GetMapping(path="/my/path/{date}/{text}", produces = MediaType....
chunkynuggy's user avatar
0 votes
2 answers
72 views

Why a @Pointcut name method can't be overloaded?

For Spring Framework 6.0.11 about AOP, having public class CienciaPointcut { @Pointcut("execution(* com.manuel.jordan.service.CienciaService.find*(..))") public void ...
Manuel Jordan's user avatar
0 votes
0 answers
34 views

Error invoking methods on EJB in WebLogic 12c: AOP configuration issue

I'm encountering an error when invoking a method on an EJB named "IndexingFacade" in a WebLogic 12c environment. During remote debugging, I can confirm that the correct EJB is being loaded. ...
Jalal Sordo's user avatar
  • 1,615
0 votes
1 answer
89 views

How to create a custom annotation like @PathVariable that modifies/provides the value of a method parameter

I want to make a custom annotation that like @PathVariable, will be used on a parameter to provide values to a method like so: public String subscribe(@PathVariable String date, @PathVariable String ...
chunkynuggy's user avatar
0 votes
1 answer
50 views

@Aspect in spring

I try use @Aspect in spring application. I would like before executing method getName(), execute method getNameAdvice(). It helps me understand @Aspect in spring, but I can't understand, why it doesn'...
Hubert Wajda's user avatar
0 votes
0 answers
31 views

Conflict when using annotation @Scheduled and @Before in spring boot

I'm having a Component in spring boot like this : @Component public class A{} @Scheduled(cron = "0 * * * * ?") public void B{ ....... List<Database> databases = databaseServiceImpl....
Nghi Hoàng Đức's user avatar
0 votes
2 answers
100 views

Spring Retry maxAttempts does not behave and calling more than configured

Trying to configure spring boot retry for simple method. When set maxAttempts = 3 xecuted 9 times. When maxAttempts = 2 executed 4 times. Below is my controller class. @GetMapping("/...
akalanka's user avatar
0 votes
0 answers
37 views

What is the most generic solution to look after changes of the fields of an entity in Java?

I was looking around to find what it is the best solution regarding observing changes of the fields of an entity. I want something generic and maybe to be used in other application in the future ( i ...
Trex's user avatar
  • 19
0 votes
2 answers
94 views

PointCut expressions in spring

I have two pointcut expressions: * *..*Repository.find*(..) * *Repository.find*(..) What is the difference between these two and what does the *..part of the first pointcut means?
firemancer's user avatar
0 votes
1 answer
76 views

Why are field values null when calling final methods on a proxy instance?

I have my own Spring Boot application and want to create my annotation, which will check incoming data to null. When I created the @Aspect annotated class, all other beans became null, what should I ...
YourDaddyProgrammer's user avatar
0 votes
1 answer
78 views

Spring AOP for Parent and Child relation classes

I'm working on existing code and I am writing some Auditing for the requests. I have tried multiple ways but my Pointcut expressions are not getting executed. I have created a separate class which has ...
Prajyod Kumar's user avatar
-1 votes
1 answer
29 views

How does AspectJ match @annotation advice expression with an annotation even when the expression in a different case (small case)?

@Auditable(value=1) public ResponseEntity upload(@RequestParam file){ // Code } This code is using an @Auditable annotation given below: @Retention(RetentionPolicy.RUNTIME) @Target(ElementType....
Namami Shanker's user avatar
0 votes
0 answers
16 views

In Fody plugin, can I retrieve service from IServiceCollection/DI?

I am going to adopt https://github.com/vescon/MethodBoundaryAspect.Fody as my AOP engine. However, since it is a compile time approach, I have problem on how to retrieve service from ...
mannok's user avatar
  • 1,732
0 votes
0 answers
42 views

Unit test failing after adding a new unit test for an Aspect

I am facing a weird issue and I'm not able to find out the root cause. I added a new unit test for an aspect that I have created and that is causing most of the test cases in the application to fail ...
Hindol Dey's user avatar
-1 votes
1 answer
55 views

How to change the @Cacheable condition field at runtime?

I am using Redis with Spring Boot and I want to make a flag to enable cache at runtime by AOP I tried to change the condition filed to "false" from AOP but it is not working and the caching ...
Ahmed Essam's user avatar
0 votes
0 answers
17 views

aspects, exceptionhandlers don't catch exception java spring

annotation @Target(ElementType.METHOD) @Retention(RetentionPolicy.RUNTIME) public @interface BotExceptionCheck { } @Aspect @Component public class BotExceptionCheckAspect { SendMessageProducer ...
wanderer's user avatar
0 votes
1 answer
16 views

i cannot see the aspect logs when i run the method to be intercepted

thats my code and this is only showing the logs as method is executed in intellij INFO: Publishing comment: Demo comment. Also added the dependencies but still i cant see whats the error. package com....
alpha's user avatar
  • 23
0 votes
1 answer
89 views

"This advice advises no methods"

I am trying to complete a simple (but, tbh, badly formulated) entry test. I used an aspect to incorporate the request limit feature, but the chances are it doesn't work. The IDE says "This advice ...
JoreJoh's user avatar
  • 319
-1 votes
1 answer
39 views

Building a library for using AspectJ

Background We have a Java project which uses Maven as the build tool. The project structure has a Parent POM and then various Child POMs. I am working on creating a child POM project where I want to ...
user762421's user avatar
1 vote
0 answers
43 views

Postsharp aspects reach to HttpContext

I am using PostSharp, and within my aspects, I want to check a header from the incoming request during the entry phase of a method. I am unable to access HttpContext. Is there a way to achieve this? ...
Saruhan's user avatar
  • 91
0 votes
0 answers
12 views

Using AOP to inject Security Access Policies at runtime

The problem space: High Level-> I'm looking for a way to apply security access policies during the runtime of my application (and use AOP to do this). In detail-> I currently store customer's ...
AChase99's user avatar
0 votes
1 answer
44 views

@Before doesn't allow pointcut reference, why?

I can do @Pointcut("@annotation(com.learning.validation.Validate)") public void validatePointCut() { } @AfterReturning(pointcut = "validatePointCut()") public ...
Kurian Kevin's user avatar
0 votes
0 answers
45 views

Define and increment a prometheus custom counter whenever slf4j Logger error() is being called from my class method's execution(E2E) using AOP

I have a requirement where I want to count number of org.slf4j.Logger.error() calls within my method's execution (across multiple class like controller--service--repo etc). I am thinking to use AOP ...
Sachin Mankotia's user avatar
0 votes
0 answers
6 views

Explanation of the principle of inverted dependency for spring ioc containers

I am a newcomer and have just started using experience Q&A recently. I have some doubts about some questions and hope everyone can help and support me. I hope it is rich and meaningful, dear gods. ...
xinyu zheng's user avatar
0 votes
0 answers
98 views

Custom annotation in spring boot

i have this simple java spring app public static void main(String[] args) { new TestClass().init() } and i want monitor some metric in the TestClass but it's not work @EnableMonitoring(level = 5) ...
Saman Obeydzadeh's user avatar
-1 votes
1 answer
83 views

Implement method of interface at runtime in Java Spring

I have a spring data repository for each of my model classes: interface CatRepository extends MongoRepository<Cat, String> { Optional<Cat> findById(String id); } interface ...
Robert Vanden Eynde's user avatar
0 votes
1 answer
185 views

Spring AOP custom annotation alternatives

I am working on a library which would allow clients to capture runtime data in their code. I am following the below steps. I am planning to do the following: Create a Annotation in Library. Use ...
user762421's user avatar
-2 votes
1 answer
27 views

Custom annotation issue?

Annotation @Target(ElementType.METHOD) // Annotation can be applied to methods @Retention(RetentionPolicy.RUNTIME) // Annotation will be retained at runtime public @interface MethodExecutionTime { } ...
Ansh Gupta's user avatar
0 votes
1 answer
151 views

Spring AOP running advices in separate threads [duplicate]

I have below Java code which intercepts the method getUserDetails() using Spring AOP and logs its execution time. The method calculateExecutionTime gets executed in the same thread as getUserDetails()....
user762421's user avatar
0 votes
1 answer
526 views

ClassCastException for configuration CGLIB proxy and org.springframework.cglib.proxy.Factory after upgrade Spring to 6.0.9 and Spring Boot to 3.0.6

In our project, after upgrade the SpringBoot from 3.0.4 to 3.0.9, several of our tests started to fail on Caused by: org.springframework.aop.framework.AopConfigException: Unexpected AOP exception ...
Petr Vraník's user avatar
0 votes
1 answer
31 views

Modify parseInt param before execution with @AspectJ

I'm using spring boot 3.1.0 with org.springframework.boot:spring-boot-starter-aop I can't make the aroundParseInt aspect to trigger. I do another aspect test (test1) and this one is triggering. What I ...
Isaachjk's user avatar
  • 103
-1 votes
1 answer
24 views

@Transactional public method invokes private method [closed]

I have a service: @Service public class SImpl implements S { @Override @Transactional(readOnly = true) public void mPublic() { mPrivate(); } private void mPrivate() { ...
Pup's user avatar
  • 77

1
2 3 4 5
74