Questions tagged [aspects]

Aspects are modules implemented in an Aspect-Oriented Programming language that contain code for a cross-cutting concern, like logging or security.

Features of a program, like logging, are usually spread throughout a program. These features are not related to that program's main function and are called cross-cutting concerns. The aim of aspect-oriented software development (AOSD) (also called aspect-oriented programming or AOP) is to move cross-cutting concerns into aspects. This is called refactoring the code.

In AOSD, aspects are written separately from the main application, which can be written in any standard OOP language. An AOP compiler, like AspectJ, compiles the AOP code and object-oriented programming (OOP) code together in a process called weaving.

AOP is often used to enhance legacy applications or 3rd party libraries when the original source code is not available. It is also used to overcome the main weakness of OOP by collecting the cross-cutting concerns into aspects.

Wikis:

See also:

77 questions
1
vote
1 answer

Spring AOP Aspect not executing

I've been trying to figure out why my simple aspect is not getting executed. I looked at the answers of similar problems but i still can't get it to work. My intention is to wrap the execution of a method annotated with a custom annotation with an…
JDR
  • 33
  • 1
  • 3
  • 8
1
vote
0 answers

Lombok and AspectJ with Sprint boot 2

I am trying to use Lombok along with AspectJ utilising spring boot.However, the ajc is not able to identify the getters/setters created by Lombok.I did try multiple attempts at it searching various solutions provided i.e generating delombok and then…
1
vote
1 answer

PostSharp - break other aspects

I have two method that execute first the "Cache" aspect and next the "Log" aspect. I want that, if I have a "cache hit" I don't have to Log anything! In other words, if a certain condition in "Cache" aspect is satisified then the "Log" aspect must…
Ricibald
  • 9,369
  • 7
  • 47
  • 62
1
vote
1 answer

Spring Aspect not working as it should

I am trying to add a very simple aspect to my application which is responsible for monitoring changes in entities. Basically I want to rise a flag after a setter within a class is called like this: @After("execution(*…
1
vote
0 answers

When an entity has a Spring Data Repository, the LoadTimeWeaving for this entity doesnt work

For example, the User entity : @Configurable @Entity @Data @EqualsAndHashCode(callSuper = false) @DynamicInsert @DynamicUpdate public class User extends AbstractAggregateRoot implements Serializable { private static final long…
陈振阳
  • 131
  • 1
  • 4
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

Log message on Spring AOP Aspect start up

how to log message on Spring AOP aspect start up? The only way I see is to specify flag on every intercepted method and check. May be any other options? Thanks
antongarakh
  • 570
  • 6
  • 16
1
vote
2 answers

Spring AOP : Interface method with Parameter annotation captured, but annotation is not present

I'm using Spring AOP to intercept a method execution. I have an interface that looks like the following: public interface MyAwesomeService { public Response doThings(int id, @AwesomeAnnotation SomeClass instance); } Here is the implementation…
n00bc0der
  • 103
  • 1
  • 3
  • 9
1
vote
1 answer

Can I enable/disable aspects from an external application?

Supposing I have two applications, one that has features based on aspect oriented programming such as authentication, authorization, logging, exception handling etc. and the other one that connects to the previous application and has buttons that…
user1012732
  • 181
  • 2
  • 14
1
vote
4 answers

Can I get WebApi to work with IoC Aspects/Interceptor

I'm from a WCF background where I successfully used IoC with Aspects/Interceptors to abstract functions such as Authentication and Logging. I would simply just add the required interfaces to the aspects constructor the same way as you would with any…
Steve Parry
  • 366
  • 3
  • 12
1
vote
1 answer

Is there a data binder using aspects and annotations?

I want to write a java application using swing, spring and hibernate. I want to use a data binder to populate the gui with the values of a bean, and I also want it to reflect updates of the bean in the gui. It seems there is a way to do that in…
Bernhard
  • 665
  • 1
  • 6
  • 22
1
vote
1 answer

Using aspect.around, but checking for methods calling each other

I would like to run some specific code around put() and add() for Dojo stores. The problem I am having is that for JSON REST stores, in JsonRest.js add() is just a function that calls put(): add: function(object, options){ options = options ||…
Merc
  • 16,277
  • 18
  • 79
  • 122
1
vote
1 answer

Can pointcuts be dynamically thread specific?

I want to track all my public method calls under a certain condition. But I want this tracking to hurt the whole system performance as little as possible. I would need a way how to "turn on" a pointcut dynamically to be executed just for a specified…
1
vote
1 answer

Why a defined pointcut with @target doesn't work?

I'm trying to use Spring aspects to do save aditional data while storing documents with MongoRepository. The target is this interface: @InSearch public interface ItemRepository extends MongoRepository, ItemRepositoryCustom { …
francadaval
  • 2,451
  • 3
  • 26
  • 36
0
votes
1 answer

Spring AOP with annotations Help Needed !

Can anyone help me with some sample code? I need to implement Spring AOP and Annotations to achieve a Db Audit or Logging, in a Services Level. Some code I found online, but nothing very clear and tidy. I tried it with examples, but I never could…
CactusPolock
  • 11
  • 1
  • 5