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
50
votes
3 answers

What is AspectJ good for?

First let me note, that I use AspectJ and I like it, but what else can I do with it. I know AspectJ can be/is used for Logging. In some cases it is used for Transaction controlling – mostly implemented in conjunction with annotations. AspectJ can…
Ralph
  • 118,862
  • 56
  • 287
  • 383
33
votes
1 answer

Interceptors vs Aspects in Spring?

I am trying to use interceptors in Spring. I want to implement an interceptor on some methods to handle specific logic when these methods are called. I also want to be apart from using web framework, as am tending to use Spring as back end, without…
Amr Faisal
  • 2,004
  • 6
  • 27
  • 36
11
votes
3 answers

Using annotations for trace logging

I've been working with a codebase of a company that has a policy of writing lots of trace logging. So pretty much every method has a piece of code that starts like this: String LOG_METHOD =…
mahler
  • 526
  • 5
  • 25
11
votes
1 answer

IntelliJ IDEA + AspectJ

I am trying to use AspectJ in sample project in IntelliJ IDEA. I have an experience with Spring AOP, but this is first time I am using AspectJ, and cannot make it work. I am trying to do as described here:…
spam
  • 1,853
  • 2
  • 13
  • 33
11
votes
3 answers

How do you use stereotype annotations in Spring 2.5.x?

When moving to Spring 2.5.x I found that it adds more stereotype annotations (on top of @Repository from 2.0): @Component, @Service and @Controller. How do you use them? Do you rely on implicit Spring support or you define custom stereotype specific…
topchef
  • 19,091
  • 9
  • 63
  • 102
9
votes
2 answers

Is AspectF (a Fluent Aspect Framework) an AOP-like design that can be used without much concern?

Omar Al Zabir is looking for "a simpler way to do AOP style coding". He created a framework called AspectF, which is "a fluent and simple way to add Aspects to your code". It is not true AOP, because it doesn't do any compile time or runtime…
9b5b
  • 1,508
  • 11
  • 20
7
votes
6 answers

Future of Aspect Oriented Programming

I am a newbie in the area of AOP. The first time I coded something applying concepts of AOP, I was thrilled to understand how aspects eliminate cross cutting patterns in your application. I was overwhelmed by the thought of solving cross cutting…
Jay
  • 2,394
  • 11
  • 54
  • 98
7
votes
1 answer

Replace Property Getter/Setter with Reflection or similar (no 3rd party libraries) in c#

I've got a property contained in a class for example public class Greeter { private Hashtable _data; public string HelloPhrase { get; set; } public Greeter(data) { _data = data; } } What I would like to do is add an Attribute to…
Mike Miller
  • 16,195
  • 1
  • 20
  • 27
7
votes
6 answers

How to separate logging logic from business logic in a C program? And in a C++ one?

I am currently coding in C and I have lots of printfs so that I can track, at some times, the flow of my application. The problem is that some times I want more detail than others, so I usually spend my time commenting/uncommenting my C code, so I…
devoured elysium
  • 101,373
  • 131
  • 340
  • 557
7
votes
1 answer

PostSharp on assemblies I don't have source for

In the examples on their website, PostSharp has a demo of intercepting calls in main system assemblies. I have tried a few times to setup and replicate said intercept calls on assemblies I don't have the source code for with no success. My approach…
pinvoke
  • 331
  • 1
  • 3
  • 10
6
votes
1 answer

Using aspects from other jars

What I'm trying to accomplish is the following: I have a server with the following structure. bin apis services etc... I want to define an API that contains an aspect to be used by services. Say: @Aspect public class AuthorizationAspect…
rpvilao
  • 1,116
  • 2
  • 14
  • 31
4
votes
3 answers

Use Spring @Transactional in Scala

We have a mixed Java and Scala project, which uses Spring transaction management. We are using the Spring aspects to weave the files with @Transactional annotated methods. The problem is, that the Scala classes aren't woven with the Spring…
timomeinen
  • 3,101
  • 3
  • 33
  • 46
4
votes
0 answers

instanceof not working with aspects in Spring

I have a Spring Bean obtained from a factory, say, private ObjectFactory studentFactory; public void somemethod() { IStudent astudent = studentFactory.getObject(); System.out.println(astudent instanceof GoodStudent); // prints…
Antho Christen
  • 1,369
  • 1
  • 10
  • 21
4
votes
2 answers

AspectJ Handling of Multiple Matching Advices

I am using AspectJ in Java to log the calls to some methods. I've looked online but couldn't manage to find an answer to this: What happens when two @Around advices match for a method? Specifically, I am using two @Around advices, like…
Vlad Schnakovszki
  • 8,434
  • 6
  • 80
  • 114
4
votes
2 answers

Autocompletion in Eclipse for Roo project

I've got a Roo project where I've made a couple of entities, and when I load up the project in Eclipse it loads up fine, but if I i.e. make an instance MyEntity entity and then write entity. I don't get any of my properties (i.e. getMyField) in the…
niklassaers
  • 8,480
  • 20
  • 99
  • 146
1
2 3 4 5 6