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
4
votes
1 answer

Spring AOP aspect around not executing

I want to count now much my method worked. So I use Around aspect but it doesn't work. Neither with annotations nor XML. Dubgger shows that Aspect hasn't been invoked. Unfortunatly, non of examples…
Devour
  • 305
  • 3
  • 15
4
votes
2 answers

Why is this Spring Aspect not printing as it should with method parameter?

Let me first foremention, the problem I'm facing is with the interceptThoughts(String thoughts) method, from the first code block, not printing I'm running a tutorial from Spring in Action. There's a Magician class that implements MindReader…
Paul Samsotha
  • 205,037
  • 37
  • 486
  • 720
4
votes
4 answers

Any PostSharp alternative?

I have to abandon using PostSharp, because it won't work with obfuscated/merged assemblies. At least, I don't see any way to get it working (it crashes on app start, when assemblies are obfuscated) I need to intercept some methods in my app (call…
skevar7
  • 995
  • 1
  • 10
  • 21
4
votes
3 answers

Creating our own aspects using custom annotations

I am new to Annotations and new to StackOverflow and this is my first question. I am trying to write custom annotations which will help me trace and log method executions. For example: class A { @Logthis void methodA(); } Here whenever the…
yash6
  • 141
  • 3
  • 14
4
votes
4 answers

Why does the serialVersionUID field exist?

It has baffled me from the launch of the Serializable interface why I have to incorporate this field in all of my classes. I understand that this interface needs a unique identifier to mark the class but why cant they generate this at run-time. For…
nikdeapen
  • 1,581
  • 3
  • 15
  • 27
3
votes
2 answers

Adding an aspect to catch an exception and return null instead

I've switched from using Spring Data JPA for regular DAO objects with Entity Manager and found out, that instead of returning null the .getSingleResult() throws NoResultException. Is there some way of adding an aspect that would surround all the DAO…
Vojtěch
  • 11,312
  • 31
  • 103
  • 173
3
votes
1 answer

How can I apply an aspect using annotations in Spring?

Update: I've found the Spring 2.x annotation-based Controllers are horrible for AOP security because you can't make assumptions about the method prototype due to the increased freedom in params and return values. Before 2.x you could intercept…
Robert Campbell
  • 6,848
  • 12
  • 63
  • 93
3
votes
2 answers

AspectJ - why use annotations instead of ajc compiler?

We can use both @AspectJ annotation style to define aspects, as well as the AspectJ Java extension language, which requires us to use the ajc compiler. What are the reasons that one would want to use the annotation style instead of ajc? It seems to…
polomo12
  • 95
  • 1
  • 6
3
votes
5 answers

Aspect Oriented Programming in Ruby

What frameworks exist to add AOP to Ruby?
gunit888
  • 571
  • 6
  • 14
3
votes
1 answer

redirected request when exception throwed

in my application (using spring), i try to call a method from view using spring exposingBean. and when i try to invoke a method from view, it throw error. i try to catch with HandlerExceptionResolver, but no luck, i think it cannot handled by…
Jeg Bagus
  • 4,895
  • 9
  • 43
  • 54
3
votes
2 answers

How to intercept method which handles its own exceptions using AspectJ

I'm trying add some monitoring when some specific exception occurs. For example, if I have an aspect like this: @Aspect public class LogAspect { @AfterThrowing(value = "execution(* *(..))", throwing = "e") public void log(JoinPoint joinPoint,…
4evertoblerone
  • 95
  • 1
  • 3
  • 12
3
votes
3 answers

Scala and Aspects

Scala and Aspects can be used together? Are there benefits in this case? Thanks
adelarsq
  • 3,718
  • 4
  • 37
  • 47
3
votes
1 answer

C# AOP Method Interception on child method calls?

My AOP (C#) implementation always intercepts the first (public) method call but not subsequent methods called within the first intercepted method, is this a limitation with ContextBoundObject AOP implementations or am I doing it…
Jon
  • 4,295
  • 6
  • 47
  • 56
3
votes
2 answers

Aspectj. Creating innter type methods in multiple classes

If I put: public CountryState CountryState.find(long id) { return (CountryState) findById(CountryState.class, id); } I'm creating a method find in the class CountryState. Is there a way to create a method in several classes? Do I need to…
John John Pichler
  • 4,427
  • 8
  • 43
  • 72
3
votes
1 answer

CodeFluent Aspect: How to Set up DropDown Input with Entity Properties

I'm developing an Full-Text Index Aspect, and I got to the point where I can specify a property to be a full-text index. However, the next thing I want to do is specifying inside the SQL Full Text Index syntax, the "TYPE COLUMN xx", where "xx" is…
MTran
  • 1,799
  • 2
  • 17
  • 21