Questions tagged [aspect]

An aspect is a module implemented in an Aspect-Oriented Programming language that contains code for a cross-cutting concern, like logging or security. For questions about the aspect ratio of images, use the aspect-ratio tag.

This tag is for Aspect-Oriented Programming. For questions and answers about the aspect ratio of images, please use the tag.

A feature of a program, like logging, is usually spread throughout a program and is not related to that program's main function. Such a feature is called a cross-cutting concern. The aim of aspect-oriented software development (AOSD) (also called aspect-oriented programming or AOP) is to move a cross-cutting concerns into an aspect. 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:

433 questions
0
votes
0 answers

Get logged-in username inside aspect in struts2-spring2.5 web application

I have a web application built on struts2 and spring2.5. It uses the MVC nature of struts and security, Dependency Injection, AOP from spring. I have used an aspect for logging operation which runs before any method is called. But by no way I am…
Soumya
  • 1,833
  • 5
  • 34
  • 45
0
votes
2 answers

@RequestMapping MethodInterceptor aspect ignores @Validated annotation

I have a strange problem with MethodInterceptor aspect and @Validated annotation. When I add the method interceptor to intercept all the methods annotated with @RequestMapping, the @Validated annotation does not work. When I remove it, it works fine…
0
votes
2 answers

@Around Aspect is Executing before @transaction Annotation Spring

I have one class with transaction Annotation: @Service @EnableTransactionManagement(order=2000) public class UserManagementServiceImpl implements UserManagementService { @Transactional public User addUser(User user) throws…
abhishek
  • 1
  • 2
0
votes
1 answer

spring aspect pointcut definition

In Spring we can share common pointcut definitions like below @Aspect public class SystemArchitecture { /** * A join point is in the web layer if the method is defined * in a type in the com.xyz.someapp.web package or any sub-package *…
lives
  • 1,243
  • 5
  • 25
  • 61
0
votes
0 answers

Spring AOP: passing parameters for logging

We are using a org.springframework.beans.factory.BeanFactoryAware to run a chain of commands. All the services of the system use one service to do the audit logging. This audit logging service needs an unique identifier that is set in our…
Sam Carleton
  • 1,339
  • 7
  • 23
  • 45
0
votes
1 answer

Spring @Transactional wont rollback after putting aspect around method

I have two transactional methods one inside other. When around aspect is not set around methodA Transactional anotation work well. After calling methodA we call methodB, methodB write something in DB, then we return in methodA, throw an exception…
Juka
  • 37
  • 1
  • 9
0
votes
1 answer

Returning HTTP status 400 from Spring AOP based around Aspect

I have an interesting problem with me (at least it is a problem from my current point of view). I have a RESTful web service that is exposing an interface. In our environment, we use annotation to decorate the request handlers, e.g.…
sgsi
  • 382
  • 1
  • 8
  • 18
0
votes
2 answers

How to replace PostSharp Aspect with fake aspect for unit testing

I have a class like the following: [Log] public class SomeClass { } With the LogAttribute being an OnMethodBoundaryAspect from PostSharp. I would like to have all instances of LogAttribute to be swapped out for some faked/mocked version of the…
cjablonski76
  • 173
  • 1
  • 13
0
votes
1 answer

Difference between Refactoring and Aspect Oriented Programming

I have a difficulty in understanding the different between Refactoring and Aspect Oriented Programming. I understand that Aspect Oriented Programming aims to increase modularity by separating cross cutting concerns, which also includes Code…
fuschia
  • 283
  • 2
  • 6
  • 23
0
votes
1 answer

Conversion to data format for crfsharp ...

I have a a review data set of about 250000 reviews of hotels, I'm planing to extract aspects from it using crfsharp dll, however the data that I have is in normal text paragraph form and I need to convert it into the format of crfsharp so I can…
praxprog
  • 21
  • 5
0
votes
1 answer

Cancel a method execution in an Aspect (which has been catched by "before")

Basicly I'm trying to cancel method execution in an aspect. So, here's my program: I have a Sender Application a receiver Application (let's call it the Central Monitor) In the Sender App : I have, An Activity (ın this activity, I have a…
Adnan Bal
  • 213
  • 3
  • 16
0
votes
0 answers

How to intercept JSF Managed bean Method via Spring AspectJ

I can not intercept the JSF managed bean methods via ASpectj. DO you know how to make it possible. I mean, does spring only intercept its own context class methods? Aspect Class package com.netas.afad.log; import java.util.Arrays; import…
Ahmet Karakaya
  • 9,899
  • 23
  • 86
  • 141
0
votes
2 answers

Using Spring AOP uses underneath aspectj?

Hy, Reading a lot about Spring AOP vs AspectJ, I still have some doubts: 1.)When using Spring AOP with classes annotated with @Aspect and using "aop:aspectj-autoproxy" tag , it can be said that we are using just the annotations of aspectj or besides…
fernando1979
  • 1,727
  • 2
  • 20
  • 26
0
votes
1 answer

Pointcut entity load/persist JPA actions?

I'd like to wrap/unwrap my Entity each time it's loaded or persisted. I got to know that I cannot do it using JPA listeners since they can only perform an action on the object and not swap it with the other. The natural solution would be to use an…
kboom
  • 2,279
  • 3
  • 28
  • 43
0
votes
1 answer

PostSharp AOP - Unable to apply aspect to mscorlib System.IO.StreamReader members

**I'm using PostSharp Express... not sure that would make a difference in this instance though. I've got an OnMethodBoundary->OnEntry aspect that successfully multicasts at the assembly level to class members in my own code, but when I attempt to…
Brett Rossier
  • 3,420
  • 3
  • 27
  • 36