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.

aop
960 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
9 votes
1 answer
1k views

Aspect around Kotlin suspended function

What is the right way to create an aspect around Kotlin suspended function? From my observation, Micrometer's @Timed aspect does work with them, but shows incorrect result - looks like it measures ...
silent-box's user avatar
  • 1,658
7 votes
0 answers
3k views

Spring AOP + JPARepository

I'm using Spring Data in my project. So, I need to intercept some methods (save and delete) only from some entities only. I tried to configure the pointcut for my own repositories interfaces, but ...
Luciano Nunes's user avatar
7 votes
0 answers
6k views

how to use a ContextBoundObject to intercept a function call before/after the invocation?

I have read this article and I can't find a good example for how to use a ContextBoundObject to intercept a function call. Can anyone show me how it's done? Also, a side question: Why can't I use a ...
the_drow's user avatar
  • 19k
6 votes
0 answers
310 views

How to introduce new property based on existing property and modify existing one?

I am trying to automate this XmlSerializer workaround pattern. See update below. Is it possible to introduce new property based on existing property and modify attributes of existing one using ...
Anton Krouglov's user avatar
6 votes
1 answer
6k views

How do I get my Spring aspects to execute before @Valid/@Validated annotation on a spring controller method?

I have this service/controller method: public ResponseEntity<PolicyDTO> addPolicy(@Valid @RequestBody PolicyDTO policy) throws InternalServerException, BadRequestException { log....
Mircea's user avatar
  • 393
6 votes
2 answers
8k views

Java - How to combine Validation and AOP annotations and use it in Spring Controller?

Currently we are migrating a Struts 1.1 project into Spring 4.x. We have successfully converted Action class to Controller and formbean to Model and even we are able to convert struts validation to ...
Selvakumar Velmurugesan's user avatar
6 votes
1 answer
307 views

Spring(Java): Aspect is not triggered in non linear class hierarchy

When class hierarchy is not linear, aspect is not triggered when defined on base interface. The most interesting: when adding delegating implementation (see last code block) to the parent class of ...
Sergej Werfel's user avatar
6 votes
0 answers
1k views

Spring AOP: inherited methods

I am using Spring AOP 4.0.x. I have the next classes: class A { public void methodA() { // ... } } class B extends A { public void methodB() { // ... } } class C ...
yaskovdev's user avatar
  • 1,235
6 votes
0 answers
1k views

AOP with Castle Windsor

What I'm trying to achieve is AOP via attributes using Castle Windsor interceptors. I've had some success but having trouble with the aspects at the class level vs. the method level. If I use class ...
Juan Ayala's user avatar
  • 3,458
6 votes
1 answer
1k views

Load time weaving in grails

I'm trying to use load time weaving in a Grails project in order to be able to serialize and deserialize an object and to have automatic injection of spring dependencies. After some searching I found ...
sterym's user avatar
  • 553
6 votes
1 answer
1k views

Difference between Aspects, concerns and cross-cutting concerns in Spring AOP

Can anyone please explain the difference between Aspects, concerns and cross-cutting concerns in Spring AOP with example? I have gone through a lot of tutorial sites but I didn't get any good ...
Rezaul Hoque's user avatar
5 votes
1 answer
3k views

spring aop - chaining multiple aspects

i have two aspects, one for acquiring a lock @Around a call, another one for debouncing method calls. the aspects look like this: @Pointcut("execution(public * * (..))") private void ...
rmalchow's user avatar
  • 2,719
5 votes
3 answers
13k views

Spring AOP with Around advice and @annotation not working

I am using Spring AOP for logging in my application. Here is the applicationContext.xml file <mvc:annotation-driven /> <context:component-scan base-package="com.template" /> <context:...
Mahesh's user avatar
  • 101
5 votes
1 answer
6k views

How to implement annotation based security using Spring AOP?

I'm new to Spring AOP (and AOP in general), need to implement the following: @HasPermission(operation=SecurityOperation.ACTIVITY_EDIT, object="#act") public Activity updateActivity(Activity act) { ...
Sergey Makarov's user avatar
5 votes
0 answers
282 views

Applying AOP to a 3-tier winforms application

Background I am trying to implement logging and exception handling using AOP for a new project. I wish to apply this through all the 3 layers of a Windows form application. I am using Windsor ...
nikhil pinto's user avatar
5 votes
1 answer
563 views

ServiceStack ResponseFilterAttribute not being called

//--------------------------------------------------------------------- //Aspect Filters public class RequestAspectAttribute : RequestFilterAttribute { public RequestAspectAttribute() { } //debug ...
Tom's user avatar
  • 16k
5 votes
0 answers
2k views

AOP Not serializable org.springframework.aop.aspectj.annotation.InstantiationModelAwarePointcutAdvisorImpl?

I'm using Eclipse IDE and tomcat 7.0 I have a client-server application. In the server side I have a StationInterface and Station class that implements the StationInterface and Serializable, and I'm ...
eliorsh's user avatar
  • 195
4 votes
1 answer
202 views

In Spring, how to flag transaction info?

I need to somehow flag a transaction. Need some method like: TransactionAspectSupport.setData(someObject); Then till the transaction is alive I would like to be able to read those data. I need it to ...
user1685860's user avatar
4 votes
0 answers
1k views

AOP not working in the interface method implementations

I have a situation where I have a default method which is calling another method of the same interface. public interface Test { default Boolean isValidObject(String A) { ComplexObject B= ...
prasingh's user avatar
  • 462
4 votes
1 answer
57 views

How to apply limitations into all of business points in spring/hibernate enterprise application without change codes?

Assume this class diagram: I have class named Organization that many objects has association to that. also there are many object in addition to the StoreHouse and Personnel, but to have simple class ...
Rasool Ghafari's user avatar
4 votes
0 answers
2k views

Django Rest Framework models post_save signal is executed after post request is completed

I have the following serializer: class CreateOrderSerializer(OrderSerializer): class Meta(MetaOrder): fields = MetaOrder.fields + ('pair',) read_only_fields = MetaOrder....
Oleg Belousov's user avatar
4 votes
0 answers
1k views

Spring aspect support for repeatable annotation?

I have created a java8's repeatable annotation and want create an aspect before the method containing the annotation is invoked. This seems to work when method is annotated once but fails to invoke ...
Chinmay's user avatar
  • 741
4 votes
0 answers
722 views

AspectJ: @AfterReturning

I've created this pointcut: @Pointcut("execution(* com.living.commty.boot.resources.*.* (..))") public void resourcesCut() {} I'm trying to get the return value after having been returned: @...
Jordi's user avatar
  • 22k
4 votes
1 answer
2k views

Role of spring-aspects jar in AOP?

I have following dependencies using in my pom <dependency> <groupId>org.springframework</groupId> <artifactId>spring-aop</artifactId> ...
emilly's user avatar
  • 10.3k
4 votes
1 answer
716 views

I'm getting a NoSuchMethodError when trying to use Guice AOP

I'm trying to use Guice AOP for profiling: @Override protected void configure() { this.bindInterceptor(Matchers.any(), Matchers.annotatedWith(Profiled.class), new ProfileInterceptor()); } It's ...
BradMicholson's user avatar
4 votes
3 answers
10k views

Could not find dependencies for aspectj-maven-plugin

I have a problem with CTW aspects using aspectj-maven-plugin. I get the following error (execution entry is being highlighted): Multiple annotations found at this line: - Execution default of ...
kboom's user avatar
  • 2,309
4 votes
0 answers
643 views

AspectJ: pointcut after completed object initialization

I want to add an advice that runs for each object created from a set of classes (in my case, from a specific package) after initialization is complete. Consider this code: public class Test { ...
Silly Freak's user avatar
  • 4,121
4 votes
0 answers
2k views

Spring - Injecting resources in per-scoped (perthis - pertarget) aspect

In my Spring web application, I'm trying to inject a resource in a perthis-scoped AspectJ aspect. Injection works well using a singleton aspect, but fails using a perthis scoped one. I tried using ...
user1781028's user avatar
  • 1,498
4 votes
0 answers
386 views

Need advice how to decouple logging functionality from data processing in Python

In my project, I have a set of classes that do some job by calling external commands, and return their results. Let's call them "reports". I want to add logging to these reports, however, a concrete ...
Serge Tarkovski's user avatar
4 votes
2 answers
8k views

Spring AOP @Pointcut not triggering

I want to trigger a method when a particular method from another class is invoked that is why I thought of using @Pointcut. The code below is almost identical to the that I am coding and I don't what ...
Alvin's user avatar
  • 136
4 votes
1 answer
2k views

Spring declarative transaction management : multiple pointcuts

I know its almost weekend but still worth trying :) I need to use multiple transaction managers due to which it makes sense for me to go with declarative transactions management instead of using tx:...
sul's user avatar
  • 267
4 votes
1 answer
1k views

Getting real instance from proxy under Unity Interception with NHibernate

I'm using Unity to resolve types dynamically for a pluggable architecture. I'm also using interception to apply business rule validation via AOP (using ValidationAspects). Finally, I'm using ...
Neil Hewitt's user avatar
  • 2,518
4 votes
2 answers
2k views

Any way to wrap all IOExceptions to a RuntimeException instead?

I am using a third party REST API in which every single API call is defined as throws IOException. I am wrapping the REST API in a Repository-style class. However, given the API interface, I am ...
Eric B.'s user avatar
  • 24k
3 votes
1 answer
7k views

Error creating bean with name 'org.springframework.transaction.annotation. error at ::0 formal unbound in pointcut Spring AOP

I'm facing an error that mentioned below, related to Spring Aspect Oriented Programming. 2022-05-06 17:26:44 ERROR org.springframework.boot.SpringApplication.java Line 826: Application run failed org....
Dulani Maheshi's user avatar
3 votes
2 answers
2k views

Spring AOP - I want to apply the pointcut to a class from a library

I'm trying to use Spring AOP to add logging to methods coming from a third party library. So there is a class, ProxyServlet, that is being used by my Spring Boot application, and I just want to apply ...
craigmiller160's user avatar
3 votes
0 answers
984 views

Using aspectJ with Cucumber

I am trying to use aspectJ with cucumber project to add conditional statements with cucumber(you may think why.. but I am). It intercepts the cucumber step definitions that I have in my current ...
MagicBeans's user avatar
3 votes
0 answers
354 views

Initialising Spring AOP hangs the entire application after few successful requests

I have Spring 5.0.4 application with a Dispatcher servlet config file as spring-web-servlet.xml (spring-web being Dispatcher servlet name). To enable AOP in the application, I made the entry <aop:...
Ravi Agrawal's user avatar
3 votes
0 answers
346 views

Spring AOP in different projects does not work

I am new to Spring AOP and AspectJ but the simplicity they can provide makes me want to use them. The questions is: I have two projects, one is a spring boot application server and the other one ...
ruomeng's user avatar
  • 31
3 votes
1 answer
356 views

Upgrading Unity container breaks interception mechanism

We recently upgraded Microsoft's Unity in our project from version 3.5.1404 to 5.8.6. With only a few minor adjustments in our code this upgrade seemed to go pretty easy. It resolves all our ...
Niles11's user avatar
  • 553
3 votes
1 answer
391 views

Logging with context information

I am working on a greenfield project and I want to integrate serilog with ninject. The use case is as follows: There are a number of common libraries These libraries are used in a number of modules ...
Bernard's user avatar
  • 995
3 votes
0 answers
4k views

how to use aop concept in spring restful web service @controller?

I'm new in spring aop concept. I want to build logging functionality using spring aop. I got so mamy examples but what I need is: I have @controller class and each method having requestmapping url, ...
Unnati's user avatar
  • 71
3 votes
1 answer
2k views

How to use spring aop with class from external jar

I need to intercept org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter#handle method and i use spring aop for that. It is spring class from spring-webmvc.jar. It uses ...
miroshnik's user avatar
  • 163
3 votes
2 answers
2k views

AOP aspects in a multi-module Maven project

I have a multi-module Maven project and configured Spring AOP in one of my module. Unfortunately AOP only works for the project where it is. Here is my Maven config: The parent pom.xml: <parent&...
Pulkownik's user avatar
  • 530
3 votes
2 answers
2k views

Intercept Method Invocation or Property Change with Reflection

I'm trying to create a generic class that will fire an event whenever a method is called or a property is accessed or changed. It may also fire events in response to other changes or actions being ...
jmindel's user avatar
  • 505
3 votes
0 answers
670 views

Running an aspect inside the transaction boundary of the calling method

I am having a method annotated with spring @Transactional and another custom annotation @Counter. @counter is used by many other methods from different classes. @Transactional @Counter public int ...
EmeraldTablet's user avatar
3 votes
0 answers
2k views

Adding Response Header using AspectJ spring

I'm trying to add a response header to all the responses in my java application, to do that I'm using AspectJ. In other words, what I want to do is, in the moment before the Response is being ...
Jay's user avatar
  • 768
3 votes
0 answers
718 views

Spring Aspect or AspectJ Pointcut that matches the value of annotation

Code: @Controller public class TestController { @RequestMapping("/{abc}/{def}") public String handleTest(HttpServletRequest request, HttpServletResponse response,...
ssgao's user avatar
  • 5,331
3 votes
1 answer
384 views

Is it possible to implement method result caching based on field injection instead of a Map?

I've seen some implementations of method result caching using AspectJ. For example, one in jcabi-aspects or some older examples. The idea is that instead of writing bolierplate code for caching ...
gvlasov's user avatar
  • 19.4k
3 votes
0 answers
883 views

Eagerly loaded spring beans are preventing load-time-weaving

I am trying to configure AspectJ load time weaving and I need to weave a spring managed bean. This is because unfortunately the spring bean I'm interested in is in a third party library and has no ...
moncheery's user avatar
  • 343
3 votes
0 answers
248 views

Spring Data repository proxy Pointcut on Annotation

I know generally you cannot execute a pointcut based on an annotation that was made on an interface, but is there anyway to do this with Spring Data Repository Proxies? I have custom annotations for ...
Leon's user avatar
  • 12.3k

1
2 3 4 5
20