What are the possible uses for AOP?

I would like to talk about possible cases of effective participation of AOP in application development. Everything I've met so far:

  • logging related
  • security checks
  • transaction management
  • configuring an outdated application

Anything else?

(It does not have to be Spring based on AOP proxy - rather JOBSS AOP.)

( Related question )

+47
java spring aop jboss use-case
Feb 04 '10 at 2:55
source share
11 answers

I can give two examples where we use it:

  • Automatic registration of objects in JMX for remote management. If a class is annotated with our @AutoRegister annotation, we have an aspect that keeps track of new instances of this class and automatically registers them in JMX.

  • Keeping an audit trail (use case of AOP in the gold standard). Its a bit crude, but the general approach is to comment on methods that are some kind of testable action. Combined with something like Spring Security, we can get a good idea:

    • who is the user
    • what method do they call
    • what data they provide.
    • during method call
    • whether the call was successful or not (i.e. if an exception was thrown)
+25
Feb 04 '10 at 3:25
source share
— -

To see the scope of AOP from the point of view of applicability, I really recommend that you read the book Aspect-Oriented Development Programs — Case Studies . This book discusses options for using functional and non-functional requirements using AOP. After that, you will see that aspects can be used for more requirements than logging, tracing, security, etc.

+7
Feb 04 '10 at 10:11
source share

One effective use of AOP, besides all those listed by you, can be verified. Validate user input or business objects.

Related articles you should pay attention to.

+4
Feb 04 '10 at 4:05
source share
  • Read / write locks . Instead of replicating the same fragment, I used the aspect to identify methods that require read locks or exclusive locks.
+4
Feb 04 2018-10-12T00
source share

Method level caching if your method has no state (I mean returning the same value when called again with the same parameter values). This is more effective with DAO methods, since it avoids database hits.

+3
Feb 04 '10 at 6:37
source share

We use it to manage software licenses, that is, we only allow software to run if a certain license is installed on the computer. This is not so different from the uses you have listed, as it is a form of security check.

I posted a blog post describing the practical implementation here

+3
Nov 21 '10 at 0:12
source share
  • Exception handling: no need to repeat the awful try list ... catch, catch, catch, etc. - also means that exception handling is guaranteed.
  • Performance monitoring: very useful since using the aspect is not intrusive and can be done after the fact and then turned off when it is no longer required.
+2
Feb 05
source share

I will also recommend aspects for:

  • Asynchronous method calls
  • Monitoring

With Spring and tcServer (developer), you can easily control all your Spring beans with @ Component annotation. You can see the time used, input and return data, including exceptions.

+1
Feb 10 2018-10-10
source share

INotifyPropertyChanged and similar horrors.

Basically wherever there is code that looks like this: use the aspect, and you're done.

+1
Jul 16 '10 at 15:17
source share

Checking the execution time of code contracts. .NET code contracts use AOP to

Check runtime. Our binary rewriting module modifies the program by entering contracts that are checked as part of the program execution.

+1
Oct 02 '15 at 15:24
source share

We use AspectJ to perform AOP. Use cases other than those listed above are:

  • Restricting access to method calls to only a few classes.
  • Automatic annotation of selected methods / classes / fields.
0
Jan 04 '16 at 4:57
source share



All Articles